Fixes issue regarding allocation rows

Sometimes the job name and/or task group name wouldn't show up.
This commit is contained in:
Michael Lange 2017-10-05 15:21:10 -07:00
parent 0941c7bec1
commit 4e606e435d
3 changed files with 36 additions and 10 deletions

View file

@ -1,9 +1,11 @@
import Ember from 'ember';
import { lazyClick } from '../helpers/lazy-click';
const { Component } = Ember;
const { Component, inject } = Ember;
export default Component.extend({
store: inject.service(),
tagName: 'tr',
classNames: ['allocation-row', 'is-interactive'],
@ -20,17 +22,35 @@ export default Component.extend({
},
didReceiveAttrs() {
// TODO: Use this code again once the temporary workaround below
// is resolved.
// If the job for this allocation is incomplete, reload it to get
// detailed information.
// const allocation = this.get('allocation');
// if (
// allocation &&
// allocation.get('job') &&
// !allocation.get('job.isPending') &&
// !allocation.get('taskGroup')
// ) {
// const job = allocation.get('job.content');
// job && job.reload();
// }
// TEMPORARY: https://github.com/emberjs/data/issues/5209
// Ember Data doesn't like it when relationships aren't reflective,
// which means the allocation's job will be null if it hasn't been
// resolved through the allocation (allocation.get('job')) before
// being resolved through the store (store.findAll('job')). The
// workaround is to persist the jobID as a string on the allocation
// and manually re-link the two records here.
const allocation = this.get('allocation');
if (
allocation &&
allocation.get('job') &&
!allocation.get('job.isPending') &&
!allocation.get('taskGroup')
) {
const job = allocation.get('job.content');
job && job.reload();
}
this.get('store')
.findRecord('job', allocation.get('originalJobId'))
.then(job => {
allocation.set('job', job);
});
},
});

View file

@ -19,6 +19,9 @@ export default Model.extend({
resources: fragment('resources'),
modifyIndex: attr('number'),
// TEMPORARY: https://github.com/emberjs/data/issues/5209
originalJobId: attr('string'),
clientStatus: attr('string'),
desiredStatus: attr('string'),

View file

@ -20,6 +20,9 @@ export default ApplicationSerializer.extend({
return summary;
});
// TEMPORARY: https://github.com/emberjs/data/issues/5209
hash.OriginalJobId = hash.JobID;
return this._super(typeHash, hash);
},
});