Merge pull request #743 from bc24fl/develop
Fixed sorting under Folder View in Script Manager
This commit is contained in:
@@ -489,9 +489,24 @@ export default {
|
|||||||
// add Unassigned category
|
// add Unassigned category
|
||||||
categoriesTemp.push("Unassigned");
|
categoriesTemp.push("Unassigned");
|
||||||
|
|
||||||
const sorted = categoriesTemp.sort();
|
const sortedCategories = categoriesTemp.sort();
|
||||||
|
|
||||||
sorted.forEach(category => {
|
// sort by name property
|
||||||
|
const sortedScripts = scriptsTemp.sort(function (a, b) {
|
||||||
|
const nameA = a.name.toUpperCase();
|
||||||
|
const nameB = b.name.toUpperCase();
|
||||||
|
|
||||||
|
if (nameA < nameB) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (nameA > nameB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// names must be equal
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
sortedCategories.forEach(category => {
|
||||||
let temp = {
|
let temp = {
|
||||||
icon: "folder",
|
icon: "folder",
|
||||||
iconColor: "yellow-9",
|
iconColor: "yellow-9",
|
||||||
@@ -500,13 +515,12 @@ export default {
|
|||||||
id: category,
|
id: category,
|
||||||
children: [],
|
children: [],
|
||||||
};
|
};
|
||||||
for (var i = scriptsTemp.length - 1; i >= 0; i--) {
|
|
||||||
if (scriptsTemp[i].category === category) {
|
for (let x = 0; x < sortedScripts.length; x++) {
|
||||||
temp.children.push({ label: scriptsTemp[i].name, header: "script", ...scriptsTemp[i] });
|
if (sortedScripts[x].category === category) {
|
||||||
scriptsTemp.splice(i, 1);
|
temp.children.push({ label: sortedScripts[x].name, header: "script", ...sortedScripts[x] });
|
||||||
} else if (category === "Unassigned" && !scriptsTemp[i].category) {
|
} else if (category === "Unassigned" && !sortedScripts[x].category) {
|
||||||
temp.children.push({ label: scriptsTemp[i].name, header: "script", ...scriptsTemp[i] });
|
temp.children.push({ label: sortedScripts[x].name, header: "script", ...sortedScripts[x] });
|
||||||
scriptsTemp.splice(i, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,4 +647,4 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script> | ||||||