summaryrefslogtreecommitdiffstats
path: root/settings/js/apps.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-05-20 13:43:20 +0200
committerVincent Petry <pvince81@owncloud.com>2015-05-20 13:43:20 +0200
commit66e426c9904b7ccb73fbf87a62b55feae6a672e6 (patch)
treea8118d209ccc9a5e206ba403236fe9f4b768a7e0 /settings/js/apps.js
parent3a4568313fdc55b07e9bda0937c3a179f78d1af9 (diff)
downloadnextcloud-server-66e426c9904b7ccb73fbf87a62b55feae6a672e6.tar.gz
nextcloud-server-66e426c9904b7ccb73fbf87a62b55feae6a672e6.zip
Sort apps by level, then by name
Also properly initialize the level to 0 when no level was returned
Diffstat (limited to 'settings/js/apps.js')
-rw-r--r--settings/js/apps.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 58a0a31ccd8..731a107fb14 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -86,17 +86,25 @@ OC.Settings.Apps = OC.Settings.Apps || {
}), {
type:'GET',
success: function (apps) {
- OC.Settings.Apps.State.apps = _.indexBy(apps.apps, 'id');
+ var appList = _.map(_.indexBy(apps.apps, 'id'), function(app) {
+ // default values for missing fields
+ return _.extend({level: 0}, app);
+ });
+ OC.Settings.Apps.State.apps = appList;
var source = $("#app-template").html();
var template = Handlebars.compile(source);
- if (apps.apps.length) {
- apps.apps.sort(function(a,b) {
- return b.level - a.level;
+ if (appList.length) {
+ appList.sort(function(a,b) {
+ var levelDiff = b.level - a.level;
+ if (levelDiff === 0) {
+ return OC.Util.naturalSortCompare(a.name, b.name);
+ }
+ return levelDiff;
});
var firstExperimental = false;
- _.each(apps.apps, function(app) {
+ _.each(appList, function(app) {
if(app.level === 0 && firstExperimental === false) {
firstExperimental = true;
OC.Settings.Apps.renderApp(app, template, null, true);