I have a freight order model with a hasMany relation with a shipment model. I do a save on the freight order, and send all data in one go. I can handle errors on the freight order model just fine, but can not figure out how to handle API errors on nested models in the template.
The freight order model:
import DS from 'ember-data';
export default DS.Model.extend({
comment: DS.attr('string'),
freighter: DS.belongsTo('account'),
shipments: DS.hasMany('shipment', { inverse: null })
});
The shipment model:
import DS from 'ember-data';
export default DS.Model.extend({
pickup_address: DS.belongsTo('address', { inverse: null }),
delivery_address: DS.belongsTo('address', { inverse: null }),
shipment_lines: DS.hasMany('shipment-line', { inverse: null }),
shipmentPrice: Ember.computed('shipment_lines.@each.package_price', function () {
let price = 0;
this.get('shipment_lines').forEach(function(shipment_line) {
price += Number(shipment_line.get('package_price'));
});
return price;
}),
});
Errors directly on the freight order I handle in the handlebars template like this:
<div class="errorMessage">
</div>
Thank you for your time.
Aucun commentaire:
Enregistrer un commentaire