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

fix(core): reset the date,datetime column when another column is selected #75

Merged
merged 2 commits into from
Mar 8, 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
20 changes: 10 additions & 10 deletions projects/workflows-creator/src/lib/builder/builder.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,16 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
case EventTypes.OnValueEvent:
case ActionTypes.ChangeColumnValueAction:
const columnExists = !!node.node.state.get('column');
let valueExists = false;
if (typeof node.node.state.get('value') !== 'undefined') {
valueExists = true;
} else if (
node.node.state.get('condition') === ConditionTypes.PastToday
) {
valueExists = true;
} else {
valueExists = !!node.node.state.get('value');
}
let valueExists = false;
if (typeof node.node.state.get('value') !== 'undefined') {
valueExists = true;
} else if (
node.node.state.get('condition') === ConditionTypes.PastToday
) {
valueExists = true;
} else {
valueExists = !!node.node.state.get('value');
}
const valueTypeIsAnyValue =
node.node.state.get('valueType') === ValueTypes.AnyValue;
isValid = columnExists && (valueExists || valueTypeIsAnyValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@
<input
class="date-input"
type="date"
[(ngModel)]="date"
[(ngModel)]="input.getModelValue(nodeWithInput.node.state) || date"
(ngModelChange)="updateSecondVariable($event, inputType.date)"
(click)="$event.stopPropagation()"
min="0000-01-01"
max="9999-12-31"
Expand Down Expand Up @@ -321,10 +322,36 @@
<div class="date-time-picker" (document:click)="hide()">
<div class="time-picker">
<div class="date-input">
<input type="date" [(ngModel)]="dateTime.date" />
<input
type="date"
[(ngModel)]="
input.getModelValue(nodeWithInput.node.state).date ||
dateTime.date
"
(ngModelChange)="
updateSecondVariable(
$event,
inputType.dateTime,
dateTimeFields.date
)
"
/>
</div>
<div class="time-input">
<input type="time" [(ngModel)]="dateTime.time" />
<input
type="time"
[(ngModel)]="
input.getModelValue(nodeWithInput.node.state).time ||
dateTime.time
"
(ngModelChange)="
updateSecondVariable(
$event,
inputType.dateTime,
dateTimeFields.time
)
"
/>
</div>
<div>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {NgxPopperjsContentComponent} from 'ngx-popperjs';
import {isSelectInput, NodeService, WorkflowPrompt} from '../../classes';
import {AbstractBaseGroup} from '../../classes/nodes';
import {
DateTimeFields,
InputTypes,
LocalizedStringKeys,
NodeTypes,
Expand Down Expand Up @@ -61,6 +62,7 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
private readonly localizationSvc: LocalizationProviderService,
) {}
public inputType = InputTypes;
public dateTimeFields = DateTimeFields;
private isMouseDown: boolean = false;
@Input()
group: AbstractBaseGroup<E>;
Expand Down Expand Up @@ -322,6 +324,11 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
time: '',
};
this.date = '';
this.emailInput = {
subject: '',
body: '',
focusKey: '',
};
const newNode = {
node: this.nodes.getNodeByName(
node.getIdentifier(),
Expand Down Expand Up @@ -528,6 +535,11 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
metaObj: RecordOfAnyType,
) {
const value = $event.target?.value ?? $event;
this.dateTime = {
date: '',
time: '',
};
this.date = '';
switch (type) {
case InputTypes.People:
const selectedIds = metaObj.list.filter((item: {id: any}) =>
Expand All @@ -547,8 +559,8 @@ 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';
if (value.time === '') {
value.time = node.state.get('defaultTime') ?? '9:00';
}
const dateObj = moment(`${value.date} ${value.time}`);
return {
Expand Down Expand Up @@ -614,6 +626,26 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
callback(response);
}
}

updateSecondVariable(
event: any,
inputType: InputTypes,
dateTimeField?: string,
) {
//if inputType->dateTime
switch (inputType) {
case InputTypes.DateTime:
if (dateTimeField == 'date') {
this.dateTime.date = event;
} else {
this.dateTime.time = event;
}
yeshamavani marked this conversation as resolved.
Show resolved Hide resolved
break;
case InputTypes.Date:
this.date = event;
}
}

/**
* It removes all the inputs that come after the current input
* @param element - NodeWithInput<E>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,19 @@ export abstract class WorkflowPrompt {
});
}
case InputTypes.Date: {
if (!state.get(this.inputKey)) {
return '';
}
const dateString = state.get(this.inputKey);
return moment(dateString).format('YYYY-MM-DD');
}
case InputTypes.DateTime: {
if (!state.get(this.inputKey)) {
return {
date: null,
time: null,
};
}
const dateString = moment(state.get(this.inputKey))?.format(
DATE_TIME_FORMAT,
);
Expand Down
5 changes: 5 additions & 0 deletions projects/workflows-creator/src/lib/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ export enum LocalizedStringKeys {
SelectColumnTooltip = 'selectColumnTooltip',
SetLbl = 'setLbl',
}

export enum DateTimeFields {
Date = 'date',
Time = 'time',
}
3 changes: 2 additions & 1 deletion projects/workflows-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"access": "public",
"directory": "dist"
},
"hash": "52e16f7339ae099b920d5eba85c8551b9ac2178d0fdb8c34eb6eb6de8aa96685"
"hash": "3c1458420fa687bd8cf740b4ec3efc6aed003c8e1ce99c465f3d467a95c9ac90"
}

Loading