Преглед на файлове

HUE-2513 [fb] File list column sorting is broken

Applied smart sorting just to the name column
Set sorting_asc by default on name
Added temp files to .gitignore
Enrico Berti преди 11 години
родител
ревизия
8a95384
променени са 2 файла, в които са добавени 17 реда и са изтрити 6 реда
  1. 3 0
      .gitignore
  2. 14 6
      apps/filebrowser/src/filebrowser/templates/listdir_components.mako

+ 3 - 0
.gitignore

@@ -93,3 +93,6 @@ oozie.sql
 tools/jenkins/ext/
 tools/jenkins/oozie.sql
 apps/logs
+
+# Sublime Text temp files
+*.subl*

+ 14 - 6
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -41,7 +41,7 @@ from django.utils.translation import ugettext as _
       <tr>
         <th width="1%"><div data-bind="click: selectAll, css: {hueCheckbox: true, 'fa': true, 'fa-check': allSelected}" class="select-all"></div></th>
         <th class="sortable sorting" data-sort="type" width="1%" data-bind="click: sort">&nbsp;</th>
-        <th class="sortable sorting" data-sort="name" data-bind="click: sort">${_('Name')}</th>
+        <th class="sortable sorting_asc" data-sort="name" data-bind="click: sort">${_('Name')}</th>
         <th class="sortable sorting" data-sort="size" width="10%" data-bind="click: sort">${_('Size')}</th>
         <th class="sortable sorting" data-sort="user" width="10%" data-bind="click: sort">${_('User')}</th>
         <th class="sortable sorting" data-sort="group" width="10%" data-bind="click: sort">${_('Group')}</th>
@@ -768,7 +768,7 @@ from django.utils.translation import ugettext as _
       self.searchQuery = ko.observable("");
       self.isCurrentDirSentryManaged = ko.observable(false);
 
-      self.filesSorting = function (l, r) {
+      self.fileNameSorting = function (l, r) {
         if (l.name == "..") {
           return -1;
         }
@@ -782,14 +782,21 @@ from django.utils.translation import ugettext as _
           return 1;
         }
         else {
-          return l.name > r.name ? 1 : -1
+          var _ret = l.name > r.name ? 1 : -1;
+          if (self.sortDescending()){
+            _ret = _ret * -1;
+          }
+          return _ret;
         }
       }
 
       self.files = ko.observableArray(ko.utils.arrayMap(files, function (file) {
         return new File(file);
       }));
-      self.files.sort(self.filesSorting)
+
+      if (self.sortBy() == "name"){
+        self.files.sort(self.fileNameSorting);
+      }
 
       self.homeDir = ko.observable("${home_directory}");
 
@@ -819,7 +826,6 @@ from django.utils.translation import ugettext as _
         } else {
           el.addClass("sorting_asc");
         }
-
         self.retrieveData();
       }
 
@@ -901,7 +907,9 @@ from django.utils.translation import ugettext as _
         self.files(ko.utils.arrayMap(files, function (file) {
           return new File(file);
         }));
-        self.files.sort(self.filesSorting)
+        if (self.sortBy() == "name"){
+          self.files.sort(self.fileNameSorting);
+        }
 
         self.breadcrumbs(ko.utils.arrayMap(breadcrumbs, function (breadcrumb) {
           return new Breadcrumb(breadcrumb);