Sfoglia il codice sorgente

Remove links from templates board for the moment
Insert the correct template type in templates board
Allow independant lists in templates board
Add some helpers

Andrés Manelli 6 anni fa
parent
commit
cdf070189e

+ 8 - 7
client/components/lists/listBody.jade

@@ -45,13 +45,14 @@ template(name="addCardForm")
   .add-controls.clearfix
     button.primary.confirm(type="submit") {{_ 'add'}}
     unless isSandstorm
-      span.quiet
-        | {{_ 'or'}}
-        a.js-link {{_ 'link'}}
-      span.quiet
-        |  
-        | /
-        a.js-search {{_ 'search'}}
+      unless currentBoard.isTemplatesBoard
+        span.quiet
+          | {{_ 'or'}}
+          a.js-link {{_ 'link'}}
+        span.quiet
+          |  
+          | /
+          a.js-search {{_ 'search'}}
 
 template(name="autocompleteLabelLine")
   .minicard-label(class="card-label-{{colorName}}" title=labelName)

+ 8 - 3
client/components/lists/listBody.js

@@ -70,7 +70,11 @@ BlazeComponent.extendComponent({
     const boardId = this.data().board();
     let swimlaneId = '';
     const boardView = Meteor.user().profile.boardView;
-    if (boardView === 'board-view-swimlanes')
+    let cardType = 'cardType-card';
+    if (this.data().board().isTemplatesBoard()) {
+      swimlaneId = this.parentComponent().parentComponent().data()._id; // Always swimlanes view
+      cardType = (Swimlanes.findOne(swimlaneId).isCardTemplatesSwimlane())?'template-card':'cardType-card';
+    } else if (boardView === 'board-view-swimlanes')
       swimlaneId = this.parentComponent().parentComponent().data()._id;
     else if ((boardView === 'board-view-lists') || (boardView === 'board-view-cal'))
       swimlaneId = boardId.getDefaultSwimline()._id;
@@ -85,7 +89,7 @@ BlazeComponent.extendComponent({
         boardId: boardId._id,
         sort: sortIndex,
         swimlaneId,
-        type: 'cardType-card',
+        type: cardType,
       });
 
       // if the displayed card count is less than the total cards in the list,
@@ -149,7 +153,8 @@ BlazeComponent.extendComponent({
 
   idOrNull(swimlaneId) {
     const currentUser = Meteor.user();
-    if (currentUser.profile.boardView === 'board-view-swimlanes')
+    if (currentUser.profile.boardView === 'board-view-swimlanes'
+        || this.data().board().isTemplatesBoard())
       return swimlaneId;
     return undefined;
   },

+ 2 - 0
client/components/swimlanes/swimlaneHeader.js

@@ -47,12 +47,14 @@ BlazeComponent.extendComponent({
         const titleInput = this.find('.swimlane-name-input');
         const title = titleInput.value.trim();
         const sortValue = calculateIndexData(this.currentSwimlane, nextSwimlane, 1);
+        const swimlaneType = (currentBoard.isTemplatesBoard())?'template-swimlane':'swimlane';
 
         if (title) {
           Swimlanes.insert({
             title,
             boardId: Session.get('currentBoard'),
             sort: sortValue.base,
+            type: swimlaneType,
           });
 
           titleInput.value = '';

+ 7 - 0
client/components/swimlanes/swimlanes.jade

@@ -10,6 +10,13 @@ template(name="swimlane")
           +miniList(this)
         if currentUser.isBoardMember
           +addListForm
+    else if currentBoard.isTemplatesBoard
+      each lists
+        +list(this)
+        if currentCardIsInThisList _id ../_id
+          +cardDetails(currentCard)
+      if currentUser.isBoardMember
+        +addListForm
     else
       each currentBoard.lists
         +list(this)

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

@@ -153,6 +153,10 @@ BlazeComponent.extendComponent({
 }).register('swimlane');
 
 BlazeComponent.extendComponent({
+  onCreated() {
+    this.currentSwimlane = this.currentData();
+  },
+
   // Proxy
   open() {
     this.childComponents('inlinedForm')[0].open();
@@ -164,11 +168,14 @@ BlazeComponent.extendComponent({
         evt.preventDefault();
         const titleInput = this.find('.list-name-input');
         const title = titleInput.value.trim();
+        const listType = (this.currentSwimlane.isListTemplatesSwimlane())?'template-list':'list';
         if (title) {
           Lists.insert({
             title,
             boardId: Session.get('currentBoard'),
             sort: $('.list').length,
+            type: listType,
+            swimlaneId: this.currentSwimlane._id,
           });
 
           titleInput.value = '';

+ 7 - 0
models/lists.js

@@ -27,6 +27,13 @@ Lists.attachSchema(new SimpleSchema({
      */
     type: String,
   },
+  swimlaneId: {
+    /**
+     * the swimalen associated to this list. Used for templates
+     */
+    type: String,
+    defaultValue: '',
+  },
   createdAt: {
     /**
      * creation date

+ 22 - 0
models/swimlanes.js

@@ -108,6 +108,13 @@ Swimlanes.helpers({
     }), { sort: ['sort'] });
   },
 
+  lists() {
+    return Lists.find(Filter.mongoSelector({
+        swimlaneId: this._id,
+        archived: false,
+    }), { sort: ['sort'] });
+  },
+
   allCards() {
     return Cards.find({ swimlaneId: this._id });
   },
@@ -129,6 +136,21 @@ Swimlanes.helpers({
   isTemplateContainer() {
       return this.type === 'template-container';
   },
+
+  isListTemplatesSwimlane() {
+      const user = Users.findOne(Meteor.userId());
+      return user.profile.listTemplatesSwimlaneId === this._id;
+  },
+
+  isCardTemplatesSwimlane() {
+      const user = Users.findOne(Meteor.userId());
+      return user.profile.cardTemplatesSwimlaneId === this._id;
+  },
+
+  isBoardTemplatesSwimlane() {
+      const user = Users.findOne(Meteor.userId());
+      return user.profile.boardsTemplatesSwimlaneId === this._id;
+  },
 });
 
 Swimlanes.mutations({