Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add criteriaInput and optionlist for add a condition #86

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
this.templateMap?.[InputTypes.Interval] || this.listTemplate,
[InputTypes.Email]:
this.templateMap?.[InputTypes.Email] || this.emailTemplate,
[InputTypes.OptionList]:
this.templateMap?.[InputTypes.OptionList] || this.listTemplate,
};
}

Expand Down Expand Up @@ -398,7 +400,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
element,
input,
input.setValue(element.node.state, value),
input.typeFunction(element.node.state) === InputTypes.List,
input.typeFunction(element.node.state) === InputTypes.List || input.typeFunction(element.node.state) === InputTypes.OptionList,
);
this.clearValues();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export abstract class WorkflowPrompt {
value: AllowedValues | AllowedValuesMap,
) {
switch (this.typeFunction(state)) {
case InputTypes.OptionList:
case InputTypes.List:
return value;
case InputTypes.People: {
Expand Down Expand Up @@ -146,6 +147,7 @@ export abstract class WorkflowPrompt {
*/
getValueName<S extends RecordOfAnyType>(state: State<S>) {
switch (this.typeFunction(state)) {
case InputTypes.OptionList:
case InputTypes.List:
if (typeof state.get(`${this.inputKey}Name`) === 'object') {
return state.get(`${this.inputKey}Name`)?.displayValue;
Expand Down Expand Up @@ -184,6 +186,7 @@ export abstract class WorkflowPrompt {
*/
setValueName<S extends RecordOfAnyType>(state: State<S>) {
switch (this.typeFunction(state)) {
case InputTypes.OptionList:
case InputTypes.List:
if (
typeof state.get(this.inputKey) === 'object' &&
Expand Down
2 changes: 2 additions & 0 deletions projects/workflows-creator/src/lib/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export enum InputTypes {
People = 'people',
Percentage = 'percentage',
Text = 'text',
OptionList = "optionList",
Item = 'Item'
}

/* Defining the types of conditions that can be used in the application. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class ChangeColumnValue extends ServiceTaskElement {
switch (state.get('valueInputType')) {
case InputTypes.People:
return `'${JSON.stringify(state.get('value'))}'`;
case InputTypes.OptionList:
case InputTypes.List:
if (!state.get('value')) return '';
return `'${JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class ReadColumnValue extends ServiceTaskElement {
taskIds: {
from: 'taskIds',
},
metaData: {
state: 'metaData',
},
groupColumnId: {
state: 'column',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
}
}`;
}
if (column === InputTypes.Item) {
return `var selectedVals = ${condition};
var selCol = selectedVals.split(',');
for(var key in readObj){
var taskValuePair = readObj[key];
if(taskValuePair && taskValuePair.value && taskValuePair.value.length){
var hasItem = false;
var usCol = taskValuePair.value;

for(var selKey in selCol){
for(var myKey in usCol){
if(usCol[myKey].value == selCol[selKey] && !hasItem){
hasItem = true;
}
}
}
if(${conditionExpression}(hasItem)){
ids.push(taskValuePair.id);
}
}
}`;
}
switch (conditionType) {
case ConditionTypes.PastToday:
return `
Expand Down Expand Up @@ -413,6 +435,7 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
case InputTypes.Text:
value = `'${value}'`;
break;
case InputTypes.OptionList:
case InputTypes.List:
value = `'${value.value}'`;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {RecordOfAnyType} from '../../../types';
import {BpmnEvent} from '../../../types/bpmn.types';
import {GatewayElement} from '../../bpmn/elements/gateways/gateway.element';
import {ReadColumnValue} from '../../bpmn/elements/tasks/read-column.task';
import {ColumnInput} from '../inputs/column.input';
import {ConditionInput} from '../inputs/condition.input';
import { CriteriaInput } from '../inputs/criteria.input';
import {ValueInput} from '../inputs/value.input';

export class OnValueEvent extends BpmnEvent {
Expand All @@ -16,7 +16,7 @@ export class OnValueEvent extends BpmnEvent {
statement = 'check if ';
properties = {};
prompts = [
ColumnInput.identifier,
CriteriaInput.identifier,
ConditionInput.identifier,
ValueInput.identifier,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {State, WorkflowPrompt} from '../../../classes';
import {InputTypes} from '../../../enum';
import {RecordOfAnyType} from '../../../types';

export class CriteriaInput extends WorkflowPrompt {
prefix = '';
suffix = '';
typeFunction = () => InputTypes.OptionList;
inputKey = 'column';
listNameField = 'text';
listValueField = 'value';
placeholder = 'Criteria';
options = <S extends RecordOfAnyType>(state: State<S>) =>
state.get('columns');
static identifier = 'CriteriaInput';

getIdentifier(): string {
return CriteriaInput.identifier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './value.input';
export * from './interval.input';
export * from './triggercolumn.input';
export * from './valuetype.input';
export * from './criteria.input';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import {BpmnNode, RecordOfAnyType} from '../../../types';

export class ValueInput extends WorkflowListPrompt {
prefix: string | {state: string} = '';
prefix: string | {state: string} = {state: 'valuePrefix'};
suffix: string | {state: string} = {state: 'valueSuffix'};
inputKey = 'value';
listNameField = 'text';
Expand Down
2 changes: 2 additions & 0 deletions projects/workflows-creator/src/lib/workflow-builder.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import {TriggerColumnInput} from './services/statement/inputs/triggercolumn.inpu
import {ValueTypeInput} from './services/statement/inputs/valuetype.input';
import {TooltipRenderComponent} from './builder/tooltip-render/tooltip-render.component';
import {LocalizationPipe} from './pipes/localization.pipe';
import { CriteriaInput } from './services';
@NgModule({
declarations: [
BuilderComponent,
Expand Down Expand Up @@ -143,6 +144,7 @@ import {LocalizationPipe} from './pipes/localization.pipe';
{provide: BPMN_ELEMENTS, useClass: ChangeColumnValue, multi: true},
{provide: BPMN_ELEMENTS, useClass: ProcessPropertiesElement, multi: true},
{provide: BPMN_INPUTS, useClass: ColumnInput, multi: true},
{provide: BPMN_INPUTS, useClass: CriteriaInput, multi: true},
{provide: BPMN_INPUTS, useClass: TriggerColumnInput, multi: true},
{provide: BPMN_INPUTS, useClass: IntervalInput, multi: true},
{provide: BPMN_INPUTS, useClass: ConditionInput, multi: true},
Expand Down
Loading