Selaa lähdekoodia

Temporarily revert collapse per user that did not work yet.

Thanks to xet7 !

Related #5388
Lauri Ojansivu 1 vuosi sitten
vanhempi
sitoutus
4156b6f932

+ 7 - 7
client/components/lists/listHeader.jade

@@ -6,15 +6,15 @@ template(name="listHeader")
       +editListTitleForm
       +editListTitleForm
     else
     else
       unless isMiniScreen
       unless isMiniScreen
-        if listCollapsed
-          a.js-collapse-list(title="{{_ 'uncollapse'}}")
+        if collapsed
+          a.js-collapse(title="{{_ 'uncollapse'}}")
             i.fa.fa-arrow-left.list-header-uncollapse-left
             i.fa.fa-arrow-left.list-header-uncollapse-left
             i.fa.fa-arrow-right.list-header-uncollapse-right
             i.fa.fa-arrow-right.list-header-uncollapse-right
       if isMiniScreen
       if isMiniScreen
         if currentList
         if currentList
           a.list-header-left-icon.fa.fa-angle-left.js-unselect-list
           a.list-header-left-icon.fa.fa-angle-left.js-unselect-list
       unless isMiniScreen
       unless isMiniScreen
-        if listCollapsed
+        if collapsed
           if showCardsCountForList cards.length
           if showCardsCountForList cards.length
             br
             br
             span.cardCount {{cardsCount}}
             span.cardCount {{cardsCount}}
@@ -29,7 +29,7 @@ template(name="listHeader")
            span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}}
            span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}}
            |/#{wipLimit.value})
            |/#{wipLimit.value})
       unless isMiniScreen
       unless isMiniScreen
-        div(class="{{#if listCollapsed}}list-rotated{{/if}}")
+        div(class="{{#if collapsed}}list-rotated{{/if}}")
           h2.list-header-name(
           h2.list-header-name(
             title="{{ moment modifiedAt 'LLL' }}"
             title="{{ moment modifiedAt 'LLL' }}"
             class="{{#if currentUser.isBoardMember}}{{#unless currentUser.isCommentOnly}}{{#unless currentUser.isWorker}}js-open-inlined-form is-editable{{/unless}}{{/unless}}{{/if}}")
             class="{{#if currentUser.isBoardMember}}{{#unless currentUser.isCommentOnly}}{{#unless currentUser.isWorker}}js-open-inlined-form is-editable{{/unless}}{{/unless}}{{/if}}")
@@ -39,7 +39,7 @@ template(name="listHeader")
              | (
              | (
              span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}}
              span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}}
              |/#{wipLimit.value})
              |/#{wipLimit.value})
-        unless listCollapsed
+        unless collapsed
           if showCardsCountForList cards.length
           if showCardsCountForList cards.length
             span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.length}}
             span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.length}}
       if isMiniScreen
       if isMiniScreen
@@ -57,14 +57,14 @@ template(name="listHeader")
       else if currentUser.isBoardMember
       else if currentUser.isBoardMember
         if isWatching
         if isWatching
           i.list-header-watch-icon.fa.fa-eye
           i.list-header-watch-icon.fa.fa-eye
-        unless listCollapsed
+        unless collapsed
           div.list-header-menu
           div.list-header-menu
             unless currentUser.isCommentOnly
             unless currentUser.isCommentOnly
               //if isBoardAdmin
               //if isBoardAdmin
               //  a.fa.js-list-star.list-header-plus-top(class="fa-star{{#unless starred}}-o{{/unless}}")
               //  a.fa.js-list-star.list-header-plus-top(class="fa-star{{#unless starred}}-o{{/unless}}")
               if canSeeAddCard
               if canSeeAddCard
                 a.js-add-card.fa.fa-plus.list-header-plus-top(title="{{_ 'add-card-to-top-of-list'}}")
                 a.js-add-card.fa.fa-plus.list-header-plus-top(title="{{_ 'add-card-to-top-of-list'}}")
-                a.js-collapse-list(title="{{_ 'collapse'}}")
+                a.js-collapse(title="{{_ 'collapse'}}")
                   i.fa.fa-arrow-right.list-header-collapse-right
                   i.fa.fa-arrow-right.list-header-collapse-right
                   i.fa.fa-arrow-left.list-header-collapse-left
                   i.fa.fa-arrow-left.list-header-collapse-left
                 a.fa.fa-navicon.js-open-list-menu(title="{{_ 'listActionPopup-title'}}")
                 a.fa.fa-navicon.js-open-list-menu(title="{{_ 'listActionPopup-title'}}")

+ 6 - 10
client/components/lists/listHeader.js

@@ -31,18 +31,14 @@ BlazeComponent.extendComponent({
       return !status;
       return !status;
     }
     }
   },
   },
-  listCollapsed(check = undefined) {
-    const list = this.currentData()._id;
-    console.log(list);
-    const status = Meteor.call('hasCollapsedList', list);
-    console.log(status);
+  collapsed(check = undefined) {
+    const list = Template.currentData();
+    const status = list.isCollapsed();
     if (check === undefined) {
     if (check === undefined) {
       // just check
       // just check
       return status;
       return status;
     } else {
     } else {
-      console.log('toggleCollapseList');
-      //user.toggleCollapseList(this._id);
-      Meteor.call('toggleCollapseList', list);
+      list.collapse(!status);
       return !status;
       return !status;
     }
     }
   },
   },
@@ -119,9 +115,9 @@ BlazeComponent.extendComponent({
           event.preventDefault();
           event.preventDefault();
           this.starred(!this.starred());
           this.starred(!this.starred());
         },
         },
-        'click .js-collapse-list'(event) {
+        'click .js-collapse'(event) {
           event.preventDefault();
           event.preventDefault();
-          this.listCollapsed(!this.listCollapsed());
+          this.collapsed(!this.collapsed());
         },
         },
         'click .js-open-list-menu': Popup.open('listAction'),
         'click .js-open-list-menu': Popup.open('listAction'),
         'click .js-add-card.list-header-plus-top'(event) {
         'click .js-add-card.list-header-plus-top'(event) {

+ 14 - 0
models/lists.js

@@ -156,6 +156,13 @@ Lists.attachSchema(
       type: String,
       type: String,
       defaultValue: 'list',
       defaultValue: 'list',
     },
     },
+    collapsed: {
+      /**
+       * is the list collapsed
+       */
+      type: Boolean,
+      defaultValue: false,
+    },
   }),
   }),
 );
 );
 
 
@@ -286,6 +293,10 @@ Lists.helpers({
     return this.starred === true;
     return this.starred === true;
   },
   },
 
 
+  isCollapsed() {
+    return this.collapsed === true;
+  },
+
   absoluteUrl() {
   absoluteUrl() {
     const card = ReactiveCache.getCard({ listId: this._id });
     const card = ReactiveCache.getCard({ listId: this._id });
     return card && card.absoluteUrl();
     return card && card.absoluteUrl();
@@ -306,6 +317,9 @@ Lists.mutations({
   star(enable = true) {
   star(enable = true) {
     return { $set: { starred: !!enable } };
     return { $set: { starred: !!enable } };
   },
   },
+  collapse(enable = true) {
+    return { $set: { collapsed: !!enable } };
+  },
 
 
   archive() {
   archive() {
     if (this.isTemplateList()) {
     if (this.isTemplateList()) {

+ 15 - 0
models/swimlanes.js

@@ -107,6 +107,13 @@ Swimlanes.attachSchema(
       type: String,
       type: String,
       defaultValue: 'swimlane',
       defaultValue: 'swimlane',
     },
     },
+    collapsed: {
+      /**
+       * is the swimlane collapsed
+       */
+      type: Boolean,
+      defaultValue: false,
+    },
   }),
   }),
 );
 );
 
 
@@ -232,6 +239,10 @@ Swimlanes.helpers({
     return ret;
     return ret;
   },
   },
 
 
+  isCollapsed() {
+    return this.collapsed === true;
+  },
+
   board() {
   board() {
     return ReactiveCache.getBoard(this.boardId);
     return ReactiveCache.getBoard(this.boardId);
   },
   },
@@ -274,6 +285,10 @@ Swimlanes.mutations({
     return { $set: { title } };
     return { $set: { title } };
   },
   },
 
 
+  collapse(enable = true) {
+    return { $set: { collapsed: !!enable } };
+  },
+
   archive() {
   archive() {
     if (this.isTemplateSwimlane()) {
     if (this.isTemplateSwimlane()) {
       this.myLists().forEach(list => {
       this.myLists().forEach(list => {

+ 0 - 69
models/users.js

@@ -440,20 +440,6 @@ Users.attachSchema(
       defaultValue: {},
       defaultValue: {},
       blackbox: true,
       blackbox: true,
     },
     },
-    'profile.listCollapsed': {
-      /**
-       * User-specific list of collapsed list IDs
-       */
-      type: [String],
-      optional: true,
-    },
-    'profile.swimlaneCollapsed': {
-      /**
-       * User-specific list of collapsed swimlane IDs
-       */
-      type: [String],
-      optional: true,
-    },
     services: {
     services: {
       /**
       /**
        * services field of the user
        * services field of the user
@@ -750,36 +736,6 @@ Users.helpers({
     return _.contains(starredBoards, boardId);
     return _.contains(starredBoards, boardId);
   },
   },
 
 
-  collapsedLists() {
-    const { collapsedLists = [] } = this.profile || {};
-    return Lists.userLists(
-      this._id,
-      false,
-      { _id: { $in: collapsedLists } },
-      { sort: { sort: 1 } },
-    );
-  },
-
-  hasCollapsedList(listId) {
-    const { collapsedLists = [] } = this.profile || {};
-    return _.contains(collapsedLists, listId);
-  },
-
-  collapsedSwimlanes() {
-    const { collapsedSwimlanes = [] } = this.profile || {};
-    return Swimlanes.userSwimlanes(
-      this._id,
-      false,
-      { _id: { $in: collapsedSwimlanes } },
-      { sort: { sort: 1 } },
-    );
-  },
-
-  hasCollapsedSwimlane(swimlaneId) {
-    const { collapsedSwimlanes = [] } = this.profile || {};
-    return _.contains(collapsedSwimlanes, swimlaneId);
-  },
-
   invitedBoards() {
   invitedBoards() {
     const { invitedBoards = [] } = this.profile || {};
     const { invitedBoards = [] } = this.profile || {};
     return Boards.userBoards(
     return Boards.userBoards(
@@ -1048,22 +1004,6 @@ Users.mutations({
       },
       },
     };
     };
   },
   },
-  toggleCollapseList(listId) {
-    const queryKind = this.hasCollapsedList(listId) ? '$pull' : '$addToSet';
-    return {
-      [queryKind]: {
-        'profile.listCollapsed': listId,
-      },
-    };
-  },
-  toggleCollapseSwimlane(swimlaneId) {
-    const queryKind = this.hasCollapsedSwimlane(swimlaneId) ? '$pull' : '$addToSet';
-    return {
-      [queryKind]: {
-        'profile.swimlaneCollapsed': swimlaneId,
-      },
-    };
-  },
 
 
   addInvite(boardId) {
   addInvite(boardId) {
     return {
     return {
@@ -1282,15 +1222,6 @@ Meteor.methods({
     const user = ReactiveCache.getCurrentUser();
     const user = ReactiveCache.getCurrentUser();
     user.toggleHideCheckedItems();
     user.toggleHideCheckedItems();
   },
   },
-  toggleCollapseList(listId) {
-    check(listId, String);
-    const user = ReactiveCache.getCurrentUser();
-    user.toggleCollapseList(listId);
-  },
-  toggleCollapseSwimlane(swimlaneId) {
-    const user = ReactiveCache.getCurrentUser();
-    user.toggleCollapseSwimlane(swimlaneId);
-  },
   toggleSystemMessages() {
   toggleSystemMessages() {
     const user = ReactiveCache.getCurrentUser();
     const user = ReactiveCache.getCurrentUser();
     user.toggleSystem(user.hasHiddenSystemMessages());
     user.toggleSystem(user.hasHiddenSystemMessages());