Эх сурвалжийг харах

[home2] Add action to show the trash

This replaces the top delete action and hides the .Trash folder in root
Johan Ahlen 9 жил өмнө
parent
commit
284beaf

+ 37 - 7
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueFileEntry.js

@@ -31,6 +31,7 @@
    * @param {AssistHelper} options.assistHelper
    * @param {AssistHelper} options.assistHelper
    * @param {Object} options.definition
    * @param {Object} options.definition
    * @param {Function} options.activeEntry - The observable keeping track of the current open directory
    * @param {Function} options.activeEntry - The observable keeping track of the current open directory
+   * @param {Function} options.trashEntry - The observable keeping track of the trash directory
    * @param {HueFolder} options.parent
    * @param {HueFolder} options.parent
    * @param {string} options.app - Currently only 'documents' is supported
    * @param {string} options.app - Currently only 'documents' is supported
    *
    *
@@ -39,6 +40,7 @@
   function HueFileEntry (options) {
   function HueFileEntry (options) {
     var self = this;
     var self = this;
     self.activeEntry = options.activeEntry;
     self.activeEntry = options.activeEntry;
+    self.trashEntry = options.trashEntry;
     self.parent = options.parent;
     self.parent = options.parent;
     self.definition = ko.observable(options.definition);
     self.definition = ko.observable(options.definition);
     self.assistHelper = options.assistHelper;
     self.assistHelper = options.assistHelper;
@@ -46,6 +48,10 @@
 
 
     self.document = ko.observable();
     self.document = ko.observable();
 
 
+    self.isTrash = ko.pureComputed(function () {
+      return self.definition().name === '.Trash';
+    })
+
     self.isRoot = ko.pureComputed(function () {
     self.isRoot = ko.pureComputed(function () {
       return self.definition().name === '';
       return self.definition().name === '';
     });
     });
@@ -178,6 +184,7 @@
 
 
     var resultEntry = new HueFileEntry({
     var resultEntry = new HueFileEntry({
       activeEntry: self.activeEntry,
       activeEntry: self.activeEntry,
+      trashEntry: self.trashEntry,
       assistHelper: self.assistHelper,
       assistHelper: self.assistHelper,
       definition: {
       definition: {
         isSearchResult: true,
         isSearchResult: true,
@@ -196,15 +203,23 @@
       query: query,
       query: query,
       successCallback: function (data) {
       successCallback: function (data) {
         resultEntry.hasErrors(false);
         resultEntry.hasErrors(false);
-        resultEntry.entries($.map(data.children, function (definition) {
-          return new HueFileEntry({
+        var newEntries = [];
+
+        $.each(data.children, function (idx, definition) {
+          var entry = new HueFileEntry({
             activeEntry: self.activeEntry,
             activeEntry: self.activeEntry,
+            trashEntry: self.trashEntry,
             assistHelper: self.assistHelper,
             assistHelper: self.assistHelper,
             definition: definition,
             definition: definition,
             app: self.app,
             app: self.app,
             parent: self
             parent: self
-          })
-        }));
+          });
+          if (!entry.isTrash()) {
+            newEntries.push(entry);
+          }
+        });
+
+        resultEntry.entries(entries);
         resultEntry.loading(false);
         resultEntry.loading(false);
         resultEntry.loaded(true);
         resultEntry.loaded(true);
       },
       },
@@ -254,15 +269,22 @@
         successCallback: function(data) {
         successCallback: function(data) {
           self.definition(data.document);
           self.definition(data.document);
           self.hasErrors(false);
           self.hasErrors(false);
+          var newEntries = [];
 
 
-          var newEntries = $.map(data.children, function (definition) {
-            return new HueFileEntry({
+          $.each(data.children, function (idx, definition) {
+            var entry = new HueFileEntry({
               activeEntry: self.activeEntry,
               activeEntry: self.activeEntry,
+              trashEntry: self.trashEntry,
               assistHelper: self.assistHelper,
               assistHelper: self.assistHelper,
               definition: definition,
               definition: definition,
               app: self.app,
               app: self.app,
               parent: self
               parent: self
-            })
+            });
+            if (entry.isTrash()) {
+              self.trashEntry(entry);
+            } else {
+              newEntries.push(entry);
+            }
           });
           });
 
 
           newEntries.sort(function (a, b) {
           newEntries.sort(function (a, b) {
@@ -278,6 +300,7 @@
           if (! self.parent && data.parent) {
           if (! self.parent && data.parent) {
             self.parent = new HueFileEntry({
             self.parent = new HueFileEntry({
               activeEntry: self.activeEntry,
               activeEntry: self.activeEntry,
+              trashEntry: self.trashEntry,
               assistHelper: self.assistHelper,
               assistHelper: self.assistHelper,
               definition: data.parent,
               definition: data.parent,
               app: self.app,
               app: self.app,
@@ -299,6 +322,13 @@
     }
     }
   };
   };
 
 
+  HueFileEntry.prototype.showTrash = function () {
+    var self = this;
+    if (self.trashEntry()) {
+      self.trashEntry().open();
+    }
+  };
+
   HueFileEntry.prototype.showDeleteConfirmation = function () {
   HueFileEntry.prototype.showDeleteConfirmation = function () {
     var self = this;
     var self = this;
     if (self.selectedEntries().length > 0) {
     if (self.selectedEntries().length > 0) {

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/home2.vm.js

@@ -35,8 +35,10 @@
     self.assistHelper.withTotalStorage('assist', 'assist_panel_visible', self.isLeftPanelVisible, true);
     self.assistHelper.withTotalStorage('assist', 'assist_panel_visible', self.isLeftPanelVisible, true);
 
 
     self.activeEntry = ko.observable();
     self.activeEntry = ko.observable();
+    self.trashEntry = ko.observable();
     self.activeEntry(new HueFileEntry({
     self.activeEntry(new HueFileEntry({
       activeEntry: self.activeEntry,
       activeEntry: self.activeEntry,
+      trashEntry: self.trashEntry,
       assistHelper: self.assistHelper,
       assistHelper: self.assistHelper,
       app: 'documents',
       app: 'documents',
       definition: {
       definition: {
@@ -60,6 +62,7 @@
     self.activeEntry(undefined);
     self.activeEntry(undefined);
     var entry = new HueFileEntry({
     var entry = new HueFileEntry({
       activeEntry: self.activeEntry,
       activeEntry: self.activeEntry,
+      trashEntry: self.trashEntry,
       assistHelper: self.assistHelper,
       assistHelper: self.assistHelper,
       app: 'documents',
       app: 'documents',
       definition: {
       definition: {
@@ -91,6 +94,7 @@
     self.activeEntry(undefined);
     self.activeEntry(undefined);
     var lastChild = new HueFileEntry({
     var lastChild = new HueFileEntry({
       activeEntry: self.activeEntry,
       activeEntry: self.activeEntry,
+      trashEntry: self.trashEntry,
       assistHelper: self.assistHelper,
       assistHelper: self.assistHelper,
       app: 'documents',
       app: 'documents',
       definition: {
       definition: {

+ 1 - 0
desktop/core/src/desktop/templates/assist.mako

@@ -900,6 +900,7 @@ from desktop.views import _ko
         self.activeEntry = ko.observable();
         self.activeEntry = ko.observable();
         self.activeEntry(new HueFileEntry({
         self.activeEntry(new HueFileEntry({
           activeEntry: self.activeEntry,
           activeEntry: self.activeEntry,
+          trashEntry: ko.observable,
           assistHelper: options.assistHelper,
           assistHelper: options.assistHelper,
           app: 'documents',
           app: 'documents',
           definition: {
           definition: {

+ 12 - 7
desktop/core/src/desktop/templates/file_browser.mako

@@ -429,11 +429,11 @@ from desktop.views import _ko
               <!-- /ko -->
               <!-- /ko -->
 
 
               <!-- ko foreach: breadcrumbs -->
               <!-- ko foreach: breadcrumbs -->
-              <li><div class="fb-drop-target" data-bind="folderDroppable: { entries: $parent.entries, disableSelect: true }"><a href="javascript:void(0);" data-bind="text: isRoot() ? '${ _('My documents') }' : definition().name, click: open"></a></div></li>
+              <li><div class="fb-drop-target" data-bind="folderDroppable: { entries: $parent.entries, disableSelect: true }"><a href="javascript:void(0);" data-bind="text: isRoot() ? '${ _('My documents') }' : (isTrash() ? '${ _('Trash') }' : definition().name), click: open"></a></div></li>
               <li class="divider">&gt;</li>
               <li class="divider">&gt;</li>
               <!-- /ko -->
               <!-- /ko -->
               <!-- ko ifNot: isRoot -->
               <!-- ko ifNot: isRoot -->
-              <li class="active"><div class="fb-drop-target" data-bind="text: definition().name"></div></li>
+              <li class="active"><div class="fb-drop-target" data-bind="text: isTrash() ? '${ _('Trash') }' : definition().name"></div></li>
               <!-- /ko -->
               <!-- /ko -->
             </ul>
             </ul>
           </div>
           </div>
@@ -469,12 +469,14 @@ from desktop.views import _ko
             </span>
             </span>
           <!-- /ko -->
           <!-- /ko -->
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: function () { $('#createDirectoryModal').modal('show'); }"><span class="fa-stack fa-fw" style="width: 1.28571429em;"><i class="fa fa-folder-o fa-stack-1x" ></i><i class="fa fa-plus-circle fa-stack-1x" style="font-size: 14px; margin-left: 7px; margin-top: 3px;"></i></span></a>
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: function () { $('#createDirectoryModal').modal('show'); }"><span class="fa-stack fa-fw" style="width: 1.28571429em;"><i class="fa fa-folder-o fa-stack-1x" ></i><i class="fa fa-plus-circle fa-stack-1x" style="font-size: 14px; margin-left: 7px; margin-top: 3px;"></i></span></a>
-          <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: showDeleteConfirmation, css: { 'disabled': selectedEntries().length === 0 }"><i class="fa fa-fw fa-times"></i></a>
           <!-- ko if: app === 'documents' -->
           <!-- ko if: app === 'documents' -->
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: function() { showSharingModal(null) }, css: { 'disabled': selectedEntries().length !== 1 }"><i class="fa fa-fw fa-users"></i></a>
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: function() { showSharingModal(null) }, css: { 'disabled': selectedEntries().length !== 1 }"><i class="fa fa-fw fa-users"></i></a>
           <!-- /ko -->
           <!-- /ko -->
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: download"><i class="fa fa-fw fa-download"></i></a>
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: download"><i class="fa fa-fw fa-download"></i></a>
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: showUploadModal"><i class="fa fa-fw fa-upload"></i></a>
           <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: showUploadModal"><i class="fa fa-fw fa-upload"></i></a>
+          <!-- ko if: app === 'documents' -->
+          <a class="inactive-action fb-action" href="javascript:void(0);" data-bind="click: showTrash"><i class="fa fa-fw fa-trash-o"></i></a>
+          <!-- /ko -->
         </div>
         </div>
         <!-- /ko -->
         <!-- /ko -->
       </div>
       </div>
@@ -492,14 +494,17 @@ from desktop.views import _ko
       </div>
       </div>
       <!-- /ko -->
       <!-- /ko -->
 
 
-      <div class="fb-empty animated" style="display:none;" data-bind="visible: entries().length == 0 && ! hasErrors() && ! loading() && ! definition().isSearchResult">
-        ${ _('The current folder is empty. You can add a new file or folder form the top right menu.')}
+      <div class="fb-empty animated" style="display:none;" data-bind="visible: entries().length == 0 && ! hasErrors() && ! loading() && ! definition().isSearchResult && ! isTrash()">
+        ${ _('The current folder is empty, you can add a new file or folder form the top right menu')}
+      </div>
+      <div class="fb-empty animated" style="display:none;" data-bind="visible: entries().length == 0 && ! hasErrors() && ! loading() && ! definition().isSearchResult && isTrash()">
+        ${ _('The trash is empty')}
       </div>
       </div>
       <div class="fb-empty animated" style="display:none;" data-bind="visible: entries().length == 0 && ! hasErrors() && ! loading() && definition().isSearchResult">
       <div class="fb-empty animated" style="display:none;" data-bind="visible: entries().length == 0 && ! hasErrors() && ! loading() && definition().isSearchResult">
-        ${ _('No documents found matching your query.')}
+        ${ _('No documents found matching your query')}
       </div>
       </div>
       <div class="fb-empty animated" style="display: none;" data-bind="visible: hasErrors() && app === 'documents' && ! loading()">
       <div class="fb-empty animated" style="display: none;" data-bind="visible: hasErrors() && app === 'documents' && ! loading()">
-        ${ _('There was an error loading the documents.')}
+        ${ _('There was an error loading the documents')}
       </div>
       </div>
       <div class="fb-empty animated" style="display: none;" data-bind="visible: loading">
       <div class="fb-empty animated" style="display: none;" data-bind="visible: loading">
         <i class="fa fa-spinner fa-spin fa-2x" style="color: #999;"></i>
         <i class="fa fa-spinner fa-spin fa-2x" style="color: #999;"></i>