loading draft from template

This commit is contained in:
2023-02-12 20:12:19 +01:00
parent 57a282b004
commit 7c34c2ba91
7 changed files with 130 additions and 23 deletions

View File

@@ -17,9 +17,22 @@ export class CardComponent implements OnInit {
@Input() resource: string | undefined;
@Input() resource_id: string | null = null;
@Input() schema: string | undefined;
@Input() model = {};
@Input() is_modal: Boolean = false;
private _model: {} = {};
@Input() set model(value: any) {
this._model = value;
if (Object.keys(this.form.controls).length) {
delete value._id;
this.form.patchValue(value);
}
}
get model(): any {
return this._model;
}
@Output() resourceCreated: EventEmitter<string> = new EventEmitter();
@Output() resourceUpdated: EventEmitter<string> = new EventEmitter();
@Output() resourceDeleted: EventEmitter<string> = new EventEmitter();
@@ -91,6 +104,7 @@ export class CardComponent implements OnInit {
error: (err) => this.error.emit("Error creating the entity:" + err)
});
} else {
model._id = this.resource_id;
this.crudService.update(this.resource!, model).subscribe( {
next: (model: any) => {
this.model = model;