2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import EmberError from '@ember/error';
|
2017-10-30 20:39:15 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class TaskRoute extends Route {
|
|
|
|
@service store;
|
2017-10-30 20:39:15 +00:00
|
|
|
|
2018-06-27 19:59:27 +00:00
|
|
|
breadcrumbs(model) {
|
|
|
|
if (!model) return [];
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: model.get('name'),
|
|
|
|
args: ['allocations.allocation.task', model.get('allocation'), model],
|
|
|
|
},
|
|
|
|
];
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-06-27 19:59:27 +00:00
|
|
|
|
2017-10-30 20:39:15 +00:00
|
|
|
model({ name }) {
|
|
|
|
const allocation = this.modelFor('allocations.allocation');
|
|
|
|
|
2018-11-06 00:33:33 +00:00
|
|
|
// If there is no allocation, then there is no task.
|
|
|
|
// Let the allocation route handle the 404 error.
|
|
|
|
if (!allocation) return;
|
2017-10-30 20:39:15 +00:00
|
|
|
|
2018-11-06 00:33:33 +00:00
|
|
|
const task = allocation.get('states').findBy('name', name);
|
|
|
|
|
|
|
|
if (!task) {
|
2017-10-30 20:39:15 +00:00
|
|
|
const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`);
|
|
|
|
err.code = '404';
|
|
|
|
this.controllerFor('application').set('error', err);
|
|
|
|
}
|
2018-11-06 00:33:33 +00:00
|
|
|
|
|
|
|
return task;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|