Skip to content

Commit 242eaeb

Browse files
authored
feat(core): add criteriaInput and optionlist for add a condition (#86)
1 parent 090187c commit 242eaeb

File tree

11 files changed

+61
-4
lines changed

11 files changed

+61
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
212212
this.templateMap?.[InputTypes.Interval] || this.listTemplate,
213213
[InputTypes.Email]:
214214
this.templateMap?.[InputTypes.Email] || this.emailTemplate,
215+
[InputTypes.OptionList]:
216+
this.templateMap?.[InputTypes.OptionList] || this.listTemplate,
215217
};
216218
}
217219

@@ -398,7 +400,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
398400
element,
399401
input,
400402
input.setValue(element.node.state, value),
401-
input.typeFunction(element.node.state) === InputTypes.List,
403+
input.typeFunction(element.node.state) === InputTypes.List || input.typeFunction(element.node.state) === InputTypes.OptionList,
402404
);
403405
this.clearValues();
404406
}

projects/workflows-creator/src/lib/classes/nodes/abstract-prompt.class.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export abstract class WorkflowPrompt {
5454
value: AllowedValues | AllowedValuesMap,
5555
) {
5656
switch (this.typeFunction(state)) {
57+
case InputTypes.OptionList:
5758
case InputTypes.List:
5859
return value;
5960
case InputTypes.People: {
@@ -146,6 +147,7 @@ export abstract class WorkflowPrompt {
146147
*/
147148
getValueName<S extends RecordOfAnyType>(state: State<S>) {
148149
switch (this.typeFunction(state)) {
150+
case InputTypes.OptionList:
149151
case InputTypes.List:
150152
if (typeof state.get(`${this.inputKey}Name`) === 'object') {
151153
return state.get(`${this.inputKey}Name`)?.displayValue;
@@ -184,6 +186,7 @@ export abstract class WorkflowPrompt {
184186
*/
185187
setValueName<S extends RecordOfAnyType>(state: State<S>) {
186188
switch (this.typeFunction(state)) {
189+
case InputTypes.OptionList:
187190
case InputTypes.List:
188191
if (
189192
typeof state.get(this.inputKey) === 'object' &&

projects/workflows-creator/src/lib/enum.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export enum InputTypes {
2020
People = 'people',
2121
Percentage = 'percentage',
2222
Text = 'text',
23+
OptionList = "optionList",
24+
Item = 'Item'
2325
}
2426

2527
/* Defining the types of conditions that can be used in the application. */

projects/workflows-creator/src/lib/services/bpmn/elements/tasks/change-column-value.task.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class ChangeColumnValue extends ServiceTaskElement {
4545
switch (state.get('valueInputType')) {
4646
case InputTypes.People:
4747
return `'${JSON.stringify(state.get('value'))}'`;
48+
case InputTypes.OptionList:
4849
case InputTypes.List:
4950
if (!state.get('value')) return '';
5051
return `'${JSON.stringify({

projects/workflows-creator/src/lib/services/bpmn/elements/tasks/read-column.task.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export class ReadColumnValue extends ServiceTaskElement {
3232
taskIds: {
3333
from: 'taskIds',
3434
},
35+
metaData: {
36+
state: 'metaData',
37+
},
3538
groupColumnId: {
3639
state: 'column',
3740
},

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
337337
}
338338
}`;
339339
}
340+
if (column === InputTypes.Item) {
341+
return `var selectedVals = ${condition};
342+
var selCol = selectedVals.split(',');
343+
for(var key in readObj){
344+
var taskValuePair = readObj[key];
345+
if(taskValuePair && taskValuePair.value && taskValuePair.value.length){
346+
var hasItem = false;
347+
var usCol = taskValuePair.value;
348+
349+
for(var selKey in selCol){
350+
for(var myKey in usCol){
351+
if(usCol[myKey].value == selCol[selKey] && !hasItem){
352+
hasItem = true;
353+
}
354+
}
355+
}
356+
if(${conditionExpression}(hasItem)){
357+
ids.push(taskValuePair.id);
358+
}
359+
}
360+
}`;
361+
}
340362
switch (conditionType) {
341363
case ConditionTypes.PastToday:
342364
return `
@@ -413,6 +435,7 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
413435
case InputTypes.Text:
414436
value = `'${value}'`;
415437
break;
438+
case InputTypes.OptionList:
416439
case InputTypes.List:
417440
value = `'${value.value}'`;
418441
break;

projects/workflows-creator/src/lib/services/statement/events/onvalue.event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {RecordOfAnyType} from '../../../types';
33
import {BpmnEvent} from '../../../types/bpmn.types';
44
import {GatewayElement} from '../../bpmn/elements/gateways/gateway.element';
55
import {ReadColumnValue} from '../../bpmn/elements/tasks/read-column.task';
6-
import {ColumnInput} from '../inputs/column.input';
76
import {ConditionInput} from '../inputs/condition.input';
7+
import { CriteriaInput } from '../inputs/criteria.input';
88
import {ValueInput} from '../inputs/value.input';
99

1010
export class OnValueEvent extends BpmnEvent {
@@ -16,7 +16,7 @@ export class OnValueEvent extends BpmnEvent {
1616
statement = 'check if ';
1717
properties = {};
1818
prompts = [
19-
ColumnInput.identifier,
19+
CriteriaInput.identifier,
2020
ConditionInput.identifier,
2121
ValueInput.identifier,
2222
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {State, WorkflowPrompt} from '../../../classes';
2+
import {InputTypes} from '../../../enum';
3+
import {RecordOfAnyType} from '../../../types';
4+
5+
export class CriteriaInput extends WorkflowPrompt {
6+
prefix = '';
7+
suffix = '';
8+
typeFunction = () => InputTypes.OptionList;
9+
inputKey = 'column';
10+
listNameField = 'text';
11+
listValueField = 'value';
12+
placeholder = 'Criteria';
13+
options = <S extends RecordOfAnyType>(state: State<S>) =>
14+
state.get('columns');
15+
static identifier = 'CriteriaInput';
16+
17+
getIdentifier(): string {
18+
return CriteriaInput.identifier;
19+
}
20+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * from './value.input';
77
export * from './interval.input';
88
export * from './triggercolumn.input';
99
export * from './valuetype.input';
10+
export * from './criteria.input';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import {BpmnNode, RecordOfAnyType} from '../../../types';
1010

1111
export class ValueInput extends WorkflowListPrompt {
12-
prefix: string | {state: string} = '';
12+
prefix: string | {state: string} = {state: 'valuePrefix'};
1313
suffix: string | {state: string} = {state: 'valueSuffix'};
1414
inputKey = 'value';
1515
listNameField = 'text';

0 commit comments

Comments
 (0)