Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] fix pagination #480

Merged
merged 2 commits into from
Jun 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/javascripts/ng-admin/Crud/list/ListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@ define(function () {
progression.start();

this.ReadQueries
.getAll(this.view, page, true, this.search, this.sortField, this.sortDir)
.then(function (nextData) {
.getAll(this.view, page, this.search, this.sortField, this.sortDir)
.then(function (response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to fix parameters passed to getAllmethod. The third one (true) does not exists anymore.

progression.done();
self.entries = self.entries.concat(nextData.entries);
var references = self.view.getReferences();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to retrieve references and store them into the datastore.

See

nonOptimizedReferencedData: ['ReadQueries', 'view', 'response', function (ReadQueries, view, response) {
return ReadQueries.getFilteredReferenceData(view.getNonOptimizedReferences(), response.data);
}],
optimizedReferencedData: ['ReadQueries', 'view', 'response', function (ReadQueries, view, response) {
return ReadQueries.getOptimizedReferencedData(view.getOptimizedReferences(), response.data);
}],
referencedEntries: ['dataStore', 'view', 'nonOptimizedReferencedData', 'optimizedReferencedData', function (dataStore, view, nonOptimizedReferencedData, optimizedReferencedData) {
var references = view.getReferences(),
referencedData = angular.extend(nonOptimizedReferencedData, optimizedReferencedData),
referencedEntries;
for (var name in referencedData) {
referencedEntries = dataStore.mapEntries(
references[name].targetEntity().name(),
references[name].targetEntity().identifier(),
[references[name].targetField()],
referencedData[name]
);
dataStore.setEntries(
references[name].targetEntity().uniqueId + '_values',
referencedEntries
);
}
return true;
}],
entries: ['dataStore', 'view', 'response', 'referencedEntries', function (dataStore, view, response, referencedEntries) {
var entries = dataStore.mapEntries(
view.entity.name(),
view.identifier(),
view.getFields(),
response.data
);
// shortcut to diplay collection of entry with included referenced values
dataStore.fillReferencesValuesFromCollection(entries, view.getReferences(), true);
// set entries here ???
dataStore.setEntries(
view.getEntity().uniqueId,
entries
);
return true;
}],
.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure all of this is necessary. Because, on my project, the references were correctly retrieved, even the one that were not on the first page.
So it seems to me that the code in routing.js does the job, and don't need to be repeated.


self.dataStore.mapEntries(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to retrieve references before mapping and set entries to the datastore.

self.entity.name(),
self.view.identifier(),
self.fields,
response.data
).map(function (entry) {
self.dataStore.fillReferencesValuesFromEntry(entry, references, true);
self.dataStore.addEntry(self.entity.uniqueId, entry);
});

self.loadingPage = false;
});
};
Expand Down