From 13897a38644bc4fb0f635eadf8a0cac04d2b231b Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Tue, 7 Dec 2021 21:34:04 -0500 Subject: [PATCH] Reduce redundant code. Reduce redundant code. --- .../html/js/entityProperties.js | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index bb38e10a82..85c7b378da 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -3712,33 +3712,22 @@ function addZoneToZonesSelection(propertyId, id) { hiddenField.value = "[]"; } let selectedZones = JSON.parse(hiddenField.value); - if (!selectedZones.includes(id)) { - selectedZones.push(id); - } - hiddenField.value = JSON.stringify(selectedZones); - displaySelectedZones(propertyId, true); - let propertyName = propertyId.replace("property-", ""); - updateProperty(propertyName, selectedZones, false); - document.getElementById("zones-select-selector-list-panel-" + propertyId).style.display = "none"; -} - -function addAllZonesToZonesSelection (propertyId) { - let hiddenField = document.getElementById(propertyId); - if (JSON.stringify(hiddenField.value) === '"undefined"') { - hiddenField.value = "[]"; - } - let selectedZones = JSON.parse(hiddenField.value); - let i; - for (i = 0; i < zonesList.length; i++) { - if (!selectedZones.includes(zonesList[i].id)) { - selectedZones.push(zonesList[i].id); + if (id === "ALL") { + for (let i = 0; i < zonesList.length; i++) { + if (!selectedZones.includes(zonesList[i].id)) { + selectedZones.push(zonesList[i].id); + } + } + } else { + if (!selectedZones.includes(id)) { + selectedZones.push(id); } } hiddenField.value = JSON.stringify(selectedZones); displaySelectedZones(propertyId, true); let propertyName = propertyId.replace("property-", ""); updateProperty(propertyName, selectedZones, false); - document.getElementById("zones-select-selector-list-panel-" + propertyId).style.display = "none"; + document.getElementById("zones-select-selector-list-panel-" + propertyId).style.display = "none"; } function removeZoneFromZonesSelection(propertyId, zoneId) { @@ -3834,7 +3823,7 @@ function setZonesSelectionData(element, isEditable) { zoneSelector += "