2187 - Sort by translated module name
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2c39d8d390
commit
1086e13b2e
|
@ -2,10 +2,11 @@ import ngModule from '../module';
|
||||||
import getMainRoute from '../lib/get-main-route';
|
import getMainRoute from '../lib/get-main-route';
|
||||||
|
|
||||||
export default class Modules {
|
export default class Modules {
|
||||||
constructor(aclService, $window) {
|
constructor(aclService, $window, $translate) {
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
aclService,
|
aclService,
|
||||||
$window
|
$window,
|
||||||
|
$translate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ export default class Modules {
|
||||||
if (this.modules)
|
if (this.modules)
|
||||||
return this.modules;
|
return this.modules;
|
||||||
|
|
||||||
this.modules = [];
|
const modules = [];
|
||||||
for (let mod of this.$window.routes) {
|
for (let mod of this.$window.routes) {
|
||||||
if (!mod || !mod.routes) continue;
|
if (!mod || !mod.routes) continue;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ export default class Modules {
|
||||||
if (res) keyBind = res.key.toUpperCase();
|
if (res) keyBind = res.key.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modules.push({
|
modules.push({
|
||||||
name: mod.name || mod.module,
|
name: mod.name || mod.module,
|
||||||
icon: mod.icon || null,
|
icon: mod.icon || null,
|
||||||
route,
|
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);
|
ngModule.service('vnModules', Modules);
|
||||||
|
|
Loading…
Reference in New Issue