Replace refreshModel with a custom property

This commit is contained in:
Robin Ward
2015-03-19 17:16:21 -04:00
parent 8bc5de665b
commit 9e13067be0
2 changed files with 11 additions and 11 deletions

View File

@ -2,15 +2,20 @@ import showModal from 'discourse/lib/show-modal';
const DiscourseRoute = Ember.Route.extend({ const DiscourseRoute = Ember.Route.extend({
refreshModel: null, // Set to true to refresh a model without a transition if a query param
// changes
resfreshQueryWithoutTransition: false,
refresh: function() { refresh: function() {
// Implement `refreshModel` to avoid a full transition to ourselves if (!this.refreshQueryWithoutTransition) { return this._super(); }
if (!this.refreshModel) { return this._super(); }
if (!this.router.router.activeTransition) { if (!this.router.router.activeTransition) {
const params = this.controller.getProperties(Object.keys(this.queryParams)); const controller = this.controller,
this.refreshModel(params); model = controller.get('model'),
params = this.controller.getProperties(Object.keys(this.queryParams));
model.set('loading', true);
this.model(params).then(model => this.setupController(controller, model));
} }
}, },

View File

@ -5,12 +5,7 @@ export default Discourse.Route.extend({
asc: { refreshModel: true } asc: { refreshModel: true }
}, },
refreshModel(params) { refreshQueryWithoutTransition: true,
const controller = this.controllerFor('users');
controller.set('model.loading', true);
this.model(params).then(model => this.setupController(controller, model));
},
model(params) { model(params) {
// If we refresh via `refreshModel` set the old model to loading // If we refresh via `refreshModel` set the old model to loading