Skip to content

Commit

Permalink
fix(core): fix the invalid date issue when no time is selected for da…
Browse files Browse the repository at this point in the history
…te/time column (#50)
  • Loading branch information
arpit1503khanna authored Feb 15, 2024
1 parent ca0aff0 commit 100eb56
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
const {events, actions, elseActions, groups, process, state} =
await this.builder.restore(this.diagram);
this.processId = process.id;
this.selectedActions = actions;
this.selectedActions = actions;
this.selectedEvents = events;
this.selectedElseActions = elseActions;
if (this.selectedActions.length) this.actionGroups = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
(click)="
onNodeAdd(node, group.getIdentifier(), group.id);
nodePopup.hide();
$event.stopPropagation();
$event.stopPropagation()
;$event.stopPropagation()"
"
*ngFor="let node of nodeList"
>
{{ node.name }}
Expand Down Expand Up @@ -235,7 +236,7 @@
[closeOnSelect]="false"
(blur)="
callback(
getLibraryValue($event, inputType.People, {
getLibraryValue(nodeWithInput.node, $event, inputType.People, {
list: list,
key: 'value'
})
Expand Down Expand Up @@ -266,7 +267,9 @@
<input
type="date"
[(ngModel)]="date"
(input)="callback(getLibraryValue($event, inputType.Date))"
(input)="
callback(getLibraryValue(nodeWithInput.node, $event, inputType.Date))
"
(click)="$event.stopPropagation()"
(document:click)="hide()"
/>
Expand All @@ -292,10 +295,14 @@
class="close-btn"
(click)="
callback(
getLibraryValue({target: {value: dateTime}}, inputType.DateTime)
getLibraryValue(
nodeWithInput.node,
{target: {value: dateTime}},
inputType.DateTime
)
)
"
[disabled]="!dateTime.date || !dateTime.time"
[disabled]="!dateTime.date"
>
Set
</button>
Expand Down Expand Up @@ -349,4 +356,4 @@
</div>
</div>
</ng-template>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {InvalidEntityError} from '../../errors/base.error';
import {
AllowedValues,
AllowedValuesMap,
BpmnNode,
NodeWithInput,
RecordOfAnyType,
WorkflowNode,
Expand Down Expand Up @@ -99,9 +100,10 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
itemChanged = new EventEmitter<unknown>();

date: DateType = {month: 0, day: 0, year: 0};
dateTime: DateTime = {
date: {month: 0, day: 0, year: 0},
time: {hour: null, minute: null},

dateTime: any = {
date: '',
time: '',
};
emailInput: EmailInput = {
subject: '',
Expand Down Expand Up @@ -236,7 +238,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
this.dateTime = value;
break;
case InputTypes.People:
this.selectedItems = value.map((item: { id: string; }) => item.id);
this.selectedItems = value.map((item: {id: string}) => item.id);
break;
}
}
Expand Down Expand Up @@ -316,6 +318,10 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
groupId: string,
id?: string,
) {
this.dateTime = {
date: '',
time: '',
};
const newNode = {
node: this.nodes.getNodeByName(
node.getIdentifier(),
Expand Down Expand Up @@ -515,11 +521,16 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
this.selectedItems = [];
}

getLibraryValue($event: any, type: string, metaObj: RecordOfAnyType) {
getLibraryValue(
node: BpmnNode,
$event: any,
type: string,
metaObj: RecordOfAnyType,
) {
const value = $event.target?.value ?? $event;
switch (type) {
case InputTypes.People:
const selectedIds = metaObj.list.filter((item: { id: any }) =>
const selectedIds = metaObj.list.filter((item: {id: any}) =>
(this.selectedItems as any[]).includes(`${item.id}`),
);
return selectedIds;
Expand All @@ -536,6 +547,9 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
}
case InputTypes.DateTime:
if (value) {
if (this.dateTime.time === '') {
this.dateTime.time = node.state.get('defaultTime') ?? '9:00';
}
const dateObj = moment(`${value.date} ${value.time}`);
return {
date: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,8 @@ export abstract class WorkflowPrompt {
DATE_TIME_FORMAT,
);
return {
date: {
month: moment(dateString).month() + 1,
day: moment(dateString).date(),
year: moment(dateString).year(),
},
time: {
hour: moment(dateString).hours(),
minute: moment(dateString).minutes(),
},
date: moment(dateString).format('YYYY-MM-DD'),
time: moment(dateString).format('hh:mm'),
};
}
case InputTypes.Email:
Expand Down
4 changes: 2 additions & 2 deletions projects/workflows-creator/src/lib/types/base.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export type Select = {
* @property day - The day of the month.
* @property year - The year of the date.
*/
export type DateType = {month: 0; day: 0; year: 0};
export type DateType = {month: number; day: number; year: number};

/**
* `DateTime` is an object with a `date` property of type `DateType` and a `time` property of type
Expand All @@ -149,7 +149,7 @@ export type DateType = {month: 0; day: 0; year: 0};
*/
export type DateTime = {
date: DateType;
time: {hour: null; minute: null};
time: {hour: number; minute: number};
};

/**
Expand Down
4 changes: 2 additions & 2 deletions projects/workflows-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"access": "public",
"directory": "dist"
},
"hash": "7c91307fa0c8a1ecbe458304cc791f4a31ed7b8763112f2eb09bf1a6b5768b58"
}
"hash": "388809af6444a8fc997fa5e1e76c0f7847b34244a3cb68d956706dec8c470733"
}

0 comments on commit 100eb56

Please sign in to comment.