add custom apps sorting (fix SideMenu and admin ui)

This commit is contained in:
Simon Vieille
2022-10-21 19:33:43 +02:00
parent 1eb5e18d5c
commit a0c0cc0aa5
5 changed files with 56 additions and 6 deletions
+28 -1
View File
@@ -82,7 +82,34 @@ export default {
},
methods: {
retrieveApps() {
this.apps = loadState('core', 'apps', {})
const ncApps = loadState('core', 'apps', {})
let orders = {}
let finalApps = []
Array.from(window.topMenuAppsOrder).forEach((app, order) => {
orders[app] = order + 1
})
for (let id in ncApps) {
if (window.topMenuApps.includes(id) && !window.topSideMenuApps.includes(id)) {
continue;
}
let app = ncApps[id]
app.order = orders[id] || null
finalApps.push(app)
}
finalApps.sort((a, b) => {
if (a.order === null || b.order === null) {
return a.name < b.name ? -1 : 1;
}
return a.order < b.order ? -1 : 1;
})
this.apps = finalApps
document.querySelector('body').dispatchEvent(new CustomEvent('side-menu.apps', {
detail: {apps: this.apps},