summaryrefslogtreecommitdiffstats
path: root/client/components/rules/actions/checklistActions.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-09-16 03:33:45 +0300
committerLauri Ojansivu <x@xet7.org>2018-09-16 03:33:45 +0300
commitb23cbbf9259ac535129cbf431cefe18fa774dd7f (patch)
tree9e4cccadff9a228f6525fd5722da3a3f290d1ff7 /client/components/rules/actions/checklistActions.js
parent053757f135b54241b4899a83cd3bb749b1e81bc9 (diff)
parent4f299b72f731ffb836871cd19361a6359e3bdfed (diff)
downloadwekan-b23cbbf9259ac535129cbf431cefe18fa774dd7f.tar.gz
wekan-b23cbbf9259ac535129cbf431cefe18fa774dd7f.tar.bz2
wekan-b23cbbf9259ac535129cbf431cefe18fa774dd7f.zip
Merge branch 'Angtrim-feature-rules' into devel
Diffstat (limited to 'client/components/rules/actions/checklistActions.js')
-rw-r--r--client/components/rules/actions/checklistActions.js128
1 files changed, 128 insertions, 0 deletions
diff --git a/client/components/rules/actions/checklistActions.js b/client/components/rules/actions/checklistActions.js
new file mode 100644
index 00000000..4b70f959
--- /dev/null
+++ b/client/components/rules/actions/checklistActions.js
@@ -0,0 +1,128 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+ this.subscribe('allRules');
+ },
+ events() {
+ return [{
+ 'click .js-add-checklist-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#check-action').value;
+ const checklistName = this.find('#checklist-name').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+ if (actionSelected === 'add') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'addChecklist',
+ checklistName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+ if (actionSelected === 'remove') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'removeChecklist',
+ checklistName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+
+ },
+ 'click .js-add-checkall-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#checkall-action').value;
+ const checklistName = this.find('#checklist-name2').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+ if (actionSelected === 'check') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'checkAll',
+ checklistName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+ if (actionSelected === 'uncheck') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'uncheckAll',
+ checklistName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+ },
+ 'click .js-add-check-item-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const checkItemName = this.find('#checkitem-name');
+ const checklistName = this.find('#checklist-name3');
+ const actionSelected = this.find('#check-item-action').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+ if (actionSelected === 'check') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'checkItem',
+ checklistName,
+ checkItemName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+ if (actionSelected === 'uncheck') {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: 'uncheckItem',
+ checklistName,
+ checkItemName,
+ boardId,
+ desc,
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ });
+ }
+ },
+ }];
+ },
+
+}).register('checklistActions');