فهرست منبع

Add link card feature to rules

Jochen Sukrow 2 سال پیش
والد
کامیت
6e3f25c771

+ 23 - 0
client/components/rules/actions/boardActions.jade

@@ -77,6 +77,29 @@ template(name="boardActions")
     div.trigger-button.js-create-card-action.js-goto-rules
       i.fa.fa-plus
 
+  div.trigger-item
+    div.trigger-content
+      div.trigger-text
+        | {{_'r-link-card'}}
+      div.trigger-text
+        | {{_'r-the-board'}}
+      div.trigger-dropdown
+        select(id="board-id-link")
+          each boards
+            if $eq _id currentBoard._id
+              option(value="{{_id}}" selected) {{_ 'current'}}
+            else
+              option(value="{{_id}}") {{title}}
+      div.trigger-text
+        | {{_'r-in-list'}}
+      div.trigger-dropdown
+        input(id="listName-link",type=text,placeholder="{{_'r-name'}}")
+      div.trigger-text
+        | {{_'r-in-swimlane'}}
+      div.trigger-dropdown
+        input(id="swimlaneName-link",type=text,placeholder="{{_'r-name'}}")
+    div.trigger-button.js-link-card-action.js-goto-rules
+      i.fa.fa-plus
 
 
 

+ 23 - 0
client/components/rules/actions/boardActions.js

@@ -178,6 +178,29 @@ BlazeComponent.extendComponent({
             });
           }
         },
+        'click .js-link-card-action'(event) {
+          const ruleName = this.data().ruleName.get();
+          const trigger = this.data().triggerVar.get();
+          const swimlaneName = this.find('#swimlaneName-link').value || '*';
+          const listName = this.find('#listName-link').value || '*';
+          const boardId = Session.get('currentBoard');
+          const destBoardId = this.find('#board-id-link').value;
+          const desc = Utils.getTriggerActionDesc(event, this);
+          const triggerId = Triggers.insert(trigger);
+          const actionId = Actions.insert({
+            actionType: 'linkCard',
+            listName,
+            swimlaneName,
+            boardId: destBoardId,
+            desc,
+          });
+          Rules.insert({
+            title: ruleName,
+            triggerId,
+            actionId,
+            boardId,
+          });
+        },
       },
     ];
   },

+ 1 - 0
imports/i18n/data/en.i18n.json

@@ -846,6 +846,7 @@
   "r-df-received-at": "received",
   "r-to-current-datetime": "to current date/time",
   "r-remove-value-from": "Remove value from",
+  "r-link-card": "Link card to",
   "ldap": "LDAP",
   "oauth2": "OAuth2",
   "cas": "CAS",

+ 22 - 1
server/rulesHelper.js

@@ -371,8 +371,29 @@ RulesHelper = {
         listId,
         swimlaneId,
         sort: 0,
-        boardId,
+        boardId
+      });
+    }
+    if (action.actionType === 'linkCard') {
+      const list = Lists.findOne({ title: action.listName, boardId: action.boardId });
+      const card = Cards.findOne({ _id: activity.cardId });
+      let listId = '';
+      let swimlaneId = '';
+      const swimlane = Swimlanes.findOne({
+        title: action.swimlaneName,
+        boardId: action.boardId,
       });
+      if (list === undefined) {
+        listId = '';
+      } else {
+        listId = list._id;
+      }
+      if (swimlane === undefined) {
+        swimlaneId = Swimlanes.findOne({ title: 'Default', boardId: action.boardId })._id;
+      } else {
+        swimlaneId = swimlane._id;
+      }
+      card.link(action.boardId, swimlaneId, listId);
     }
   },
 };