diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2019-01-02 22:32:08 +0100 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2019-01-02 22:32:08 +0100 |
commit | 8ad0da210940c514fc173564955568f023bde3d6 (patch) | |
tree | 0a563112c29c20f2c40ab182fded20dfcdf745b7 | |
parent | 12827ef0a6a36edd4fc2ee4abd93c16ceb0245ee (diff) | |
download | wekan-8ad0da210940c514fc173564955568f023bde3d6.tar.gz wekan-8ad0da210940c514fc173564955568f023bde3d6.tar.bz2 wekan-8ad0da210940c514fc173564955568f023bde3d6.zip |
Added create card action
-rw-r--r-- | client/components/rules/actions/boardActions.jade | 17 | ||||
-rw-r--r-- | client/components/rules/actions/boardActions.js | 25 | ||||
-rw-r--r-- | i18n/en.i18n.json | 3 | ||||
-rw-r--r-- | server/rulesHelper.js | 17 |
4 files changed, 62 insertions, 0 deletions
diff --git a/client/components/rules/actions/boardActions.jade b/client/components/rules/actions/boardActions.jade index ab7d77a8..6034184c 100644 --- a/client/components/rules/actions/boardActions.jade +++ b/client/components/rules/actions/boardActions.jade @@ -47,6 +47,23 @@ template(name="boardActions") div.trigger-button.js-add-swimlane-action.js-goto-rules i.fa.fa-plus + div.trigger-item + div.trigger-content + div.trigger-text + | {{_'r-create-card'}} + div.trigger-dropdown + input(id="card-name",type=text,placeholder="{{_'r-name'}}") + div.trigger-text + | {{_'r-in-list'}} + div.trigger-dropdown + input(id="list-name",type=text,placeholder="{{_'r-name'}}") + div.trigger-text + | {{_'r-in-swimlane'}} + div.trigger-dropdown + input(id="swimlane-name2",type=text,placeholder="{{_'r-name'}}") + div.trigger-button.js-create-card-action.js-goto-rules + i.fa.fa-plus + diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js index 34f7c4b4..c2ac156c 100644 --- a/client/components/rules/actions/boardActions.js +++ b/client/components/rules/actions/boardActions.js @@ -5,6 +5,31 @@ BlazeComponent.extendComponent({ events() { return [{ + 'click .js-create-card-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + const cardName = this.find('#card-name').value; + const listName = this.find('#list-name').value; + const swimlaneName = this.find('#swimlane-name2').value; + const boardId = Session.get('currentBoard'); + const desc = Utils.getTriggerActionDesc(event, this); + const triggerId = Triggers.insert(trigger); + const actionId = Actions.insert({ + actionType: 'createCard', + swimlaneName, + cardName, + listName, + boardId, + desc, + }); + Rules.insert({ + title: ruleName, + triggerId, + actionId, + boardId, + }); + + }, 'click .js-add-swimlane-action' (event) { const ruleName = this.data().ruleName.get(); const trigger = this.data().triggerVar.get(); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index f609d2eb..6aa0335d 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -604,6 +604,9 @@ "r-d-unarchive": "Restore card from Archive", "r-d-add-label": "Add label", "r-d-remove-label": "Remove label", + "r-create-card": "Create new card", + "r-in-list": "in list", + "r-in-swimlane": "in swimlane", "r-d-add-member": "Add member", "r-d-remove-member": "Remove member", "r-d-remove-all-member": "Remove all member", diff --git a/server/rulesHelper.js b/server/rulesHelper.js index e06ed4aa..ef3c9514 100644 --- a/server/rulesHelper.js +++ b/server/rulesHelper.js @@ -145,6 +145,23 @@ RulesHelper = { ChecklistItems.insert({title:itemsArray[i],checklistId:checkListId,cardId:card._id,'sort':0}); } } + if(action.actionType === 'createCard'){ + let list = Lists.findOne({title:action.listName,boardId}); + let listId = ''; + let swimlaneId = ''; + let swimlane = Swimlanes.findOne({title:action.swimlaneName,boardId}); + if(list == undefined){ + listId = ''; + }else{ + listId = list._id; + } + if(swimlane == undefined){ + swimlaneId = Swimlanes.findOne({title:"Default",boardId})._id; + }else{ + swimlaneId = swimlane._id; + } + Cards.insert({title:action.cardName,listId,swimlaneId,sort:0,boardId}); + } }, |