Browse Source

[home2] Add sharing status column to the document list

Clicking the icon opens the sharing modal for that entry
Johan Ahlen 9 years ago
parent
commit
8bcc675

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

@@ -50,6 +50,11 @@
 
     self.document = ko.observable();
 
+    self.isShared = ko.pureComputed(function () {
+      var perms = self.definition().perms;
+      return perms && (perms.read.users.length || perms.read.groups.length || perms.write.users.length || perms.write.groups.length);
+    });
+
     self.entriesToDelete = ko.observableArray();
 
     self.selected = ko.observable(false);
@@ -95,8 +100,16 @@
     }
   };
 
-  HueFileEntry.prototype.showSharingModal = function () {
+  HueFileEntry.prototype.showSharingModal = function (entry) {
     var self = this;
+    if (entry) {
+      $.each(self.selectedEntries(), function (idx, otherEntry) {
+        if (otherEntry !== entry) {
+          otherEntry.selected(false);
+        }
+      });
+      entry.selected(true);
+    }
     if (self.selectedEntry()) {
       if (! self.selectedEntry().document()) {
         self.selectedEntry().loadDocument();

+ 15 - 0
desktop/core/src/desktop/templates/file_browser.mako

@@ -172,6 +172,19 @@ from desktop.views import _ko
       vertical-align: middle;
     }
 
+    .fb-share {
+      width: 80px;
+    }
+
+    .fb-share i {
+      font-size: 12px;
+      color: #ddd;
+    }
+
+    .fb-shared-icon-active {
+      color: #338BB8 !important;
+    }
+
     .fb-type {
       width: 140px;
     }
@@ -466,6 +479,7 @@ from desktop.views import _ko
       <div class="fb-header">
         <div class="fb-primary-col">${ _('Name') }</div>
         <div class="fb-attr-group">
+          <div class="fb-attr-col fb-share">${ _('Sharing') }</div>
           <div class="fb-attr-col fb-type">${ _('Type') }</div>
           <div class="fb-attr-col fb-owner">${ _('Owner') }</div>
           <div class="fb-attr-col fb-modified">${ _('Last Modified') }</div>
@@ -503,6 +517,7 @@ from desktop.views import _ko
                 <a href="javascript: void(0);" data-bind="text: name, click: open"></a>
               </div>
               <div class="fb-attr-group">
+                <div class="fb-attr-col fb-share"><i class="fa fa-fw fa-users fb-shared-icon" data-bind="click: function (entry, event) { $parent.showSharingModal($data); event.stopPropagation(); }, css: { 'fb-shared-icon-active': isShared }"></i></div>
                 <!-- ko with: definition -->
                 <div class="fb-attr-col fb-type" data-bind="text: type"></div>
                 <div class="fb-attr-col fb-owner" data-bind="text: owner"></div>