| .. | .. |
|---|
| 56 | 56 | protected abstract init(): void; |
|---|
| 57 | 57 | protected abstract goBack(): void; |
|---|
| 58 | 58 | |
|---|
| 59 | | - save() { |
|---|
| 60 | | - var command = this.isNew ? this.resourceServices.create(this.data) : this.resourceServices.modify(this.data.id, this.data); |
|---|
| 59 | + save(fieldId : string = 'id') { |
|---|
| 60 | + var command = this.isNew ? this.resourceServices.create(this.data) : this.resourceServices.modify(this.data[fieldId], this.data); |
|---|
| 61 | 61 | command.subscribe( |
|---|
| 62 | 62 | data => { |
|---|
| 63 | 63 | this.toaster.success(this.$L.get('{} saved sucessfully', this.resourceName.capitalize())); |
|---|
| .. | .. |
|---|
| 94 | 94 | this.form_title = this.$L.get('{} data', this.resourceName.capitalize()); |
|---|
| 95 | 95 | this.isNew = true; |
|---|
| 96 | 96 | !!this.route && this.route.params.subscribe(params => { |
|---|
| 97 | | - var eleId = +params[idparam]; // (+) converts string 'id' to a number |
|---|
| 97 | + var eleId = params[idparam]; |
|---|
| 98 | 98 | if (!eleId) { |
|---|
| 99 | 99 | this.data = {}; |
|---|
| 100 | 100 | Object.keys(default_values).forEach((k : string) => this.data[k] = default_values[k]); |
|---|