Delete measurement

This commit is contained in:
Matthew Dillon 2015-11-10 16:14:02 -07:00
parent b2fa171d17
commit c1ff0d57b4
7 changed files with 28 additions and 7 deletions

View file

@ -24,5 +24,13 @@ export default Controller.extend(SaveModel, {
}); });
}, },
deleteMeasurement: function(measurement) {
const characteristic = measurement.get('characteristic');
if (characteristic.get('isNew')) {
characteristic.destroyRecord();
}
measurement.destroyRecord();
},
}, },
}); });

View file

@ -5,6 +5,7 @@
add-characteristic=(action "addCharacteristic") add-characteristic=(action "addCharacteristic")
allCharacteristics=allCharacteristics allCharacteristics=allCharacteristics
save-measurement=(action "saveMeasurement") save-measurement=(action "saveMeasurement")
delete-measurement=(action "deleteMeasurement")
on-save=(action "save") on-save=(action "save")
on-cancel=(action "cancel") on-cancel=(action "cancel")
}} }}

View file

@ -8,8 +8,12 @@ export default Component.extend({
allCharacteristics: null, allCharacteristics: null,
measurement: null, measurement: null,
// Actions
"save-measurement": null,
"delete-measurement": null,
oldCharacteristicId: function() { oldCharacteristicId: function() {
let json = this.get('measurement').toJSON(); const json = this.get('measurement').toJSON();
return json.characteristic; return json.characteristic;
}.property(), }.property(),
@ -29,12 +33,8 @@ export default Component.extend({
}, },
delete: function() { delete: function() {
let char = this.get('measurement.characteristic'); this.attrs['delete-measurement'](this.get('measurement'));
if (char.get('isNew')) { },
char.destroyRecord();
}
this.get('measurement').destroyRecord();
}
}, },
}); });

View file

@ -13,6 +13,7 @@ export default Component.extend({
// Actions // Actions
"add-characteristic": null, "add-characteristic": null,
"save-measurement": null, "save-measurement": null,
"delete-measurement": null,
// Properties // Properties
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'], sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
@ -45,6 +46,10 @@ export default Component.extend({
saveMeasurement: function(measurement) { saveMeasurement: function(measurement) {
return this.attrs['save-measurement'](measurement); return this.attrs['save-measurement'](measurement);
}, },
deleteMeasurement: function(measurement) {
return this.attrs['delete-measurement'](measurement);
},
}, },
}); });

View file

@ -44,6 +44,7 @@
protected/strains/measurements-table-row protected/strains/measurements-table-row
measurement=measurement measurement=measurement
save-measurement=(action "saveMeasurement") save-measurement=(action "saveMeasurement")
delete-measurement=(action "deleteMeasurement")
allCharacteristics=allCharacteristics allCharacteristics=allCharacteristics
canEdit=canEdit canEdit=canEdit
}} }}

View file

@ -17,6 +17,7 @@ export default Component.extend(SetupMetaData, {
"on-update": null, "on-update": null,
"add-characteristic": null, "add-characteristic": null,
"save-measurement": null, "save-measurement": null,
"delete-measurement": null,
// Property mapping // Property mapping
propertiesList: ['strainName', 'typeStrain', 'species', 'isolatedFrom', 'accessionNumbers', 'genbank', 'wholeGenomeSequence', 'notes'], propertiesList: ['strainName', 'typeStrain', 'species', 'isolatedFrom', 'accessionNumbers', 'genbank', 'wholeGenomeSequence', 'notes'],
@ -65,6 +66,10 @@ export default Component.extend(SetupMetaData, {
return this.attrs['save-measurement'](measurement); return this.attrs['save-measurement'](measurement);
}, },
deleteMeasurement: function(measurement) {
return this.attrs['delete-measurement'](measurement);
},
strainNameDidChange: function(value) { strainNameDidChange: function(value) {
this.updateField('strainName', value); this.updateField('strainName', value);
}, },

View file

@ -56,6 +56,7 @@
add-characteristic=(action "addCharacteristic") add-characteristic=(action "addCharacteristic")
allCharacteristics=allCharacteristics allCharacteristics=allCharacteristics
save-measurement=(action "saveMeasurement") save-measurement=(action "saveMeasurement")
delete-measurement=(action "deleteMeasurement")
canEdit=strain.canEdit canEdit=strain.canEdit
canAdd=metaData.canAdd canAdd=metaData.canAdd
}} }}