From a69839689da85f29ff697969e225f81f20b9eede Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Tue, 29 Jun 2021 16:29:25 +1000 Subject: [PATCH] FEATURE: add multiselect user custom field (#13560) New user custom field similar to dropdown but allowing users to select multiple options. --- .../admin/addon/models/user-field.js | 1 + .../components/user-fields/multiselect.hbs | 19 +++++++++++++++++++ config/locales/client.en.yml | 1 + 3 files changed, 21 insertions(+) create mode 100644 app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs diff --git a/app/assets/javascripts/admin/addon/models/user-field.js b/app/assets/javascripts/admin/addon/models/user-field.js index 495be7a08d0..53b92a63fd9 100644 --- a/app/assets/javascripts/admin/addon/models/user-field.js +++ b/app/assets/javascripts/admin/addon/models/user-field.js @@ -15,6 +15,7 @@ UserField.reopenClass({ UserFieldType.create({ id: "text" }), UserFieldType.create({ id: "confirm" }), UserFieldType.create({ id: "dropdown", hasOptions: true }), + UserFieldType.create({ id: "multiselect", hasOptions: true }), ]; } diff --git a/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs b/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs new file mode 100644 index 00000000000..f81fa36fd43 --- /dev/null +++ b/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs @@ -0,0 +1,19 @@ + + +
+ {{multi-select + id=(concat "user-" this.elementId) + content=this.field.options + valueProperty=null + nameProperty=null + value=this.value + none=this.noneLabel + onChange=(action (mut this.value)) + }} +
{{html-safe this.field.description}}
+
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7b2b26969db..6d3f72afabd 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5095,6 +5095,7 @@ en: text: "Text Field" confirm: "Confirmation" dropdown: "Dropdown" + multiselect: "Multiselect" site_text: description: "You can customize any of the text on your forum. Please start by searching below:"