From b2aa4114363799ba34317094894f3334cffa5702 Mon Sep 17 00:00:00 2001 From: Jean Date: Fri, 9 Jun 2023 11:02:55 -0400 Subject: [PATCH] FEATURE: Add new site setting type for tag-group lists (#21993) * FEATURE: Add new site setting type for tag-group lists --- .../components/site-settings/tag-group-list.hbs | 7 +++++++ .../components/site-settings/tag-group-list.js | 15 +++++++++++++++ .../admin/addon/mixins/setting-component.js | 1 + lib/site_settings/type_supervisor.rb | 1 + spec/lib/site_settings/type_supervisor_spec.rb | 3 +++ 5 files changed, 27 insertions(+) create mode 100644 app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.hbs create mode 100644 app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.js diff --git a/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.hbs b/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.hbs new file mode 100644 index 00000000000..475a9fcf365 --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.hbs @@ -0,0 +1,7 @@ + +
{{html-safe this.setting.description}}
+ \ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.js b/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.js new file mode 100644 index 00000000000..5d11c75027f --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/site-settings/tag-group-list.js @@ -0,0 +1,15 @@ +import Component from "@ember/component"; +import { action } from "@ember/object"; +import discourseComputed from "discourse-common/utils/decorators"; + +export default class TagGroupList extends Component { + @discourseComputed("value") + selectedTagGroups(value) { + return value.split("|").filter(Boolean); + } + + @action + onTagGroupChange(tagGroups) { + this.set("value", tagGroups.join("|")); + } +} diff --git a/app/assets/javascripts/admin/addon/mixins/setting-component.js b/app/assets/javascripts/admin/addon/mixins/setting-component.js index f54f179046b..fa1675ce542 100644 --- a/app/assets/javascripts/admin/addon/mixins/setting-component.js +++ b/app/assets/javascripts/admin/addon/mixins/setting-component.js @@ -27,6 +27,7 @@ const CUSTOM_TYPES = [ "upload", "group_list", "tag_list", + "tag_group_list", "color", "simple_list", "emoji_list", diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rb index a13797e1f91..db4bfa054a1 100644 --- a/lib/site_settings/type_supervisor.rb +++ b/lib/site_settings/type_supervisor.rb @@ -54,6 +54,7 @@ class SiteSettings::TypeSupervisor simple_list: 23, emoji_list: 24, html_deprecated: 25, + tag_group_list: 26, ) end diff --git a/spec/lib/site_settings/type_supervisor_spec.rb b/spec/lib/site_settings/type_supervisor_spec.rb index 59400f49207..45bd084d93f 100644 --- a/spec/lib/site_settings/type_supervisor_spec.rb +++ b/spec/lib/site_settings/type_supervisor_spec.rb @@ -95,6 +95,9 @@ RSpec.describe SiteSettings::TypeSupervisor do it "'emoji_list' should be at the right position" do expect(SiteSettings::TypeSupervisor.types[:emoji_list]).to eq(24) end + it "'tag_group_list' should be at the right position" do + expect(SiteSettings::TypeSupervisor.types[:tag_group_list]).to eq(26) + end end end