Better feedback on draft publication
This commit is contained in:
@@ -37,7 +37,7 @@ export class CardComponent implements OnInit {
|
||||
@Output() resourceUpdated: EventEmitter<string> = new EventEmitter();
|
||||
@Output() resourceDeleted: EventEmitter<string> = new EventEmitter();
|
||||
@Output() error: EventEmitter<string> = new EventEmitter();
|
||||
|
||||
@Output() resourceReceived: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
form = new FormGroup({});
|
||||
fields: FormlyFieldConfig[] = [];
|
||||
@@ -78,6 +78,7 @@ export class CardComponent implements OnInit {
|
||||
next :(model: any) => {
|
||||
this.model = model;
|
||||
this._modelLoading$.next(false);
|
||||
this.resourceReceived.emit(model);
|
||||
},
|
||||
error: (err) => this.error.emit("Error loading the model:" + err)
|
||||
});
|
||||
@@ -96,27 +97,28 @@ export class CardComponent implements OnInit {
|
||||
onSubmit(model: any) {
|
||||
this._modelLoading$.next(true);
|
||||
if (this.isCreateForm()) {
|
||||
this.crudService.create(this.resource!, model).subscribe({
|
||||
next: (response: any) => {
|
||||
this._modelLoading$.next(false);
|
||||
if (! this.is_modal) {
|
||||
this.router.navigate([`../${response.id}`], {relativeTo: this.route});
|
||||
} else {
|
||||
this.resourceCreated.emit(response.id)
|
||||
}
|
||||
},
|
||||
error: (err) => this.error.emit("Error creating the entity:" + err)
|
||||
});
|
||||
this.crudService.create(this.resource!, model).subscribe({
|
||||
next: (response: any) => {
|
||||
this._modelLoading$.next(false);
|
||||
if (! this.is_modal) {
|
||||
this.router.navigate([`../${response.id}`], {relativeTo: this.route});
|
||||
} else {
|
||||
this.resourceCreated.emit(response.id)
|
||||
}
|
||||
},
|
||||
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;
|
||||
this._modelLoading$.next(false);
|
||||
this.resourceUpdated.emit(model._id)
|
||||
},
|
||||
error: (err) => this.error.emit("Error updating the entity:" + err)
|
||||
});
|
||||
this.crudService.update(this.resource!, model).subscribe( {
|
||||
next: (model: any) => {
|
||||
this.model = model;
|
||||
this._modelLoading$.next(false);
|
||||
this.resourceUpdated.emit(model._id);
|
||||
this.resourceReceived.emit(model);
|
||||
},
|
||||
error: (err) => this.error.emit("Error updating the entity:" + err)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user