Skip to content

Commit

Permalink
allow a DS.RecordArray to be used with paginated routes
Browse files Browse the repository at this point in the history
  • Loading branch information
billdami committed Jul 10, 2019
1 parent 3583923 commit fc4def3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addon/decorators/route-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { PaginationController, buildQueryParams } from '@gavant/ember-pagination
export default function routePagination<T extends ConcreteSubclass<any>>(RouteSubclass: T) {
class PaginationRoute extends RouteSubclass {
setupController(controller: PaginationController, model: any) {
assert('Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray which comes from using store.query', model instanceof DS.AdapterPopulatedRecordArray);
assert(
'Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray or DS.RecordArray which comes from using store.query',
model instanceof DS.AdapterPopulatedRecordArray || model instanceof DS.RecordArray
);

setProperties(controller, {
modelName: model.type.modelName,
Expand Down
6 changes: 5 additions & 1 deletion addon/mixins/route-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default Mixin.create({
* @param model - The result returned from a `store.query`
*/
setupController(controller: PaginationController, model: any) {
assert('Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray which comes from using store.query', model instanceof DS.AdapterPopulatedRecordArray);
assert(
'Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray or DS.RecordArray which comes from using store.query',
model instanceof DS.AdapterPopulatedRecordArray || model instanceof DS.RecordArray
);

setProperties(controller, {
modelName: get(model, 'type.modelName'),
metadata: get(model, 'meta'),
Expand Down

0 comments on commit fc4def3

Please sign in to comment.