2018-07-19 23:08:51 +00:00
|
|
|
import Component from '@ember/component';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { action, computed } from '@ember/object';
|
2019-08-08 14:26:46 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2018-07-20 21:29:51 +00:00
|
|
|
import PromiseArray from 'nomad-ui/utils/classes/promise-array';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { classNames } from '@ember-decorators/component';
|
|
|
|
import classic from 'ember-classic-decorator';
|
2018-07-19 23:08:51 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
@classNames('boxed-section')
|
|
|
|
export default class RecentAllocations extends Component {
|
|
|
|
@service router;
|
2019-06-13 00:40:37 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
sortProperty = 'modifyIndex';
|
|
|
|
sortDescending = true;
|
2019-08-08 14:26:46 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('job.allocations.@each.modifyIndex')
|
|
|
|
get sortedAllocations() {
|
2019-10-08 18:44:19 +00:00
|
|
|
return PromiseArray.create({
|
2021-12-28 14:45:20 +00:00
|
|
|
promise: this.get('job.allocations').then((allocations) =>
|
|
|
|
allocations.sortBy('modifyIndex').reverse().slice(0, 5)
|
2018-07-20 21:29:51 +00:00
|
|
|
),
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-07-19 23:08:51 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@action
|
|
|
|
gotoAllocation(allocation) {
|
|
|
|
this.router.transitionTo('allocations.allocation', allocation.id);
|
|
|
|
}
|
|
|
|
}
|