Skip to content

A platform for community discussion. Free, open, simple.

FIX: register customOptions as select kit filter (#14933)

Krzysztof Kotlarek9ce29ad0135e
diff --git a/app/assets/javascripts/select-kit/addon/components/user-chooser.js b/app/assets/javascripts/select-kit/addon/components/user-chooser.js
index a364c046e2c..b8651248ed1 100644
--- a/app/assets/javascripts/select-kit/addon/components/user-chooser.js
+++ b/app/assets/javascripts/select-kit/addon/components/user-chooser.js
@@ -4,6 +4,7 @@ import userSearch, {
} from "discourse/lib/user-search";
import MultiSelectComponent from "select-kit/components/multi-select";
import { computed } from "@ember/object";
+import { isPresent } from "@ember/utils";
import { makeArray } from "discourse-common/lib/helpers";
export const CUSTOM_USER_SEARCH_OPTIONS = [];
@@ -27,6 +28,7 @@ export default MultiSelectComponent.extend({
allowEmails: false,
groupMembersOf: undefined,
excludeCurrentUser: false,
+ customSearchOptions: undefined,
},
content: computed("value.[]", function () {
@@ -66,15 +68,18 @@ export default MultiSelectComponent.extend({
return;
}
- let customUserSearchOptions = CUSTOM_USER_SEARCH_OPTIONS.reduce(
- (obj, option) => {
- return {
- ...obj,
- [option]: options[option],
- };
- },
- {}
- );
+ let customUserSearchOptions = {};
+ if (options.customSearchOptions && isPresent(CUSTOM_USER_SEARCH_OPTIONS)) {
+ customUserSearchOptions = CUSTOM_USER_SEARCH_OPTIONS.reduce(
+ (obj, option) => {
+ return {
+ ...obj,
+ [option]: options.customSearchOptions[option],
+ };
+ },
+ {}
+ );
+ }
return userSearch({
term: filter,