mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Adds rule feature: cardAction - SetDate #2504
This commit is contained in:
parent
02de9164f0
commit
a9fc74a9b4
6 changed files with 197 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue