Commit 2f6eb0c

mo khan <mo@mokhan.ca>
2014-11-26 03:29:42
move pagination to controller.
1 parent 6a432a5
Changed files (6)
app
controllers
routes
templates
tests
unit
controllers
routes
app/controllers/cakes/index.js
@@ -0,0 +1,15 @@
+import Ember from 'ember';
+
+export default Ember.ArrayController.extend({
+  page: 1,
+  perPage: 18,
+  actions: {
+    nextPage: function(){
+      this.set('perPage', this.get('perPage') + 18);
+      var that = this;
+      this.store.find('cake', { page: 1, per_page: this.get('perPage') }).then(function(cakes){
+        that.set('content', cakes);
+      });
+    },
+  },
+});
app/routes/cakes/index.js
@@ -1,17 +1,6 @@
 import Ember from 'ember';
 
 export default Ember.Route.extend({
-  page: 1,
-  perPage: 12,
-  actions: {
-    nextPage: function(){
-      this.set('perPage', this.get('perPage') + 12);
-      var that = this;
-      this.store.find('cake', { page: 1, per_page: this.get('perPage') }).then(function(cakes){
-        that.controllerFor('cakes.index').set('content', cakes);
-      });
-    },
-  },
   model: function(params) {
     return this.store.find('cake', params);
   },
app/routes/index.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+  beforeModel: function(){
+    this.transitionTo('cakes');
+  }
+});
app/templates/index.hbs
@@ -0,0 +1,1 @@
+{{outlet}}
tests/unit/controllers/cakes/index-test.js
@@ -0,0 +1,15 @@
+import {
+  moduleFor,
+  test
+} from 'ember-qunit';
+
+moduleFor('controller:cakes/index', 'CakesIndexController', {
+  // Specify the other units that are required for this test.
+  // needs: ['controller:foo']
+});
+
+// Replace this with your real tests.
+test('it exists', function() {
+  var controller = this.subject();
+  ok(controller);
+});
tests/unit/routes/index-test.js
@@ -0,0 +1,14 @@
+import {
+  moduleFor,
+  test
+} from 'ember-qunit';
+
+moduleFor('route:index', 'IndexRoute', {
+  // Specify the other units that are required for this test.
+  // needs: ['controller:foo']
+});
+
+test('it exists', function() {
+  var route = this.subject();
+  ok(route);
+});