FIX: don't rerender whole users page while typing on input.
This commit is contained in:
parent
2acec4370b
commit
ef5320dd47
|
@ -2,6 +2,7 @@ import { equal } from "@ember/object/computed";
|
|||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import discourseDebounce from "discourse/lib/debounce";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
import { longDate } from "discourse/lib/formatter";
|
||||
|
||||
export default Controller.extend({
|
||||
application: controller(),
|
||||
|
@ -12,9 +13,29 @@ export default Controller.extend({
|
|||
name: "",
|
||||
group: null,
|
||||
exclude_usernames: null,
|
||||
isLoading: false,
|
||||
|
||||
showTimeRead: equal("period", "all"),
|
||||
|
||||
loadUsers(params) {
|
||||
this.set("isLoading", true);
|
||||
|
||||
this.store
|
||||
.find("directoryItem", params)
|
||||
.then(model => {
|
||||
const lastUpdatedAt = model.get("resultSetMeta.last_updated_at");
|
||||
this.setProperties({
|
||||
model,
|
||||
lastUpdatedAt: lastUpdatedAt ? longDate(lastUpdatedAt) : null,
|
||||
period: params.period,
|
||||
nameInput: params.name
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
this.set("isLoading", false);
|
||||
});
|
||||
},
|
||||
|
||||
@observes("nameInput")
|
||||
_setName: discourseDebounce(function() {
|
||||
this.set("name", this.nameInput);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import I18n from "I18n";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { longDate } from "discourse/lib/formatter";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
|
@ -37,20 +36,11 @@ export default DiscourseRoute.extend({
|
|||
},
|
||||
|
||||
model(params) {
|
||||
// If we refresh via `refreshModel` set the old model to loading
|
||||
this._params = params;
|
||||
return this.store.find("directoryItem", params);
|
||||
return params;
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
const params = this._params;
|
||||
const lastUpdatedAt = model.get("resultSetMeta.last_updated_at");
|
||||
controller.setProperties({
|
||||
model,
|
||||
lastUpdatedAt: lastUpdatedAt ? longDate(lastUpdatedAt) : null,
|
||||
period: params.period,
|
||||
nameInput: params.name
|
||||
});
|
||||
setupController(controller, params) {
|
||||
controller.loadUsers(params);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
{{text-field value=nameInput placeholderKey="directory.filter_name" class="filter-name no-blur"}}
|
||||
</div>
|
||||
|
||||
{{#conditional-loading-spinner condition=model.loading}}
|
||||
{{#conditional-loading-spinner condition=isLoading}}
|
||||
{{#if model.length}}
|
||||
|
||||
<table>
|
||||
|
|
Loading…
Reference in New Issue