Refactoring delete measurement
This commit is contained in:
parent
a4dbb4a94d
commit
233a2d09a1
3 changed files with 22 additions and 14 deletions
|
@ -10,6 +10,14 @@ export default Controller.extend(SaveModel, {
|
|||
fallbackRouteCancel: 'protected.strains.show',
|
||||
|
||||
actions: {
|
||||
save: function(properties, deleteQueue) {
|
||||
deleteQueue.forEach((val) => {
|
||||
val.destroyRecord();
|
||||
});
|
||||
|
||||
this._super(properties);
|
||||
},
|
||||
|
||||
addCharacteristic: function() {
|
||||
return this.store.createRecord('measurement', {
|
||||
characteristic: this.store.createRecord('characteristic', { sortOrder: -999 }),
|
||||
|
@ -25,13 +33,5 @@ export default Controller.extend(SaveModel, {
|
|||
});
|
||||
},
|
||||
|
||||
deleteMeasurement: function(measurement) {
|
||||
const characteristic = measurement.get('characteristic');
|
||||
if (characteristic.get('isNew')) {
|
||||
characteristic.destroyRecord();
|
||||
}
|
||||
measurement.destroyRecord();
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
add-characteristic=(action "addCharacteristic")
|
||||
allCharacteristics=allCharacteristics
|
||||
save-measurement=(action "saveMeasurement")
|
||||
delete-measurement=(action "deleteMeasurement")
|
||||
on-save=(action "save")
|
||||
on-cancel=(action "cancel")
|
||||
}}
|
||||
|
|
Reference in a new issue