DEV: Switch site-settings category-list component to gjs (#25569)

This commit is contained in:
Daniel Waterworth 2024-02-05 12:03:35 -06:00 committed by GitHub
parent 3159522546
commit a20bf843fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 22 deletions

View File

@ -0,0 +1,28 @@
import Component from "@ember/component";
import { action, computed } from "@ember/object";
import Category from "discourse/models/category";
import htmlSafe from "discourse-common/helpers/html-safe";
import SettingValidationMessage from "admin/components/setting-validation-message";
import CategorySelector from "select-kit/components/category-selector";
export default class CategoryList extends Component {
@computed("value")
get selectedCategories() {
return Category.findByIds(this.value.split("|").filter(Boolean));
}
@action
onChangeSelectedCategories(value) {
this.set("value", (value || []).mapBy("id").join("|"));
}
<template>
<CategorySelector
@categories={{this.selectedCategories}}
@onChange={{this.onChangeSelectedCategories}}
/>
<div class="desc">{{htmlSafe this.setting.description}}</div>
<SettingValidationMessage @message={{this.validationMessage}} />
</template>
}

View File

@ -1,7 +0,0 @@
<CategorySelector
@categories={{this.selectedCategories}}
@onChange={{this.onChangeSelectedCategories}}
/>
<div class="desc">{{html-safe this.setting.description}}</div>
<SettingValidationMessage @message={{this.validationMessage}} />

View File

@ -1,15 +0,0 @@
import Component from "@ember/component";
import { action, computed } from "@ember/object";
import Category from "discourse/models/category";
export default class CategoryList extends Component {
@computed("value")
get selectedCategories() {
return Category.findByIds(this.value.split("|").filter(Boolean));
}
@action
onChangeSelectedCategories(value) {
this.set("value", (value || []).mapBy("id").join("|"));
}
}