Skip to content

Commit 015566f

Browse files
fix(core): reset the date,datetime column when another column is selected (#75)
GH-74
1 parent 734f2bf commit 015566f

File tree

6 files changed

+90
-16
lines changed

6 files changed

+90
-16
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,16 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
460460
case EventTypes.OnValueEvent:
461461
case ActionTypes.ChangeColumnValueAction:
462462
const columnExists = !!node.node.state.get('column');
463-
let valueExists = false;
464-
if (typeof node.node.state.get('value') !== 'undefined') {
465-
valueExists = true;
466-
} else if (
467-
node.node.state.get('condition') === ConditionTypes.PastToday
468-
) {
469-
valueExists = true;
470-
} else {
471-
valueExists = !!node.node.state.get('value');
472-
}
463+
let valueExists = false;
464+
if (typeof node.node.state.get('value') !== 'undefined') {
465+
valueExists = true;
466+
} else if (
467+
node.node.state.get('condition') === ConditionTypes.PastToday
468+
) {
469+
valueExists = true;
470+
} else {
471+
valueExists = !!node.node.state.get('value');
472+
}
473473
const valueTypeIsAnyValue =
474474
node.node.state.get('valueType') === ValueTypes.AnyValue;
475475
isValid = columnExists && (valueExists || valueTypeIsAnyValue);

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@
277277
<input
278278
class="date-input"
279279
type="date"
280-
[(ngModel)]="date"
280+
[(ngModel)]="input.getModelValue(nodeWithInput.node.state) || date"
281+
(ngModelChange)="updateSecondVariable($event, inputType.date)"
281282
(click)="$event.stopPropagation()"
282283
min="0000-01-01"
283284
max="9999-12-31"
@@ -321,10 +322,36 @@
321322
<div class="date-time-picker" (document:click)="hide()">
322323
<div class="time-picker">
323324
<div class="date-input">
324-
<input type="date" [(ngModel)]="dateTime.date" />
325+
<input
326+
type="date"
327+
[(ngModel)]="
328+
input.getModelValue(nodeWithInput.node.state).date ||
329+
dateTime.date
330+
"
331+
(ngModelChange)="
332+
updateSecondVariable(
333+
$event,
334+
inputType.dateTime,
335+
dateTimeFields.date
336+
)
337+
"
338+
/>
325339
</div>
326340
<div class="time-input">
327-
<input type="time" [(ngModel)]="dateTime.time" />
341+
<input
342+
type="time"
343+
[(ngModel)]="
344+
input.getModelValue(nodeWithInput.node.state).time ||
345+
dateTime.time
346+
"
347+
(ngModelChange)="
348+
updateSecondVariable(
349+
$event,
350+
inputType.dateTime,
351+
dateTimeFields.time
352+
)
353+
"
354+
/>
328355
</div>
329356
<div>
330357
<button

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {NgxPopperjsContentComponent} from 'ngx-popperjs';
1212
import {isSelectInput, NodeService, WorkflowPrompt} from '../../classes';
1313
import {AbstractBaseGroup} from '../../classes/nodes';
1414
import {
15+
DateTimeFields,
1516
InputTypes,
1617
LocalizedStringKeys,
1718
NodeTypes,
@@ -61,6 +62,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
6162
private readonly localizationSvc: LocalizationProviderService,
6263
) {}
6364
public inputType = InputTypes;
65+
public dateTimeFields = DateTimeFields;
6466
private isMouseDown: boolean = false;
6567
@Input()
6668
group: AbstractBaseGroup<E>;
@@ -322,6 +324,11 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
322324
time: '',
323325
};
324326
this.date = '';
327+
this.emailInput = {
328+
subject: '',
329+
body: '',
330+
focusKey: '',
331+
};
325332
const newNode = {
326333
node: this.nodes.getNodeByName(
327334
node.getIdentifier(),
@@ -528,6 +535,11 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
528535
metaObj: RecordOfAnyType,
529536
) {
530537
const value = $event.target?.value ?? $event;
538+
this.dateTime = {
539+
date: '',
540+
time: '',
541+
};
542+
this.date = '';
531543
switch (type) {
532544
case InputTypes.People:
533545
const selectedIds = metaObj.list.filter((item: {id: any}) =>
@@ -547,8 +559,8 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
547559
}
548560
case InputTypes.DateTime:
549561
if (value) {
550-
if (this.dateTime.time === '') {
551-
this.dateTime.time = node.state.get('defaultTime') ?? '9:00';
562+
if (value.time === '') {
563+
value.time = node.state.get('defaultTime') ?? '9:00';
552564
}
553565
const dateObj = moment(`${value.date} ${value.time}`);
554566
return {
@@ -614,6 +626,26 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
614626
callback(response);
615627
}
616628
}
629+
630+
updateSecondVariable(
631+
event: any,
632+
inputType: InputTypes,
633+
dateTimeField?: string,
634+
) {
635+
//if inputType->dateTime
636+
switch (inputType) {
637+
case InputTypes.DateTime:
638+
if (dateTimeField == 'date') {
639+
this.dateTime.date = event;
640+
} else {
641+
this.dateTime.time = event;
642+
}
643+
break;
644+
case InputTypes.Date:
645+
this.date = event;
646+
}
647+
}
648+
617649
/**
618650
* It removes all the inputs that come after the current input
619651
* @param element - NodeWithInput<E>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,19 @@ export abstract class WorkflowPrompt {
222222
});
223223
}
224224
case InputTypes.Date: {
225+
if (!state.get(this.inputKey)) {
226+
return '';
227+
}
225228
const dateString = state.get(this.inputKey);
226229
return moment(dateString).format('YYYY-MM-DD');
227230
}
228231
case InputTypes.DateTime: {
232+
if (!state.get(this.inputKey)) {
233+
return {
234+
date: null,
235+
time: null,
236+
};
237+
}
229238
const dateString = moment(state.get(this.inputKey))?.format(
230239
DATE_TIME_FORMAT,
231240
);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ export enum LocalizedStringKeys {
106106
SelectColumnTooltip = 'selectColumnTooltip',
107107
SetLbl = 'setLbl',
108108
}
109+
110+
export enum DateTimeFields {
111+
Date = 'date',
112+
Time = 'time',
113+
}

projects/workflows-element/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"access": "public",
1818
"directory": "dist"
1919
},
20-
"hash": "52e16f7339ae099b920d5eba85c8551b9ac2178d0fdb8c34eb6eb6de8aa96685"
20+
"hash": "3c1458420fa687bd8cf740b4ec3efc6aed003c8e1ce99c465f3d467a95c9ac90"
2121
}
22+

0 commit comments

Comments
 (0)