mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Treat filtering on an async relationship as async
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import Component from '@ember/component';
|
||||
import { computed } from '@ember/object';
|
||||
import PromiseArray from 'nomad-ui/utils/classes/promise-array';
|
||||
|
||||
export default Component.extend({
|
||||
sortProperty: 'modifyIndex',
|
||||
sortDescending: true,
|
||||
sortedAllocations: computed('job.allocations.@each.modifyIndex', function() {
|
||||
return this.get('job.allocations')
|
||||
.sortBy('modifyIndex')
|
||||
.reverse()
|
||||
.slice(0, 5);
|
||||
return new PromiseArray({
|
||||
promise: this.get('job.allocations').then(allocations =>
|
||||
allocations
|
||||
.sortBy('modifyIndex')
|
||||
.reverse()
|
||||
.slice(0, 5)
|
||||
),
|
||||
});
|
||||
}),
|
||||
|
||||
actions: {
|
||||
|
||||
4
ui/app/utils/classes/promise-array.js
Normal file
4
ui/app/utils/classes/promise-array.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import ArrayProxy from '@ember/array/proxy';
|
||||
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
||||
|
||||
export default ArrayProxy.extend(PromiseProxyMixin);
|
||||
Reference in New Issue
Block a user