hino / app / routes / hoyu-event-approval / 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({
	hoyuEventApproval : service(),
	hoyuEventApprovalData : service(),
	hoyuEventApprovalListData: service(),
	hoyuEventApprovalAttachmentData: service(),
	hoyuEventApprovalBudgetData: service(),
	store : service(),

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

	model(params) {
		this.hoyuEventApproval.setModel(null);
		return this.hoyuEventApprovalData.getData(params.id, { include: 'hoyu-event-approval-list,hoyu-event-approval-attachment,hoyu-event-approval-budget' })
		.then(response => {
			this.hoyuEventApproval.setModel(response);
			this.hoyuEventApprovalListData.getList({include: 'hoyu-event-approval', filter:{"hoyuEventApproval" : {"id" : response.id}}}).then(responseDetail => {

				this.hoyuEventApproval.clearDetail("hoyuEventApprovalList");
				responseDetail.forEach(item => {
					this.hoyuEventApproval.addRow(item, "hoyu-event-approval-list");
				});
			});
			this.hoyuEventApprovalAttachmentData.getList({include: 'attachment,hoyu-event-approval', filter:{"hoyuEventApproval" : {"id" : response.id}}}).then(responseDetail => {

				this.hoyuEventApproval.clearDetail("hoyuEventApprovalAttachment");
				responseDetail.forEach(item => {
					this.hoyuEventApproval.addRow(item, "hoyu-event-approval-attachment");
				});
			});
			this.hoyuEventApprovalBudgetData.getList({include: 'hoyu-event-approval', filter:{"hoyuEventApproval" : {"id" : response.id}}}).then(responseDetail => {

				this.hoyuEventApproval.clearDetail("hoyuEventApprovalBudget");
				responseDetail.forEach(item => {
					this.hoyuEventApproval.addRow(item, "hoyu-event-approval-budget");
				});
			});
			return response;
		});
	},

});