Updating date input type to allow empty dates
This commit is contained in:
@@ -17,7 +17,6 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
|||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
[formControl]="formControl"
|
[formControl]="formControl"
|
||||||
[formlyAttributes]="field"
|
[formlyAttributes]="field"
|
||||||
[class.is-invalid]="showError"
|
|
||||||
/>
|
/>
|
||||||
<div class="input-group" *ngIf="! this.field.props.readonly">
|
<div class="input-group" *ngIf="! this.field.props.readonly">
|
||||||
<button class="btn btn-outline-secondary" (click)="d.toggle()" type="button"><i-bs name="calendar-date-fill"></i-bs></button>
|
<button class="btn btn-outline-secondary" (click)="d.toggle()" type="button"><i-bs name="calendar-date-fill"></i-bs></button>
|
||||||
@@ -29,6 +28,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
|||||||
(ngModelChange)="changeDatetime($event)"
|
(ngModelChange)="changeDatetime($event)"
|
||||||
ngbDatepicker
|
ngbDatepicker
|
||||||
#d="ngbDatepicker"
|
#d="ngbDatepicker"
|
||||||
|
[class.is-invalid]="showError"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group" *ngIf="this.field.props.readonly">
|
<div class="input-group" *ngIf="this.field.props.readonly">
|
||||||
@@ -49,6 +49,9 @@ export class DateTypeComponent extends FieldType<FieldTypeConfig> implements OnI
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.formControl.value === undefined) {
|
if (this.formControl.value === undefined) {
|
||||||
this.changeDatetime({});
|
this.changeDatetime({});
|
||||||
|
} else {
|
||||||
|
this.datetime = new Date(this.formControl.value);
|
||||||
|
this.date = this.getDateStruct(this.datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formControl.valueChanges.subscribe(value => {
|
this.formControl.valueChanges.subscribe(value => {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
|||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
[formControl]="formControl"
|
[formControl]="formControl"
|
||||||
[formlyAttributes]="field"
|
[formlyAttributes]="field"
|
||||||
[class.is-invalid]="showError"
|
|
||||||
/>
|
/>
|
||||||
<div class="input-group" *ngIf="! this.field.props.readonly">
|
<div class="input-group" *ngIf="! this.field.props.readonly">
|
||||||
<button class="btn btn-outline-secondary bi bi-calendar3" (click)="d.toggle()" type="button"></button>
|
<button class="btn btn-outline-secondary bi bi-calendar3" (click)="d.toggle()" type="button"></button>
|
||||||
@@ -26,6 +25,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
|||||||
(ngModelChange)="changeDatetime($event)"
|
(ngModelChange)="changeDatetime($event)"
|
||||||
ngbDatepicker
|
ngbDatepicker
|
||||||
#d="ngbDatepicker"
|
#d="ngbDatepicker"
|
||||||
|
[class.is-invalid]="showError"
|
||||||
/>
|
/>
|
||||||
<ngb-timepicker
|
<ngb-timepicker
|
||||||
(ngModelChange)="changeDatetime($event)"
|
(ngModelChange)="changeDatetime($event)"
|
||||||
@@ -54,6 +54,9 @@ export class DatetimeTypeComponent extends FieldType<FieldTypeConfig> implements
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.formControl.value === undefined) {
|
if (this.formControl.value === undefined) {
|
||||||
this.changeDatetime({});
|
this.changeDatetime({});
|
||||||
|
} else {
|
||||||
|
this.datetime = new Date(this.formControl.value);
|
||||||
|
this.date = this.getDateStruct(this.datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formControl.valueChanges.subscribe(value => {
|
this.formControl.valueChanges.subscribe(value => {
|
||||||
|
|||||||
Reference in New Issue
Block a user