FEATURE: Add new site setting type for tag-group lists (#21993)

* FEATURE: Add new site setting type for tag-group lists
This commit is contained in:
Jean 2023-06-09 11:02:55 -04:00 committed by GitHub
parent b3bb3872cf
commit b2aa411436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<TagGroupChooser
@tagGroups={{this.selectedTagGroups}}
@onChange={{action "onTagGroupChange"}}
@options={{hash filterPlaceholder="category.required_tag_group.placeholder"}}
/>
<div class="desc">{{html-safe this.setting.description}}</div>
<SettingValidationMessage @message={{this.validationMessage}} />

View File

@ -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("|"));
}
}

View File

@ -27,6 +27,7 @@ const CUSTOM_TYPES = [
"upload",
"group_list",
"tag_list",
"tag_group_list",
"color",
"simple_list",
"emoji_list",

View File

@ -54,6 +54,7 @@ class SiteSettings::TypeSupervisor
simple_list: 23,
emoji_list: 24,
html_deprecated: 25,
tag_group_list: 26,
)
end

View File

@ -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