mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
Replace refreshModel
with a custom property
This commit is contained in:
@ -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));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user