ソースを参照

Save template swimlanes in profile. Fix swimlane view for templates board. Avoid deleting template containers

Andrés Manelli 6 年 前
コミット
64bf455b29

+ 6 - 3
client/components/boards/boardBody.jade

@@ -20,12 +20,15 @@ template(name="boardBody")
       class="{{#if draggingActive.get}}is-dragging-active{{/if}}")
       if showOverlay.get
         .board-overlay
-      if isViewSwimlanes
+      if currentBoard.isTemplatesBoard
         each currentBoard.swimlanes
           +swimlane(this)
-      if isViewLists
+      else if isViewSwimlanes
+        each currentBoard.swimlanes
+          +swimlane(this)
+      else if isViewLists
         +listsGroup
-      if isViewCalendar
+      else if isViewCalendar
         +calendarView
 
 template(name="calendarView")

+ 7 - 5
client/components/boards/boardHeader.jade

@@ -96,10 +96,11 @@ template(name="boardHeaderBar")
         i.fa.fa-search
         span {{_ 'search'}}
 
-      a.board-header-btn.js-toggle-board-view(
-        title="{{_ 'board-view'}}")
-        i.fa.fa-th-large
-        span {{_ currentUser.profile.boardView}}
+      unless currentBoard.isTemplatesBoard
+        a.board-header-btn.js-toggle-board-view(
+          title="{{_ 'board-view'}}")
+          i.fa.fa-th-large
+          span {{_ currentUser.profile.boardView}}
 
       if canModifyBoard
         a.board-header-btn.js-multiselection-activate(
@@ -132,7 +133,8 @@ template(name="boardMenuPopup")
       hr
       ul.pop-over-list
         li: a(href="{{exportUrl}}", download="{{exportFilename}}") {{_ 'export-board'}}
-        li: a.js-archive-board {{_ 'archive-board'}}
+        unless currentBoard.isTemplatesBoard
+          li: a.js-archive-board {{_ 'archive-board'}}
         li: a.js-outgoing-webhooks {{_ 'outgoing-webhooks'}}
       hr
       ul.pop-over-list

+ 2 - 2
client/components/boards/boardsList.js

@@ -8,10 +8,10 @@ Template.boardListHeaderBar.events({
 
 Template.boardListHeaderBar.helpers({
   templatesBoardId() {
-      return Meteor.user().getTemplatesBoard().id;
+      return Meteor.user().getTemplatesBoardId();
   },
   templatesBoardSlug() {
-      return Meteor.user().getTemplatesBoard().slug;
+      return Meteor.user().getTemplatesBoardSlug();
   },
 });
 

+ 4 - 3
client/components/swimlanes/swimlaneHeader.jade

@@ -22,9 +22,10 @@ template(name="swimlaneActionPopup")
   unless currentUser.isCommentOnly
     ul.pop-over-list
        li: a.js-set-swimlane-color {{_ 'select-color'}}
-    hr
-    ul.pop-over-list
-      li: a.js-close-swimlane {{_ 'archive-swimlane'}}
+    unless this.isTemplateContainer
+      hr
+      ul.pop-over-list
+        li: a.js-close-swimlane {{_ 'archive-swimlane'}}
 
 template(name="swimlaneAddPopup")
   unless currentUser.isCommentOnly

+ 2 - 2
client/components/users/userHeader.js

@@ -5,10 +5,10 @@ Template.headerUserBar.events({
 
 Template.memberMenuPopup.helpers({
   templatesBoardId() {
-      return Meteor.user().getTemplatesBoard().id;
+      return Meteor.user().getTemplatesBoardId();
   },
   templatesBoardSlug() {
-      return Meteor.user().getTemplatesBoard().slug;
+      return Meteor.user().getTemplatesBoardSlug();
   },
 });
 

+ 3 - 3
i18n/en.i18n.json

@@ -456,9 +456,9 @@
     "welcome-list1": "Basics",
     "welcome-list2": "Advanced",
     "templates-board": "Templates Board",
-    "card-templates-swimlane": "Card Templates Swimlane",
-    "list-templates-swimlane": "List Templates Swimlane",
-    "board-templates-swimlane": "Board Templates Swimlane",
+    "card-templates-swimlane": "Card Templates",
+    "list-templates-swimlane": "List Templates",
+    "board-templates-swimlane": "Board Templates",
     "what-to-do": "What do you want to do?",
     "wipLimitErrorPopup-title": "Invalid WIP Limit",
     "wipLimitErrorPopup-dialog-pt1": "The number of tasks in this list is higher than the WIP limit you've defined.",

+ 4 - 0
models/boards.js

@@ -569,6 +569,10 @@ Boards.helpers({
   isTemplateBoard() {
     return this.type === 'template-board';
   },
+
+  isTemplatesBoard() {
+    return this.type === 'template-container';
+  },
 });
 
 

+ 4 - 0
models/swimlanes.js

@@ -125,6 +125,10 @@ Swimlanes.helpers({
   isTemplateSwimlane() {
     return this.type === 'template-swimlane';
   },
+
+  isTemplateContainer() {
+      return this.type === 'template-container';
+  },
 });
 
 Swimlanes.mutations({

+ 42 - 8
models/users.js

@@ -166,6 +166,27 @@ Users.attachSchema(new SimpleSchema({
     type: String,
     defaultValue: '',
   },
+  'profile.cardTemplatesSwimlaneId': {
+    /**
+     * Reference to the card templates swimlane Id
+     */
+    type: String,
+    defaultValue: '',
+  },
+  'profile.listTemplatesSwimlaneId': {
+    /**
+     * Reference to the list templates swimlane Id
+     */
+    type: String,
+    defaultValue: '',
+  },
+  'profile.boardTemplatesSwimlaneId': {
+    /**
+     * Reference to the board templates swimlane Id
+     */
+    type: String,
+    defaultValue: '',
+  },
   services: {
     /**
      * services field of the user
@@ -336,11 +357,12 @@ Users.helpers({
     return profile.language || 'en';
   },
 
-  getTemplatesBoard() {
-      return {
-          id: this.profile.templatesBoardId,
-          slug: Boards.findOne(this.profile.templatesBoardId).slug,
-      };
+  getTemplatesBoardId() {
+      return this.profile.templatesBoardId;
+  },
+
+  getTemplatesBoardSlug() {
+      return Boards.findOne(this.profile.templatesBoardId).slug;
   },
 });
 
@@ -731,7 +753,11 @@ if (Meteor.isServer) {
                 boardId,
                 sort: 1,
                 type: 'template-container',
-            }, fakeUser);
+            }, fakeUser, (err, swimlaneId) => {
+
+                // Insert the reference to out card templates swimlane
+                Users.update(fakeUserId.get(), {$set: {'profile.cardTemplatesSwimlaneId': swimlaneId}});
+            });
 
             // Insert the list templates swimlane
             Swimlanes.insert({
@@ -739,7 +765,11 @@ if (Meteor.isServer) {
                 boardId,
                 sort: 2,
                 type: 'template-container',
-            }, fakeUser);
+            }, fakeUser, (err, swimlaneId) => {
+
+                // Insert the reference to out list templates swimlane
+                Users.update(fakeUserId.get(), {$set: {'profile.listTemplatesSwimlaneId': swimlaneId}});
+            });
 
             // Insert the board templates swimlane
             Swimlanes.insert({
@@ -747,7 +777,11 @@ if (Meteor.isServer) {
                 boardId,
                 sort: 3,
                 type: 'template-container',
-            }, fakeUser);
+            }, fakeUser, (err, swimlaneId) => {
+
+                // Insert the reference to out board templates swimlane
+                Users.update(fakeUserId.get(), {$set: {'profile.boardTemplatesSwimlaneId': swimlaneId}});
+            });
         });
       });
     });