hummingbird-me/hummingbird

View on GitHub
frontend/app/routes/edits.js

Summary

Maintainability
A
0 mins
Test Coverage
import Ember from 'ember';
import Paginated from '../mixins/paginated';
import setTitle from '../utils/set-title';

export default Ember.Route.extend(Paginated, {
  preloadKey: "versions",
  preloadPath: "versions",
  preloadObject: "version",

  fetchPage: function(page) {
    return this.store.find('version', {
      state: 'pending',
      page: page
    });
  },

  afterModel: function() {
    setTitle('Pending Edits');
  },

  setupController: function(controller, model) {
    this.setCanLoadMore(true);
    controller.set('model', model);
    if (model.get('length') === 0) {
      this.set('cursor', null);
      this.loadNextPage();
    }
  }
});