Repairing Date & Datetime components
This commit is contained in:
@@ -59,8 +59,8 @@ export class CardComponent implements OnInit {
|
||||
this._loading$.next(true);
|
||||
if (this.isCreateForm()) {
|
||||
this.crudService.create(this.resource!, model).subscribe((response: any) => {
|
||||
this._loading$.next(false);
|
||||
this.router.navigateByUrl(response.id);
|
||||
this._loading$.next(false);
|
||||
this.router.navigate([`../${response.id}`], {relativeTo: this.route});
|
||||
});
|
||||
} else {
|
||||
this.crudService.update(this.resource!, model).subscribe((model: any) => {
|
||||
|
||||
@@ -39,16 +39,20 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
})
|
||||
export class DateTypeComponent extends FieldType<FieldTypeConfig> implements OnInit
|
||||
{
|
||||
public time : NgbTimeStruct = { hour: 12, minute: 0, second: 0 }
|
||||
public date : NgbDateStruct = { year: 2023, month: 1, day: 9 }
|
||||
public datetime : Date = new Date()
|
||||
public date : NgbDateStruct;
|
||||
public datetime : Date = new Date();
|
||||
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.date = this.getDateStruct(new Date());
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.formControl.value === undefined) {
|
||||
this.changeDatetime({});
|
||||
}
|
||||
|
||||
this.formControl.valueChanges.subscribe(value => {
|
||||
this.datetime = new Date(value)
|
||||
this.date = this.getDateStruct(this.datetime);
|
||||
|
||||
@@ -41,16 +41,22 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
})
|
||||
export class DatetimeTypeComponent extends FieldType<FieldTypeConfig> implements OnInit
|
||||
{
|
||||
public time : NgbTimeStruct = { hour: 12, minute: 0, second: 0 }
|
||||
public date : NgbDateStruct = { year: 2023, month: 1, day: 9 }
|
||||
public time : NgbTimeStruct;
|
||||
public date : NgbDateStruct;
|
||||
public datetime : Date = new Date()
|
||||
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.time = this.getTimeStruct(new Date());
|
||||
this.date = this.getDateStruct(new Date());
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.formControl.value === undefined) {
|
||||
this.changeDatetime({});
|
||||
}
|
||||
|
||||
this.formControl.valueChanges.subscribe(value => {
|
||||
this.datetime = new Date(value)
|
||||
this.date = this.getDateStruct(this.datetime);
|
||||
|
||||
Reference in New Issue
Block a user