Treat filtering on an async relationship as async

This commit is contained in:
Michael Lange
2018-07-20 14:29:51 -07:00
parent 5fff8e1c9a
commit f50aff562c
2 changed files with 13 additions and 4 deletions

View File

@@ -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: {

View File

@@ -0,0 +1,4 @@
import ArrayProxy from '@ember/array/proxy';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
export default ArrayProxy.extend(PromiseProxyMixin);