Simplify save function.
This commit is contained in:
parent
25fcc34b68
commit
5e964dd8e8
@ -125,15 +125,8 @@ export class OperationListComponent implements OnInit {
|
|||||||
save(operation) {
|
save(operation) {
|
||||||
operation.confirmed = true;
|
operation.confirmed = true;
|
||||||
|
|
||||||
var observable: Observable<Operation>;
|
return this.operationService.create(operation).subscribe(
|
||||||
|
(operation) => {
|
||||||
if(operation.id){
|
|
||||||
observable = this.operationService.update(operation);
|
|
||||||
} else {
|
|
||||||
observable = this.operationService.create(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return observable.subscribe((operation) => {
|
|
||||||
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
||||||
|
|
||||||
this.load(this.minDate, this.maxDate);
|
this.load(this.minDate, this.maxDate);
|
||||||
@ -143,7 +136,8 @@ export class OperationListComponent implements OnInit {
|
|||||||
this.toastrService.error(
|
this.toastrService.error(
|
||||||
'Error while saving operation: ' + result.message
|
'Error while saving operation: ' + result.message
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
onUpdate(dateRange) {
|
onUpdate(dateRange) {
|
||||||
|
Loading…
Reference in New Issue
Block a user