From d11ebcb652fb76391928bbbc0c338d4a5737e3a9 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 1 Dec 2017 13:25:39 +0100 Subject: [roomplanner] Sort already placed machines to the bottom --- modules-available/roomplanner/clientscript.js | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'modules-available/roomplanner/clientscript.js') diff --git a/modules-available/roomplanner/clientscript.js b/modules-available/roomplanner/clientscript.js index 1cd65132..722e3909 100644 --- a/modules-available/roomplanner/clientscript.js +++ b/modules-available/roomplanner/clientscript.js @@ -11,10 +11,16 @@ var selectMachinInitialized = false; var placedMachines = []; +function makeCombinedFieldSingle(item) +{ + item.combined = (item.machineuuid + " " + item.hostname + " " + item.clientip + " " + item.macaddr + " " + item.macaddr.replace(/-/g, ':')).toLocaleLowerCase(); + item.sortField = (item.fixedlocationid === null ? 'a' : 'z') + item.hostname; +} + function makeCombinedField(machineArray) { machineArray.forEach(function (v,i,a){ - machineArray[i].combined = (v.machineuuid + " " + v.hostname + " " + v.clientip + " " + v.macaddr + " " + v.macaddr.replace(/-/g, ':')).toLocaleLowerCase(); + makeCombinedFieldSingle(machineArray[i]); }); return machineArray; } @@ -25,15 +31,14 @@ function renderMachineEntry(item, escape) { // console.log('used uuids is '); // console.log(placedMachines); - var isUsed = $.inArray(item.machineuuid, placedMachines) > -1; var extraClass = ''; var extraText = ''; - if (isUsed) { - extraText = ' (already placed)'; - extraClass = 'used'; - } else if (item.otherroom) { + if (item.otherroom) { extraText = ' (in ' + item.otherroom + ')'; extraClass = 'used'; + } else if (item.fixedlocationid !== null) { + extraText = ' (already placed)'; + extraClass = 'used'; } return '