--- a/cms/app-client/app/routes/application.js Thu Nov 10 15:35:27 2016 +0100
+++ b/cms/app-client/app/routes/application.js Sat Nov 12 17:21:25 2016 +0100
@@ -9,12 +9,21 @@
filter: Ember.inject.service(),
constants: Ember.inject.service(),
- model: function(params) {
- let filterQueryArgs = _.clone(this.get('filter').get('queryParamsValues'));
- return this.store.query('document', _.merge(filterQueryArgs, {
- page: params['page'],
- perpage: this.get('constants').DOCUMENTS_PAGINATION_PERPAGE
- }));
+ model: function(params, transition) {
+ if(transition.targetName === 'document') {
+ let documentId = transition.params['document']['doc_id'];
+ return this.store.query('document', {
+ id: documentId,
+ page: 1,
+ perpage: this.get('constants').DOCUMENTS_PAGINATION_PERPAGE
+ });
+ } else {
+ let filterQueryArgs = _.clone(this.get('filter').get('queryParamsValues'));
+ return this.store.query('document', _.merge(filterQueryArgs, {
+ page: params['page'],
+ perpage: this.get('constants').DOCUMENTS_PAGINATION_PERPAGE
+ }));
+ }
},
/**
@@ -48,12 +57,12 @@
},
beforeModel: function(transition) {
- new RSVP.Promise((resolve) => {
+ return new RSVP.Promise((resolve) => {
// succeed
this.get('filter').setProperties(transition['queryParams']);
resolve();
});
- return this._super(...arguments);
+ //return this._super(...arguments);
},
queryParams: Ember.computed('filter', function() {
@@ -71,6 +80,12 @@
controller.set('isLoading', false);
});
},
+ willTransition: function(transition) {
+ if(this.controller.currentPath === 'document' || transition.targetName === 'document') {
+ this.refresh();
+ }
+ return true;
+ },
didTransition: function() {
// Append body classname depending on the route