2187 - Sort by translated module name
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-11 12:20:15 +01:00
parent 278839b2b3
commit 14d471fc32
1 changed files with 13 additions and 6 deletions

View File

@ -2,10 +2,11 @@ import ngModule from '../module';
import getMainRoute from '../lib/get-main-route';
export default class Modules {
constructor(aclService, $window) {
constructor(aclService, $window, $translate) {
Object.assign(this, {
aclService,
$window
$window,
$translate
});
}
@ -17,7 +18,7 @@ export default class Modules {
if (this.modules)
return this.modules;
this.modules = [];
const modules = [];
for (let mod of this.$window.routes) {
if (!mod || !mod.routes) continue;
@ -31,7 +32,7 @@ export default class Modules {
if (res) keyBind = res.key.toUpperCase();
}
this.modules.push({
modules.push({
name: mod.name || mod.module,
icon: mod.icon || null,
route,
@ -39,9 +40,15 @@ export default class Modules {
});
}
return this.modules;
const sortedModules = modules.sort((a, b) => {
const translatedNameA = this.$translate.instant(a.name);
const translatedNameB = this.$translate.instant(b.name);
return translatedNameA.localeCompare(translatedNameB);
});
return sortedModules;
}
}
Modules.$inject = ['aclService', '$window'];
Modules.$inject = ['aclService', '$window', '$translate'];
ngModule.service('vnModules', Modules);