diff -r ac6928e86d14 -r 69a9f3687902 cms/app-client/app/routes/tabs/thematiques.js --- a/cms/app-client/app/routes/tabs/thematiques.js Sat Jul 09 00:59:32 2016 +0200 +++ b/cms/app-client/app/routes/tabs/thematiques.js Tue Jul 12 09:48:11 2016 +0200 @@ -2,16 +2,49 @@ export default Ember.Route.extend({ - page: 0, - limit: 40, - sort: 'alphabetical', + index: 0, + limit: 40, + sort: 'alphabetical', + + themes: [], + + model: Ember.observer('index', function() { + var self = this; + var promise = this.store.query('theme', { + 'limit': this.get('limit'), + 'index': this.get('index'), + 'sort': this.get('sort') + }); + promise.then(function(value) { + if (self.get('themes').length) { + value = self.get('themes').pushObjects(value.get('content')); + } + self.set('themes', value); + }) + return promise; + }), - model: function() { - return this.store.query('theme', { - 'limit': this.get('limit'), - 'page': this.get('page'), - 'sort': this.get('sort') - }); + setupController: function(controller, model) { + this._super(...arguments); + // Add ArrayProxy to template context. + controller.set('themes', this.get('themes')); + }, + + actions: { + + setIndexQueryparams: function() { + this.set('index', this.get('index') + 1); + }, + + setSortQueryparams: function(sort) { + this.set('sort', sort); + this.get('themes').replaceContent(0, this.get('themes').get('content').length, null); + // Force property reset to trigger request. + this.propertyWillChange('index'); + this.set('index', 0); + this.propertyDidChange('index'); + } + } });