Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
ba583b0
fix(core): fix status column not being selected when priority column …
nileshkumar-sf Apr 25, 2023
b22334b
fix(styles): fix UI discrepency when value width is too large
nileshkumar-sf May 3, 2023
d5beb73
feat(core): add validation and fix icon properties
nileshkumar-sf May 3, 2023
1b517c4
fix(core): incorrect condition for is past today
maninder-pal-singh May 23, 2023
5851aab
feat(core): changes condition script for passed by and coming in clauses
maninder-pal-singh Jun 9, 2023
0500568
fix(core): incorrect addition of read block and gateway when change t…
maninder-pal-singh Jun 15, 2023
422ffd6
fix(core): insert column var at caret position
maninder-pal-singh Jun 30, 2023
315d7a5
feat(core): setting output var in send email service task
maninder-pal-singh Jul 6, 2023
5336a42
fix(core): escape double quotes in email body and subject
maninder-pal-singh Jul 14, 2023
27880b4
fix(core): message and subject getting copied to fresh email popup
maninder-pal-singh Jul 18, 2023
b8d2878
feat(core): add custom date option handling in events (#43)
nileshkumar-sf Feb 8, 2024
090187c
fix(core): camunda update changes and valueType anyValue fix (#85)
abhinavverma-sf Sep 18, 2024
242eaeb
feat(core): add criteriaInput and optionlist for add a condition (#86)
VipulSha99 Nov 21, 2024
2a7d458
feat(core): add timeinterval for the interval trigger in workflow (#88)
VipulSha99 Jan 7, 2025
d0a1cdb
feat(core): allow email to get edited without removing sequence selec…
VipulSha99 Mar 24, 2025
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 @@ -11,7 +11,7 @@
(add)="openPopup(types.GROUP)"
(remove)="onGroupRemove(i)"
(eventAdded)="onEventAdded($event)"
(eventRemoved)="onEventRemoved()"
(nodeRemoved)="onNodeRemoved()"
(actionAdded)="onActionAdded($event)"
(itemChanged)="onItemChanged($event)"
></workflow-group>
Expand All @@ -29,6 +29,7 @@
[templateMap]="templateMap"
[allColumns]="allColumns"
(eventAdded)="onEventAdded($event)"
(nodeRemoved)="onNodeRemoved()"
(actionAdded)="onActionAdded($event)"
(itemChanged)="onItemChanged($event)"
></workflow-group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
}
.container {
min-width: 46%;
min-width: 52%;
max-width: max-content;
color: rgb(50, 51, 56);
margin: auto;
Expand Down
139 changes: 115 additions & 24 deletions projects/workflows-creator/src/lib/builder/builder.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ import {
} from '../classes';
import {AbstractBaseGroup} from '../classes/nodes';
import {BuilderService, ElementService, NodeService} from '../classes/services';
import {EventTypes, LocalizedStringKeys, NodeTypes, ValueTypes} from '../enum';
import {
ActionTypes,
ConditionTypes,
EventTypes,
LocalizedStringKeys,
NUMBER,
NodeTypes,
NotificationRecipientTypesEnum,
ValueTypes,
} from '../enum';
import {InvalidEntityError} from '../errors/base.error';
import {
ActionAddition,
Expand All @@ -38,6 +47,11 @@ import {
WorkflowNode,
} from '../types';
import {LocalizationProviderService} from '../services/localization-provider.service';
import {
ReadColumnValue,
TriggerWhenColumnChanges,
} from '../services/bpmn/elements/tasks';
import {GatewayElement} from '../services/bpmn/elements/gateways';

@Component({
selector: 'workflow-builder',
Expand Down Expand Up @@ -78,7 +92,7 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
stateChange = new EventEmitter<StateMap<RecordOfAnyType>>();

@Output()
diagramChange = new EventEmitter<string>();
diagramChange = new EventEmitter<Object>();

@Output()
eventAdded = new EventEmitter<EventAddition<E>>();
Expand Down Expand Up @@ -217,7 +231,7 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
this.updateDiagram();
this.updateState(event.node, event.newNode.inputs);
this.elseBlockHidden =
!this.eventGroups[0]?.children?.length &&
this.eventGroups[0]?.children?.length === 1 &&
(event.node.getIdentifier() === EventTypes.OnIntervalEvent ||
event.node.getIdentifier() === EventTypes.OnAddItemEvent);
}
Expand All @@ -226,16 +240,9 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
* The function is called when an event is removed from the workflow.
* Hides the else block when it is not needed.
*/
onEventRemoved() {
const events = this.eventGroups[0].children;

this.elseBlockHidden =
events.length === 1 &&
(events[0].node.getIdentifier() === EventTypes.OnIntervalEvent ||
events[0].node.getIdentifier() === EventTypes.OnAddItemEvent ||
(events[0].node.getIdentifier() === EventTypes.OnChangeEvent &&
(events[0].node.state.get('value') === ValueTypes.AnyValue ||
events[0].node.state.get('valueType') === ValueTypes.AnyValue)));
onNodeRemoved() {
this.updateDiagram();
if (this.eventGroups[0]?.children?.length) this.hideElseBlockIfRequired();
}

/**
Expand Down Expand Up @@ -264,19 +271,32 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
item: item.element.node,
});
this.updateState(item.element.node, item.element.inputs);
// TODO: to be refactored
// to hide else block when anything is selected in ValueInput or ValueTypeInput
this.elseBlockHidden =
this.eventGroups[0].children?.length === 1 &&
this.eventGroups[0].children[0].node.getIdentifier() ===
EventTypes.OnChangeEvent &&
(this.eventGroups[0].children[0].node.state.get('value') ===
ValueTypes.AnyValue ||
this.eventGroups[0].children[0].node.state.get('valueType') ===
ValueTypes.AnyValue);
this.hideElseBlockIfRequired();
this.updateDiagram();
}

/**
* This function checks if the else block should be hidden based on the type and number of events in
* the event group.
*/
hideElseBlockIfRequired() {
const events = this.eventGroups[0].children;
let value = events[0].node.state.get('value');
if (typeof value === 'object') {
value = value.value;
}
if (events.length !== 1) {
this.elseBlockHidden = false;
} else {
this.elseBlockHidden =
events[0].node.getIdentifier() === EventTypes.OnIntervalEvent ||
events[0].node.getIdentifier() === EventTypes.OnAddItemEvent ||
(events[0].node.getIdentifier() === EventTypes.OnChangeEvent &&
(value === ValueTypes.AnyValue ||
events[0].node.state.get('valueType') === ValueTypes.AnyValue));
}
}

/**
* "If the type is a group, then get the groups, otherwise throw an error."
*
Expand Down Expand Up @@ -346,6 +366,30 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
value: AllowedValues | AllowedValuesMap,
select = false,
) {
if (
(input.getIdentifier() === 'ValueTypeInput' ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should ideally not have any reference to input type here in this component

input.getIdentifier() === 'ValueInput') &&
element.node.getIdentifier() === 'OnChangeEvent'
) {
if (
((value as AllowedValuesMap)?.value as AllowedValuesMap)?.value ===
ValueTypes.AnyValue
) {
/**
* Remove node on changes event
*/
element.node.elements.splice(-NUMBER.TWO, NUMBER.TWO);
// element.inputs[1].prefix = '';
//this.enableActionIcon = false;
} else {
element.node.elements = [
TriggerWhenColumnChanges.identifier,
ReadColumnValue.identifier,
GatewayElement.identifier,
];
}
}

if (select && isSelectInput(input)) {
element.node.state.change(
`${input.inputKey}Name`,
Expand Down Expand Up @@ -429,8 +473,55 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
* It builds a new diagram, emits the new diagram, and then tells Angular to update the view
*/
async updateDiagram() {
const nodes = [
...this.eventGroups[0].children,
...this.actionGroups[0].children,
...this.elseActionGroups[0].children,
];
let isValid =
!!this.eventGroups[0].children.length &&
(!!this.actionGroups[0].children.length ||
!!this.elseActionGroups[0].children.length);
if (isValid) {
for (const node of nodes) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for validation, we can use a separate service that gets the current state of diagram and just returns true or false and use that here, and this should be based on the default inputs provided. Anyone using the library should be able to replace it to write there own logic according to there own custom events/actions/inputs

switch (node.node.getIdentifier()) {
case EventTypes.OnChangeEvent:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned, the builder component should not have any code specific to event types

case EventTypes.OnValueEvent:
case ActionTypes.ChangeColumnValueAction:
const columnExists = !!node.node.state.get('column');
const valueExists =
node.node.state.get('condition') === ConditionTypes.PastToday
? true
: !!node.node.state.get('value');
const valueTypeIsAnyValue =
node.node.state.get('valueType') === ValueTypes.AnyValue;
isValid = columnExists && (valueExists || valueTypeIsAnyValue);
break;
case EventTypes.OnIntervalEvent:
const intervalExists = !!node.node.state.get('interval');
const intervalValueExists = !!node.node.state.get('value');
isValid = intervalValueExists && intervalExists;
break;
case ActionTypes.SendEmailAction:
const email = !!node.node.state.get('email');
const emailTo = !!node.node.state.get('emailTo');
const specificRecipientsRequired = [
NotificationRecipientTypesEnum.NotifySpecificColumn,
NotificationRecipientTypesEnum.NotifySpecificPeople,
].includes(node.node.state.get('emailTo'));
const recipients = !!node.node.state.get('specificRecepient');
isValid = specificRecipientsRequired
? email && emailTo && recipients
: email && emailTo;
break;
}
if (!isValid) {
break; // exit the loop since we found an invalid input
}
}
}
this.diagram = await this.build();
this.diagramChange.emit(this.diagram);
this.diagramChange.emit({diagram: this.diagram, isValid: isValid});
this.cdr.detectChanges();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
emailInput: emailInput,
appendEmailBody: appendEmailBody,
setFocusKey: setFocusKey,
hide: hidePopper()
hide: hidePopper(),
setFocusOutPos: setFocusOutPos
}
"
></ng-container>
Expand Down Expand Up @@ -284,6 +285,7 @@
let-appendEmailBody="appendEmailBody"
let-setFocusKey="setFocusKey"
let-hide="hide"
let-setFocusOutPos="setFocusOutPos"
>
<div class="email-template" (document:click)="hide()">
<input
Expand All @@ -292,14 +294,15 @@
id="email-subject"
autofocus
(focus)="setFocusKey(emailInput, 'subject')"
(focusout)="setFocusOutPos(emailInput, $event.target.selectionStart)"
[placeholder]="typeSubjectPlaceholder"
[(ngModel)]="emailInput.subject"
/>
<textarea
[placeholder]="typeEmailPlaceholder"
id="email-body"
class="email-input email-body-input"
(focus)="setFocusKey(emailInput, 'body')"
(focusout)="setFocusOutPos(emailInput, $event.target.selectionStart)"
[(ngModel)]="emailInput.body"
></textarea>
<div class="auto-populate">
Expand All @@ -315,7 +318,7 @@
(click)="callback(emailInput)"
[disabled]="!emailInput.subject || !emailInput.body"
>
{{ localizedStringKeys.SetLbl | localization }}
{{ setLbl }}
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
.value-text {
display: inline-block;
overflow: hidden;
max-width: 45%;
max-width: 15rem;
text-decoration: inherit;
text-overflow: ellipsis;
vertical-align: top;
Expand Down
Loading