2017-12-15 21:39:18 +00:00
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import { computed } from '@ember/object';
|
2017-09-19 14:47:10 +00:00
|
|
|
import Sortable from 'nomad-ui/mixins/sortable';
|
|
|
|
import Searchable from 'nomad-ui/mixins/searchable';
|
|
|
|
|
|
|
|
export default Controller.extend(Sortable, Searchable, {
|
|
|
|
queryParams: {
|
|
|
|
currentPage: 'page',
|
|
|
|
searchTerm: 'search',
|
|
|
|
sortProperty: 'sort',
|
|
|
|
sortDescending: 'desc',
|
2019-04-17 18:19:54 +00:00
|
|
|
onlyPreemptions: 'preemptions',
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 8,
|
|
|
|
|
|
|
|
sortProperty: 'modifyIndex',
|
|
|
|
sortDescending: true,
|
|
|
|
|
2017-10-18 19:52:24 +00:00
|
|
|
searchProps: computed(() => ['shortId', 'name']),
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-04-17 18:19:54 +00:00
|
|
|
onlyPreemptions: false,
|
|
|
|
|
|
|
|
visibleAllocations: computed(
|
|
|
|
'model.allocations.[]',
|
|
|
|
'preemptions.[]',
|
|
|
|
'onlyPreemptions',
|
|
|
|
function() {
|
|
|
|
return this.onlyPreemptions ? this.preemptions : this.model.allocations;
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
listToSort: alias('visibleAllocations'),
|
2017-12-15 21:39:18 +00:00
|
|
|
listToSearch: alias('listSorted'),
|
|
|
|
sortedAllocations: alias('listSearched'),
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-04-17 18:19:54 +00:00
|
|
|
preemptions: computed('model.allocations.@each.wasPreempted', function() {
|
|
|
|
return this.model.allocations.filterBy('wasPreempted');
|
|
|
|
}),
|
|
|
|
|
2018-05-08 18:23:42 +00:00
|
|
|
sortedEvents: computed('model.events.@each.time', function() {
|
|
|
|
return this.get('model.events')
|
|
|
|
.sortBy('time')
|
|
|
|
.reverse();
|
|
|
|
}),
|
|
|
|
|
2018-05-09 01:09:20 +00:00
|
|
|
sortedDrivers: computed('model.drivers.@each.name', function() {
|
|
|
|
return this.get('model.drivers').sortBy('name');
|
|
|
|
}),
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
actions: {
|
|
|
|
gotoAllocation(allocation) {
|
|
|
|
this.transitionToRoute('allocations.allocation', allocation);
|
|
|
|
},
|
2019-04-17 18:19:54 +00:00
|
|
|
|
|
|
|
setPreemptionFilter(value) {
|
|
|
|
this.set('onlyPreemptions', value);
|
|
|
|
},
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
|
|
|
});
|