Refactor devices.php
Some checks are pending
docker / docker_dev (push) Waiting to run

This commit is contained in:
jokob-sk
2024-08-31 17:32:10 +10:00
parent 25667014fc
commit 5a96ad2304
10 changed files with 90 additions and 143 deletions

View File

@@ -12,7 +12,7 @@ var timerRefreshData = ''
var emptyArr = ['undefined', "", undefined, null, 'null'];
var UI_LANG = "English";
const allLanguages = ["en_us", "es_es", "de_de", "fr_fr", "it_it", "ru_ru", "nb_no", "pl_pl", "zh_cn", "cs_cz"]; // needs to be same as in lang.php
const allLanguages = ["en_us", "es_es", "de_de", "fr_fr", "it_it", "ru_ru", "nb_no", "pl_pl", "pt_br", "tr_tr", "zh_cn", "cs_cz"]; // needs to be same as in lang.php
var settingsJSON = {}
@@ -1201,7 +1201,7 @@ function callAfterAppInitialized(callback) {
// Check if the code has been executed before by checking sessionStorage
function isAppInitialized() {
// return arraysContainSameValues(getCache("completedCalls").split(',').filter(Boolean), completedCalls_final);
return (parseInt(getCache("completedCallsCount")) == completedCallsCount_final);
return (parseInt(getCache("completedCallsCount")) >= completedCallsCount_final);
}
// Define a function that will execute the code only once

View File

@@ -437,8 +437,6 @@ function filterRows(inputText) {
}
setTimeout(() => {
// Event listener for input change
$("#settingsSearch").on("input", function () {
@@ -711,8 +709,9 @@ function generateOptions(options, valuesArray, targetField, transformers, placeh
resultArray = []
selectedArray = []
cssClass = ""
// determine if options or values are used in teh listing
// determine if options or values are used in the listing
if (valuesArray.length > 0 && options.length > 0){
// multiselect list -> options only + selected the ones in valuesArray
@@ -730,21 +729,31 @@ function generateOptions(options, valuesArray, targetField, transformers, placeh
resultArray = options;
}
// Create a map to track the index of each item in valuesArray
const orderMap = new Map(valuesArray.map((item, index) => [item, index]));
// Sort resultArray based on the order in valuesArray
resultArray.sort((a, b) => {
const indexA = orderMap.has(a.id) ? orderMap.get(a.id) : valuesArray.length;
const indexB = orderMap.has(b.id) ? orderMap.get(b.id) : valuesArray.length;
return indexA - indexB;
});
resultArray.forEach(function(item) {
let labelName = item.name;
labelName = item.name
if(labelName != '❌None')
{
labelName = reverseTransformers(labelName, transformers)
if (labelName !== '❌None') {
labelName = reverseTransformers(labelName, transformers);
}
// needs to happen always if options ued as source
let selected = options.length != 0 && valuesArray.includes(item.id) ? 'selected' : '';
// Always include selected if options are used as a source
let selected = options.length !== 0 && valuesArray.includes(item.id) ? 'selected' : '';
optionsHtml += `<option class="${cssClass}" value="${item.id}" ${selected}>${labelName}</option>`;
});
// Place the resulting HTML into the specified placeholder div
$("#" + placeholder).replaceWith(optionsHtml);
}

View File

@@ -249,6 +249,7 @@ function initSelect2() {
// --------------------------------------------------------
//Initialize Select2 Elements and make them sortable
$(function () {
// Iterate over each Select2 dropdown
$('.select2').each(function() {