Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: simvalery <[email protected]>
  • Loading branch information
simvalery committed Dec 10, 2024
1 parent 193943c commit cd6b9b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class DateTimeComponent implements OnInit, AfterViewInit, OnChanges, OnDe
@Input('control') control: UntypedFormControl;
@Input('showIcon') showIcon: boolean = true;
@Input('showSeconds') showSeconds: boolean = true;
@Input('showTime') showTime: boolean = true;
@Input('showTime') showTime: boolean;
@Input('timeOnly') timeOnly: boolean = false;
@Input('dateFormat') dateFormat: string = 'yy-mm-dd';
@Input('item') item: any;
Expand Down Expand Up @@ -69,6 +69,7 @@ export class DateTimeComponent implements OnInit, AfterViewInit, OnChanges, OnDe
}

setTimeout(() => {
console.log(this.showTime);
const input = this.calendar?.el.nativeElement.querySelector('input');
if (input && value) {
if (this.timeOnly) {
Expand All @@ -78,6 +79,10 @@ export class DateTimeComponent implements OnInit, AfterViewInit, OnChanges, OnDe
const date = moment(value, 'hh:mm:ss').toDate();
this.control.setValue(date);
input.value = moment(value, 'hh:mm:ss').format('HH:mm:ss');
} else if (!this.showTime) {
const date = moment(value, 'YYYY-MM-DD').toDate();
this.control.setValue(date);
input.value = moment(value, 'YYYY-MM-DD').format('YYYY-MM-DD');
} else {
this.control.setValue(moment(value).toDate())
input.value = moment(value).format('YYYY-MM-DD HH:mm:ss');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
</div>

<div *ngIf="isDateTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="item.control" [item]="item"></date-time-control>
<date-time-control [control]="item.control" [item]="item" [showTime]="true"></date-time-control>
</div>

<div *ngIf="isDate(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="item.control" [item]="item"
<date-time-control [control]="item.control" [item]="item" [showTime]="false"
[showSeconds]="false"></date-time-control>
</div>

Expand Down Expand Up @@ -194,7 +194,7 @@

<div *ngIf="isDateTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="listItem.control" [index]="i" [isMany]="true"
[item]="listItem"
[item]="listItem" [showTime]="true"
[value]="item.suggest"></date-time-control>
</div>

Expand Down

0 comments on commit cd6b9b8

Please sign in to comment.