summaryrefslogtreecommitdiffstats
path: root/client/components/rules/actions/boardActions.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-09-16 00:10:40 +0300
committerLauri Ojansivu <x@xet7.org>2018-09-16 00:10:40 +0300
commit6673b79738720651f186039808d4e22ef14e4c3c (patch)
tree464eb186f382f14b93c9c9ca7b21a14851746770 /client/components/rules/actions/boardActions.js
parent053757f135b54241b4899a83cd3bb749b1e81bc9 (diff)
parent36c04edb9f7cf16fb450b76598c4957968d4674b (diff)
downloadwekan-6673b79738720651f186039808d4e22ef14e4c3c.tar.gz
wekan-6673b79738720651f186039808d4e22ef14e4c3c.tar.bz2
wekan-6673b79738720651f186039808d4e22ef14e4c3c.zip
Merge branch 'feature-rules' of https://github.com/Angtrim/wekan into Angtrim-feature-rules
Diffstat (limited to 'client/components/rules/actions/boardActions.js')
-rw-r--r--client/components/rules/actions/boardActions.js121
1 files changed, 121 insertions, 0 deletions
diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js
new file mode 100644
index 00000000..3eda039f
--- /dev/null
+++ b/client/components/rules/actions/boardActions.js
@@ -0,0 +1,121 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+
+ },
+
+ events() {
+ return [{
+ 'click .js-add-spec-move-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#move-spec-action').value;
+ const listTitle = this.find('#listName').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+ if (actionSelected == "top") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "moveCardToTop",
+ "listTitle": listTitle,
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ if (actionSelected == "bottom") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "moveCardToBottom",
+ "listTitle": listTitle,
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ },
+ 'click .js-add-gen-move-action' (event) {
+ const desc = Utils.getTriggerActionDesc(event, this);
+ const boardId = Session.get('currentBoard');
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#move-gen-action').value;
+ if (actionSelected == "top") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "moveCardToTop",
+ "listTitle": "*",
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ if (actionSelected == "bottom") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "moveCardToBottom",
+ "listTitle": "*",
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ },
+ 'click .js-add-arch-action' (event) {
+ const desc = Utils.getTriggerActionDesc(event, this);
+ const boardId = Session.get('currentBoard');
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#arch-action').value;
+ if (actionSelected == "archive") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "archive",
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ if (actionSelected == "unarchive") {
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({
+ actionType: "unarchive",
+ "boardId": boardId,
+ "desc": desc
+ });
+ Rules.insert({
+ title: ruleName,
+ triggerId: triggerId,
+ actionId: actionId,
+ "boardId": boardId
+ });
+ }
+ },
+ }];
+ },
+
+}).register('boardActions'); \ No newline at end of file