Просмотр исходного кода

Merge branch 'master' of https://github.com/PDIS/wekan into PDIS-master

Lauri Ojansivu 5 лет назад
Родитель
Сommit
026d8f4941

+ 2 - 0
client/components/sidebar/sidebarArchives.js

@@ -1,3 +1,4 @@
+archivedRequested = false;
 const subManager = new SubsManager();
 
 BlazeComponent.extendComponent({
@@ -12,6 +13,7 @@ BlazeComponent.extendComponent({
       const currentBoardId = Session.get('currentBoard');
       if (!currentBoardId) return;
       const handle = subManager.subscribe('board', currentBoardId, true);
+      archivedRequested = true;
       Tracker.nonreactive(() => {
         Tracker.autorun(() => {
           this.isArchiveReady.set(handle.ready());

+ 16 - 0
client/components/sidebar/sidebarFilters.jade

@@ -56,6 +56,22 @@ template(name="filterSidebar")
           if Filter.customFields.isSelected _id
             i.fa.fa-check
   hr
+  ul.sidebar-list
+    li(class="{{#if Filter.archive.isSelected _id}}active{{/if}}")
+      a.name.js-toggle-archive-filter
+        span.sidebar-list-item-description
+          | {{_ 'filter-show-archive'}}
+        if Filter.archive.isSelected _id
+          i.fa.fa-check
+  hr
+  ul.sidebar-list
+    li(class="{{#if Filter.hideEmpty.isSelected _id}}active{{/if}}")
+      a.name.js-toggle-hideEmpty-filter
+        span.sidebar-list-item-description
+          | {{_ 'filter-hide-empty'}}
+        if Filter.hideEmpty.isSelected _id
+          i.fa.fa-check
+  hr
   span {{_ 'advanced-filter-label'}}
   input.js-field-advanced-filter(type="text")
   span {{_ 'advanced-filter-description'}}

+ 19 - 0
client/components/sidebar/sidebarFilters.js

@@ -1,3 +1,5 @@
+const subManager = new SubsManager();
+
 BlazeComponent.extendComponent({
   events() {
     return [
@@ -12,6 +14,23 @@ BlazeComponent.extendComponent({
           Filter.members.toggle(this.currentData()._id);
           Filter.resetExceptions();
         },
+        'click .js-toggle-archive-filter'(evt) {
+          evt.preventDefault();
+          Filter.archive.toggle(this.currentData()._id);
+          Filter.resetExceptions();
+          const currentBoardId = Session.get('currentBoard');
+          if (!currentBoardId) return;
+          subManager.subscribe(
+            'board',
+            currentBoardId,
+            Filter.archive.isSelected(),
+          );
+        },
+        'click .js-toggle-hideEmpty-filter'(evt) {
+          evt.preventDefault();
+          Filter.hideEmpty.toggle(this.currentData()._id);
+          Filter.resetExceptions();
+        },
         'click .js-toggle-custom-fields-filter'(evt) {
           evt.preventDefault();
           Filter.customFields.toggle(this.currentData()._id);

+ 2 - 1
client/components/swimlanes/swimlanes.jade

@@ -33,7 +33,8 @@ template(name="listsGroup")
             +addListForm
     else
       each lists
-        +list(this)
+        if visible this
+          +list(this)
         if currentCardIsInThisList _id null
           +cardDetails(currentCard)
       if currentUser.isBoardMember

+ 18 - 0
client/components/swimlanes/swimlanes.js

@@ -246,6 +246,24 @@ BlazeComponent.extendComponent({
   currentCardIsInThisList(listId, swimlaneId) {
     return currentCardIsInThisList(listId, swimlaneId);
   },
+  visible(list) {
+    if (list.archived) {
+      // Show archived list only when filter archive is on or archive is selected
+      if (!(Filter.archive.isSelected() || archivedRequested)) {
+        return false;
+      }
+    }
+    if (Filter.hideEmpty.isSelected()) {
+      const swimlaneId = this.parentComponent()
+        .parentComponent()
+        .data()._id;
+      const cards = list.cards(swimlaneId);
+      if (cards.count() === 0) {
+        return false;
+      }
+    }
+    return true;
+  },
   onRendered() {
     const boardComponent = this.parentComponent();
     const $listsDom = this.$('.js-lists');

+ 3 - 1
client/lib/filter.js

@@ -451,10 +451,12 @@ Filter = {
   // before changing the schema.
   labelIds: new SetFilter(),
   members: new SetFilter(),
+  archive: new SetFilter(),
+  hideEmpty: new SetFilter(),
   customFields: new SetFilter('_id'),
   advanced: new AdvancedFilter(),
 
-  _fields: ['labelIds', 'members', 'customFields'],
+  _fields: ['labelIds', 'members', 'archive', 'hideEmpty', 'customFields'],
 
   // We don't filter cards that have been added after the last filter change. To
   // implement this we keep the id of these cards in this `_exceptions` fields

+ 2 - 0
i18n/en.i18n.json

@@ -306,6 +306,8 @@
   "filter-no-label": "No label",
   "filter-no-member": "No member",
   "filter-no-custom-fields": "No Custom Fields",
+  "filter-show-archive": "Show archived lists",
+  "filter-hide-empty": "Hide empty lists",
   "filter-on": "Filter is on",
   "filter-on-desc": "You are filtering cards on this board. Click here to edit filter.",
   "filter-to-selection": "Filter to selection",

+ 1 - 4
models/boards.js

@@ -407,10 +407,7 @@ Boards.helpers({
   },
 
   lists() {
-    return Lists.find(
-      { boardId: this._id, archived: false },
-      { sort: { sort: 1 } },
-    );
+    return Lists.find({ boardId: this._id }, { sort: { sort: 1 } });
   },
 
   nullSortLists() {