Browse Source

HUE-5369 [fb] The trash link shouldn't refresh the page

Enrico Berti 9 years ago
parent
commit
980591f

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/fb_components.mako

@@ -41,7 +41,7 @@ from aws import get_client
         </li>
         % if is_trash_enabled:
         <li class="pull-right">
-          <a href="${url('filebrowser.views.view', path=urlencode(path))}?default_to_trash" class="trashLink" title="${_('View trash')}">
+          <a class="pointer trashLink" data-bind="click: $root.openTrash, attr:{'href': '${url('filebrowser.views.view', path=urlencode(path))}?default_to_trash'}" title="${_('View trash')}">
             <i class="fa fa-trash-o"></i> ${_('Trash')}
           </a>
         </li>

+ 11 - 3
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1220,23 +1220,31 @@ from django.utils.translation import ugettext as _
         self.retrieveData();
       };
 
-      self.openHome = function (vm, e) {
+      self.openDefaultFolder = function (vm, e, folderPath) {
         var isLeftButton = (e.which || e.button) === 1;
         if (isLeftButton) {
           if (! (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
             e.stopPropagation();
             e.preventDefault();
             viewModel.targetPageNum(1);
-            viewModel.targetPath("${url('filebrowser.views.view', path='')}?default_to_home");
+            viewModel.targetPath("${url('filebrowser.views.view', path='')}?" + folderPath);
             location.hash = '';
             viewModel.retrieveData();
           }
           else {
-            window.open("${url('filebrowser.views.view', path='')}?default_to_home");
+            window.open("${url('filebrowser.views.view', path='')}?" + folderPath);
           }
         }
       }
 
+      self.openHome = function (vm, e) {
+        self.openDefaultFolder(vm, e, 'default_to_home');
+      }
+
+      self.openTrash = function (vm, e) {
+        self.openDefaultFolder(vm, e, 'default_to_trash');
+      }
+
       self.viewFile = function (file) {
         if (file.type == "dir") {
           // Reset page number so that we don't hit a page that doesn't exist