hino / app / routes / multiple-attachment / detail.js
detail.js
Raw
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

import BaseRoute from 'hino-hearts/routes/base';

export default BaseRoute.extend({
	multipleAttachment : service(),
	multipleAttachmentData : service(),
	multipleAttachmentDetailData: service(),
	store : service(),

	init() {
		this._super(...arguments);
	},

	model(params) {
		this.multipleAttachment.setModel(null);
		return this.multipleAttachmentData.getData(params.id, { include: 'multiple-attachment-detail' })
		.then(response => {
			this.multipleAttachment.setModel(response);
			this.multipleAttachmentDetailData.getList({include: 'multiple-attachment,core-attachment', filter:{"multipleAttachment" : {"id" : response.id}}}).then(responseDetail => {

				this.multipleAttachment.clearDetail("multipleAttachmentDetail");
				responseDetail.forEach(item => {
					this.multipleAttachment.addRow(item, "multiple-attachment-detail");
				});
			});
			return response;
		});
	},

});