Skip to content

Commit b8d2878

Browse files
feat(core): add custom date option handling in events (#43)
1 parent 27880b4 commit b8d2878

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

projects/workflows-creator/src/lib/builder/builder.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,12 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
493493
node.node.state.get('condition') === ConditionTypes.PastToday
494494
? true
495495
: !!node.node.state.get('value');
496-
const valueTypeIsAnyValue =
497-
node.node.state.get('valueType') === ValueTypes.AnyValue;
498-
isValid = columnExists && (valueExists || valueTypeIsAnyValue);
496+
const valueTypeIsSufficient = [
497+
ValueTypes.AnyValue,
498+
ValueTypes.Today,
499+
ValueTypes.PastToday,
500+
].includes(node.node.state.get('valueType'));
501+
isValid = columnExists && (valueExists || valueTypeIsSufficient);
499502
break;
500503
case EventTypes.OnIntervalEvent:
501504
const intervalExists = !!node.node.state.get('interval');

projects/workflows-creator/src/lib/services/bpmn/strategies/link/gateway-link.strategy.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,11 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
224224
) {
225225
const column: string = node.workflowNode.state.get('columnName');
226226
const conditionType = node.workflowNode.state.get('condition');
227-
const value = node.workflowNode.state.get('value');
227+
const valueType = node.workflowNode.state.get('valueType');
228+
const valueInputType = node.workflowNode.state.get('valueInputType');
228229

229-
if (!conditionType && value) {
230-
switch (value) {
230+
if (!conditionType && valueType && valueInputType === InputTypes.Date) {
231+
switch (valueType) {
231232
case ValueTypes.PastToday:
232233
return `
233234
for(var key in readObj){
@@ -252,6 +253,22 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
252253
}
253254
}
254255
`;
256+
case ValueTypes.Custom:
257+
return `
258+
for (var key in readObj) {
259+
var taskValuePair = readObj[key];
260+
if (taskValuePair && taskValuePair.value) {
261+
var readDateValue = taskValuePair.value.split('T')[0];
262+
var customDate = "${condition}";
263+
264+
if (${
265+
isElse ? '!' : ''
266+
}(readDateValue === customDate)) {
267+
ids.push(taskValuePair.id);
268+
}
269+
}
270+
}
271+
`;
255272
}
256273
}
257274

@@ -383,6 +400,8 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
383400
break;
384401
case InputTypes.People:
385402
return `'${value.ids}'`;
403+
case InputTypes.Date:
404+
return `${value.split('T')[0]}`;
386405
}
387406
const condition = node.workflowNode.state.get('condition');
388407
const pair = this.conditions.find(item => item.condition === condition);

projects/workflows-creator/src/lib/services/statement/inputs/value.input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class ValueInput extends WorkflowListPrompt {
3232
InputTypes.Number,
3333
InputTypes.People,
3434
InputTypes.Percentage,
35+
InputTypes.Date,
3536
].includes(node.state.get('valueInputType')) &&
3637
node.state.get('valueType') !== ValueTypes.Custom)
3738
);

projects/workflows-creator/src/lib/services/statement/inputs/valuetype.input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ValueTypeInput extends WorkflowListPrompt {
2020
InputTypes.Number,
2121
InputTypes.People,
2222
InputTypes.Percentage,
23+
InputTypes.Date,
2324
].includes(node.state.get('valueInputType'));
2425
};
2526

0 commit comments

Comments
 (0)