فهرست منبع

[home2] Initially sort the documents by name

It will put directories on top and the documents below
Johan Ahlen 10 سال پیش
والد
کامیت
64ec0ce
1فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 14 2
      desktop/core/src/desktop/static/desktop/js/fileBrowser/hueFileEntry.js

+ 14 - 2
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueFileEntry.js

@@ -247,7 +247,8 @@
         successCallback: function(data) {
           self.definition(data.directory);
           self.hasErrors(false);
-          self.entries($.map(data.documents, function (definition) {
+
+          var newEntries = $.map(data.documents, function (definition) {
             return new HueFileEntry({
               activeEntry: self.activeEntry,
               assistHelper: self.assistHelper,
@@ -255,7 +256,18 @@
               app: self.app,
               parent: self
             })
-          }));
+          });
+
+          newEntries.sort(function (a, b) {
+            if (a.isDirectory && !b.isDirectory) {
+              return -1;
+            }
+            if (b.isDirectory && !a.isDirectory) {
+              return 1;
+            }
+            return a.name.localeCompare(b.name);
+          });
+          self.entries(newEntries);
           if (! self.parent && data.parent) {
             self.parent = new HueFileEntry({
               activeEntry: self.activeEntry,