2018-11-24 17:03:51 +08:00

35 lines
1.0 KiB
JavaScript

import BaseRoute from '../base';
import EmberObject, { computed } from '@ember/object';
import RSVP from 'rsvp';
export default BaseRoute.extend({
breadcrumbs: [{route: 'local-product.list', params: 1, text: 'Local Product'},
{text: 'Create Local Product'}],
modelClass: EmberObject.extend({
hasImage: computed('images.@each.file', function() {
return this.get('images').filter(image => image.file).length > 0;
})
}),
model() {
return RSVP.hash({
enabled: true,
images: [{}],
attachments: [{}]
});
},
actions: {
addImage() {
this.get('controller.model.images').pushObject({});
},
removeImage(image) {
this.get('controller.model.images').removeObject(image);
},
addAttachment() {
this.get('controller.model.attachments').pushObject({});
},
removeAttachment(attachment) {
this.get('controller.model.attachments').removeObject(attachment);
}
}
});