FIX: show group filter only when user is logged in and groups are present (#14578)
This commit is contained in:
parent
b44119cdb2
commit
d2f9108470
|
@ -3,7 +3,7 @@ import Group from "discourse/models/group";
|
|||
import { action } from "@ember/object";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { equal } from "@ember/object/computed";
|
||||
import { and, equal } from "@ember/object/computed";
|
||||
import { longDate } from "discourse/lib/formatter";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
|
||||
|
@ -19,8 +19,9 @@ export default Controller.extend({
|
|||
exclude_usernames: null,
|
||||
isLoading: false,
|
||||
columns: null,
|
||||
groupsOptions: null,
|
||||
groupOptions: null,
|
||||
params: null,
|
||||
showGroupFilter: and("currentUser", "groupOptions"),
|
||||
|
||||
showTimeRead: equal("period", "all"),
|
||||
|
||||
|
@ -66,15 +67,17 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
loadGroups() {
|
||||
return Group.findAll({ ignore_automatic: true }).then((groups) => {
|
||||
const groupOptions = groups.map((group) => {
|
||||
return {
|
||||
name: group.full_name || group.name,
|
||||
id: group.name,
|
||||
};
|
||||
if (this.currentUser) {
|
||||
return Group.findAll({ ignore_automatic: true }).then((groups) => {
|
||||
const groupOptions = groups.map((group) => {
|
||||
return {
|
||||
name: group.full_name || group.name,
|
||||
id: group.name,
|
||||
};
|
||||
});
|
||||
this.set("groupOptions", groupOptions);
|
||||
});
|
||||
this.set("groupOptions", groupOptions);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
|
|
|
@ -25,15 +25,17 @@
|
|||
placeholderKey="directory.filter_name"
|
||||
class="filter-name no-blur"
|
||||
}}
|
||||
{{combo-box
|
||||
class="directory-group-selector"
|
||||
value=group
|
||||
content=groupOptions
|
||||
onChange=(action groupChanged)
|
||||
options=(hash
|
||||
none="directory.group.all"
|
||||
)
|
||||
}}
|
||||
{{#if showGroupFilter}}
|
||||
{{combo-box
|
||||
class="directory-group-selector"
|
||||
value=group
|
||||
content=groupOptions
|
||||
onChange=(action groupChanged)
|
||||
options=(hash
|
||||
none="directory.group.all"
|
||||
)
|
||||
}}
|
||||
{{/if}}
|
||||
{{#if currentUser.staff}}
|
||||
{{d-button
|
||||
icon="wrench"
|
||||
|
|
Loading…
Reference in New Issue