Ver código fonte

Try to fix : Filter List by Title - prevent showing only the list title - Hiding empty lists in Swimlane view

Ben0it-T 3 anos atrás
pai
commit
6c83cb5b44

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

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

+ 23 - 4
client/components/swimlanes/swimlanes.js

@@ -137,19 +137,38 @@ BlazeComponent.extendComponent({
     this._isDragging = false;
     this._isDragging = false;
     this._lastDragPositionX = 0;
     this._lastDragPositionX = 0;
   },
   },
-
   id() {
   id() {
     return this._id;
     return this._id;
   },
   },
-
   currentCardIsInThisList(listId, swimlaneId) {
   currentCardIsInThisList(listId, swimlaneId) {
     return currentCardIsInThisList(listId, swimlaneId);
     return currentCardIsInThisList(listId, swimlaneId);
   },
   },
-
   currentListIsInThisSwimlane(swimlaneId) {
   currentListIsInThisSwimlane(swimlaneId) {
     return currentListIsInThisSwimlane(swimlaneId);
     return currentListIsInThisSwimlane(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.lists._isActive()) {
+      if (!list.title.match(Filter.lists.getRegexSelector())) {
+        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;
+  },
   events() {
   events() {
     return [
     return [
       {
       {

+ 17 - 4
client/lib/filter.js

@@ -682,9 +682,11 @@ Filter = {
     const filterSelector = {};
     const filterSelector = {};
     const emptySelector = {};
     const emptySelector = {};
     let includeEmptySelectors = false;
     let includeEmptySelectors = false;
+    let isFilterActive = false; // we don't want there is only Filter.lists
     this._fields.forEach(fieldName => {
     this._fields.forEach(fieldName => {
       const filter = this[fieldName];
       const filter = this[fieldName];
       if (filter._isActive()) {
       if (filter._isActive()) {
+        isFilterActive = true;
         if (filter.subField !== '') {
         if (filter.subField !== '') {
           filterSelector[
           filterSelector[
             `${fieldName}.${filter.subField}`
             `${fieldName}.${filter.subField}`
@@ -715,12 +717,23 @@ Filter = {
     )
     )
       selectors.push(filterSelector);
       selectors.push(filterSelector);
     if (includeEmptySelectors) selectors.push(emptySelector);
     if (includeEmptySelectors) selectors.push(emptySelector);
-    if (this.advanced._isActive())
+    if (this.advanced._isActive()) {
+      isFilterActive = true;
       selectors.push(this.advanced._getMongoSelector());
       selectors.push(this.advanced._getMongoSelector());
+    }
     
     
-    return {
-      $or: selectors,
-    };
+    if(isFilterActive) {
+      return {
+        $or: selectors,
+      };
+    }
+    else {
+      // we don't want there is only Filter.lists
+      // otherwise no card will be displayed ...
+      // selectors = [exceptionsSelector];
+      // will return [{"_id":{"$in":[]}}]
+      return {};
+    }
   },
   },
 
 
   mongoSelector(additionalSelector) {
   mongoSelector(additionalSelector) {