Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgny committed Jul 5, 2024
1 parent 67bb72d commit 964380a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,
minDate: Date;
maxDate: Date;

datetimeInputControl: FormControl;
datetimeInputControl: FormControl<Date>;

private datetimeChangesSubscription: Subscription;

Expand All @@ -77,7 +77,7 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,
private initFormControl(): void {
this.datetimeInputControl = new FormControl<Date>(
{
value: new Date(this.field?.value),
value: DateFnsUtils.getDate(this.field.value),
disabled: this.field?.readOnly || this.readOnly
},
this.isRequired() ? [Validators.required] : []
Expand Down Expand Up @@ -108,11 +108,11 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,

private initDateRange(): void {
if (this.field?.minValue) {
this.minDate = DateFnsUtils.utcToLocal(new Date(this.field.minValue));
this.minDate = DateFnsUtils.getDate(this.field.minValue);
}

if (this.field?.maxValue) {
this.maxDate = DateFnsUtils.utcToLocal(new Date(this.field.maxValue));
this.maxDate = DateFnsUtils.getDate(this.field.maxValue);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
[placeholder]="field.placeholder"
[min]="minDate"
[max]="maxDate"
[disabled]="field.readOnly"
[matTooltip]="field.tooltip"
matTooltipPosition="above"
matTooltipShowDelay="1000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ import { NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatTooltipModule } from '@angular/material/tooltip';

@Component({
selector: 'date-widget',
standalone: true,
imports: [NgIf, TranslateModule, MatFormFieldModule, MatInputModule, MatDatepickerModule, ReactiveFormsModule, ErrorWidgetComponent],
imports: [
NgIf,
TranslateModule,
MatFormFieldModule,
MatInputModule,
MatDatepickerModule,
MatTooltipModule,
ReactiveFormsModule,
ErrorWidgetComponent
],
providers: [
{ provide: MAT_DATE_FORMATS, useValue: ADF_DATE_FORMATS },
{ provide: DateAdapter, useClass: AdfDateFnsAdapter }
Expand All @@ -53,13 +63,14 @@ import { MatInputModule } from '@angular/material/input';
encapsulation: ViewEncapsulation.None
})
export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy {
typeId = 'DateCloudWidgetComponent';
readonly DATE_FORMAT = 'dd-MM-yyyy';

minDate: Date = null;
maxDate: Date = null;
startAt: Date = null;

dateInputControl: FormControl;
dateInputControl: FormControl<Date>;

private dateChangesSubscription: Subscription;

Expand Down

0 comments on commit 964380a

Please sign in to comment.