summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-06-21 11:53:20 +0300
committerGitHub <noreply@github.com>2019-06-21 11:53:20 +0300
commit3d3c78260b3bb856f2520316a787913644dc48f2 (patch)
tree499a9308277668b75ac2443883f4edf221583e10
parent02de9164f014e149d3536a7c3cae88beda358318 (diff)
parenta9fc74a9b4b711813d5219ed7ffda8cd20f45fb6 (diff)
downloadwekan-3d3c78260b3bb856f2520316a787913644dc48f2.tar.gz
wekan-3d3c78260b3bb856f2520316a787913644dc48f2.tar.bz2
wekan-3d3c78260b3bb856f2520316a787913644dc48f2.zip
Merge pull request #2506 from road42/feature/rule_card_action_setdate
Adds rule feature: cardAction - SetDate #2504
-rw-r--r--client/components/rules/actions/cardActions.jade41
-rw-r--r--client/components/rules/actions/cardActions.js48
-rw-r--r--i18n/de.i18n.json11
-rw-r--r--i18n/en-GB.i18n.json11
-rw-r--r--i18n/en.i18n.json9
-rw-r--r--server/rulesHelper.js83
6 files changed, 197 insertions, 6 deletions
diff --git a/client/components/rules/actions/cardActions.jade b/client/components/rules/actions/cardActions.jade
index 8c6defc6..c10c4b2b 100644
--- a/client/components/rules/actions/cardActions.jade
+++ b/client/components/rules/actions/cardActions.jade
@@ -2,10 +2,43 @@ template(name="cardActions")
div.trigger-item
div.trigger-content
div.trigger-dropdown
+ select(id="setdate-action")
+ option(value="setDate") {{{_'r-set'}}}
+ option(value="updateDate") {{{_'r-update'}}}
+ div.trigger-text
+ | {{{_'r-datefield'}}}
+ div.trigger-dropdown
+ select(id="setdate-datefield")
+ option(value="startAt") {{{_'r-df-start-at'}}}
+ option(value="dueAt") {{{_'r-df-due-at'}}}
+ option(value="endAt") {{{_'r-df-end-at'}}}
+ option(value="receivedAt") {{{_'r-df-received-at'}}}
+ div.trigger-text
+ | {{{_'r-to-current-datetime'}}}
+ div.trigger-button.js-set-date-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-text
+ | {{{_'r-remove-value-from'}}}
+ | {{{_'r-datefield'}}}
+ div.trigger-dropdown
+ select(id="setdate-removedatefieldvalue")
+ option(value="startAt") {{{_'r-df-start-at'}}}
+ option(value="dueAt") {{{_'r-df-due-at'}}}
+ option(value="endAt") {{{_'r-df-end-at'}}}
+ option(value="receivedAt") {{{_'r-df-received-at'}}}
+ div.trigger-button.js-remove-datevalue-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
select(id="label-action")
option(value="add") {{{_'r-add'}}}
option(value="remove") {{{_'r-remove'}}}
- div.trigger-text
+ div.trigger-text
| {{{_'r-label'}}}
div.trigger-dropdown
select(id="label-id")
@@ -21,16 +54,16 @@ template(name="cardActions")
select(id="member-action")
option(value="add") {{{_'r-add'}}}
option(value="remove") {{{_'r-remove'}}}
- div.trigger-text
+ div.trigger-text
| {{{_'r-member'}}}
div.trigger-dropdown
- input(id="member-name",type=text,placeholder="{{{_'r-name'}}}")
+ input(id="member-name",type=text,placeholder="{{{_'r-name'}}}")
div.trigger-button.js-add-member-action.js-goto-rules
i.fa.fa-plus
div.trigger-item
div.trigger-content
- div.trigger-text
+ div.trigger-text
| {{{_'r-remove-all'}}}
div.trigger-button.js-add-removeall-action.js-goto-rules
i.fa.fa-plus
diff --git a/client/components/rules/actions/cardActions.js b/client/components/rules/actions/cardActions.js
index a1e43c38..d6e11eea 100644
--- a/client/components/rules/actions/cardActions.js
+++ b/client/components/rules/actions/cardActions.js
@@ -29,6 +29,54 @@ BlazeComponent.extendComponent({
events() {
return [{
+ 'click .js-set-date-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const triggerId = Triggers.insert(trigger);
+ const actionSelected = this.find('#setdate-action').value;
+ const dateFieldSelected = this.find('#setdate-datefield').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+
+ const actionId = Actions.insert({
+ actionType: actionSelected,
+ dateField: dateFieldSelected,
+ boardId,
+ desc,
+ });
+
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ desc,
+ });
+ },
+
+ 'click .js-remove-datevalue-action' (event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const triggerId = Triggers.insert(trigger);
+ const dateFieldSelected = this.find('#setdate-removedatefieldvalue').value;
+ const boardId = Session.get('currentBoard');
+ const desc = Utils.getTriggerActionDesc(event, this);
+
+ const actionId = Actions.insert({
+ actionType: 'removeDate',
+ dateField: dateFieldSelected,
+ boardId,
+ desc,
+ });
+
+ Rules.insert({
+ title: ruleName,
+ triggerId,
+ actionId,
+ boardId,
+ desc,
+ });
+ },
'click .js-add-label-action' (event) {
const ruleName = this.data().ruleName.get();
const trigger = this.data().triggerVar.get();
diff --git a/i18n/de.i18n.json b/i18n/de.i18n.json
index 05a4e51f..730a38dc 100644
--- a/i18n/de.i18n.json
+++ b/i18n/de.i18n.json
@@ -669,6 +669,15 @@
"r-board-note": "Hinweis: Lassen Sie ein Feld leer, um alle möglichen Werte zu finden.",
"r-checklist-note": "Hinweis: Die Elemente der Checkliste müssen als kommagetrennte Werte geschrieben werden.",
"r-when-a-card-is-moved": "Wenn eine Karte in eine andere Liste verschoben wird",
+ "r-set": "Setze",
+ "r-update": "Aktualisiere",
+ "r-datefield": "Datumsfeld",
+ "r-df-start-at": "Start",
+ "r-df-due-at": "Fällig",
+ "r-df-end-at": "Ende",
+ "r-df-received-at": "Empfangen",
+ "r-to-current-datetime": "auf das aktuelle Datum/Zeit",
+ "r-remove-value-from": "Entferne Wert von",
"ldap": "LDAP",
"oauth2": "OAuth2",
"cas": "CAS",
@@ -690,4 +699,4 @@
"restore-all": "Alles wiederherstellen",
"delete-all": "Alles löschen",
"loading": "Laden, bitte warten."
-} \ No newline at end of file
+}
diff --git a/i18n/en-GB.i18n.json b/i18n/en-GB.i18n.json
index b883857f..fe1750ef 100644
--- a/i18n/en-GB.i18n.json
+++ b/i18n/en-GB.i18n.json
@@ -669,6 +669,15 @@
"r-board-note": "Note: leave a field empty to match every possible value.",
"r-checklist-note": "Note: checklist's items have to be written as comma separated values.",
"r-when-a-card-is-moved": "When a card is moved to another list",
+ "r-set": "Set",
+ "r-update": "Update",
+ "r-datefield": "date field",
+ "r-df-start-at": "start",
+ "r-df-due-at": "due",
+ "r-df-end-at": "end",
+ "r-df-received-at": "received",
+ "r-to-current-datetime": "to current date/time",
+ "r-remove-value-from": "Remove value from",
"ldap": "LDAP",
"oauth2": "OAuth2",
"cas": "CAS",
@@ -690,4 +699,4 @@
"restore-all": "Restore all",
"delete-all": "Delete all",
"loading": "Loading, please wait."
-} \ No newline at end of file
+}
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index 3f35fca2..2b52da0e 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -672,6 +672,15 @@
"r-checklist-note": "Note: checklist's items have to be written as comma separated values.",
"r-added-to": "added to",
"r-when-a-card-is-moved": "When a card is moved to another list",
+ "r-set": "Set",
+ "r-update": "Update",
+ "r-datefield": "date field",
+ "r-df-start-at": "start",
+ "r-df-due-at": "due",
+ "r-df-end-at": "end",
+ "r-df-received-at": "received",
+ "r-to-current-datetime": "to current date/time",
+ "r-remove-value-from": "Remove value from",
"ldap": "LDAP",
"oauth2": "OAuth2",
"cas": "CAS",
diff --git a/server/rulesHelper.js b/server/rulesHelper.js
index 2188d931..7eb65f1a 100644
--- a/server/rulesHelper.js
+++ b/server/rulesHelper.js
@@ -83,6 +83,89 @@ RulesHelper = {
return;
}
}
+
+ if(action.actionType === 'setDate') {
+ try {
+ const currentDateTime = new Date();
+ switch (action.dateField){
+ case 'startAt': {
+ const resStart = card.getStart();
+ if (typeof resStart === 'undefined') {
+ card.setStart(currentDateTime);
+ }
+ break;
+ }
+ case 'endAt': {
+ const resEnd = card.getEnd();
+ if (typeof resEnd === 'undefined') {
+ card.setEnd(currentDateTime);
+ }
+ break;
+ }
+ case 'dueAt': {
+ const resDue = card.getDue();
+ if (typeof resDue === 'undefined') {
+ card.setDue(currentDateTime);
+ }
+ break;
+ }
+ case 'receivedAt': {
+ const resReceived = card.getReceived();
+ if (typeof resReceived === 'undefined') {
+ card.setReceived(currentDateTime);
+ }
+ break;
+ }
+ }
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error(e);
+ return;
+ }
+ }
+
+ if(action.actionType === 'updateDate'){
+ const currentDateTimeUpdate = new Date();
+ switch (action.dateField){
+ case 'startAt': {
+ card.setStart(currentDateTimeUpdate);
+ break;
+ }
+ case 'endAt': {
+ card.setEnd(currentDateTimeUpdate);
+ break;
+ }
+ case 'dueAt': {
+ card.setDue(currentDateTimeUpdate);
+ break;
+ }
+ case 'receivedAt': {
+ card.setReceived(currentDateTimeUpdate);
+ break;
+ }
+ }
+ }
+
+ if(action.actionType === 'removeDate'){
+ switch (action.dateField){
+ case 'startAt': {
+ card.unsetStart();
+ break;
+ }
+ case 'endAt': {
+ card.unsetEnd();
+ break;
+ }
+ case 'dueAt': {
+ card.unsetDue();
+ break;
+ }
+ case 'receivedAt': {
+ card.unsetReceived();
+ break;
+ }
+ }
+ }
if(action.actionType === 'archive'){
card.archive();
}