Skip to content

Commit

Permalink
Fix infinite pagination not updating list component when receiving ne…
Browse files Browse the repository at this point in the history
…w data
  • Loading branch information
Florian FERBACH committed Feb 26, 2018
1 parent e3a49fe commit bca5abb
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/javascripts/ng-admin/Crud/list/ListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class ListController {

const references = view.getReferences();
let data;
const toAddToDatastore = [];

let queryPromise = this.ReadQueries
.getAll(view, page, this.search, this.sortField, this.sortDir)
Expand All @@ -63,20 +64,30 @@ export default class ListController {
[references[name].targetField()],
references[name].targetEntity().name(),
references[name].targetEntity().identifier().name()
).map(entry => dataStore.addEntry(references[name].targetEntity().uniqueId + '_values', entry));
).map(entry => {
toAddToDatastore.push([
references[name].targetEntity().uniqueId + '_values',
entry
])
});
}
})
});
this.queryPromises.push(queryPromise);
// make sure all preceding promises complete before loading data into store
Promise.all(this.queryPromises)
.then(() => {
view.mapEntries(data)
.map(entry => {
dataStore.fillReferencesValuesFromEntry(entry, references, true);
dataStore.addEntry(this.entity.uniqueId, entry);
this.$scope.$apply(() => {
toAddToDatastore.map((args) => {
this.dataStore.addEntry(...args);
});

this.loadingPage = false;
view.mapEntries(data)
.map(entry => {
this.dataStore.fillReferencesValuesFromEntry(entry, references, true);
this.dataStore.addEntry(this.entity.uniqueId, entry);
});
this.loadingPage = false;
});
});
}

Expand Down

0 comments on commit bca5abb

Please sign in to comment.