ordering prompts in the menu: first the default prompts, then the custom in alphabetical order by "name"

This commit is contained in:
Mic 2024-05-15 23:18:47 +02:00
parent 1a10382053
commit e9cb2fedeb
2 changed files with 4 additions and 2 deletions

View file

@ -46,7 +46,8 @@ export class mzta_Menus {
this.allPrompts = []; this.allPrompts = [];
this.rootMenu = []; this.rootMenu = [];
this.menu_listeners = {}; this.menu_listeners = {};
this.allPrompts = await getPrompts(true); this.allPrompts = await getPrompts(true);
this.allPrompts.sort((a, b) => a.name.localeCompare(b.name));
this.allPrompts.forEach((prompt) => { this.allPrompts.forEach((prompt) => {
this.addAction(prompt) this.addAction(prompt)
}); });

View file

@ -144,8 +144,9 @@ export async function getPrompts(onlyEnabled = false){
let output = defaultPrompts.concat(customPrompts); let output = defaultPrompts.concat(customPrompts);
if(onlyEnabled){ if(onlyEnabled){
output = output.filter(obj => obj.enabled != 0); output = output.filter(obj => obj.enabled != 0);
} }else{ // order only if we are not filtering, the filtering is for the menus and we are ordering there after i18n
output.sort((a, b) => a.id.localeCompare(b.id)); output.sort((a, b) => a.id.localeCompare(b.id));
}
for(let i=1; i<=output.length; i++){ for(let i=1; i<=output.length; i++){
output[i-1].idnum = i; output[i-1].idnum = i;
} }