mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Show "no category" in category-chooser (#25917)
CategoryChooser component usually displays just categories, but sometimes it can show two none values: a "no category" or Uncategorized. This commit makes sure that these are rendered correctly. The problem was that the "none" item was automatically inserted in the list of options, but that should not always happen. Toggling option `autoInsertNoneItem` requires setting `none` too.
This commit is contained in:
@@ -12,12 +12,13 @@ import ComboBoxComponent from "select-kit/components/combo-box";
|
||||
export default ComboBoxComponent.extend({
|
||||
pluginApiIdentifiers: ["category-chooser"],
|
||||
classNames: ["category-chooser"],
|
||||
allowUncategorizedTopics: setting("allow_uncategorized_topics"),
|
||||
allowUncategorized: setting("allow_uncategorized_topics"),
|
||||
fixedCategoryPositionsOnCreate: setting("fixed_category_positions_on_create"),
|
||||
|
||||
selectKitOptions: {
|
||||
filterable: true,
|
||||
allowUncategorized: false,
|
||||
allowUncategorized: "allowUncategorized",
|
||||
autoInsertNoneItem: false,
|
||||
allowSubCategories: true,
|
||||
permissionType: PermissionType.FULL,
|
||||
excludeCategoryId: null,
|
||||
@@ -30,6 +31,7 @@ export default ComboBoxComponent.extend({
|
||||
|
||||
if (
|
||||
this.site.lazy_load_categories &&
|
||||
this.value &&
|
||||
!Category.hasAsyncFoundAll([this.value])
|
||||
) {
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -54,10 +56,7 @@ export default ComboBoxComponent.extend({
|
||||
I18n.t(isString ? this.selectKit.options.none : "category.none")
|
||||
)
|
||||
);
|
||||
} else if (
|
||||
this.allowUncategorizedTopics ||
|
||||
this.selectKit.options.allowUncategorized
|
||||
) {
|
||||
} else if (this.selectKit.options.allowUncategorized) {
|
||||
return Category.findUncategorized();
|
||||
} else {
|
||||
const defaultCategoryId = parseInt(
|
||||
@@ -94,8 +93,10 @@ export default ComboBoxComponent.extend({
|
||||
search(filter) {
|
||||
if (this.site.lazy_load_categories) {
|
||||
return Category.asyncSearch(this._normalize(filter), {
|
||||
scopedCategoryId: this.selectKit.options?.scopedCategoryId,
|
||||
prioritizedCategoryId: this.selectKit.options?.prioritizedCategoryId,
|
||||
includeUncategorized: this.selectKit.options.allowUncategorized,
|
||||
rejectCategoryIds: [this.selectKit.options.excludeCategoryId],
|
||||
scopedCategoryId: this.selectKit.options.scopedCategoryId,
|
||||
prioritizedCategoryId: this.selectKit.options.prioritizedCategoryId,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export default ComboBoxComponent.extend({
|
||||
navigateToEdit: false,
|
||||
editingCategory: false,
|
||||
editingCategoryTab: null,
|
||||
allowUncategorized: setting("allow_uncategorized_topics"),
|
||||
|
||||
selectKitOptions: {
|
||||
filterable: true,
|
||||
@@ -40,7 +41,7 @@ export default ComboBoxComponent.extend({
|
||||
displayCategoryDescription: "displayCategoryDescription",
|
||||
headerComponent: "category-drop/category-drop-header",
|
||||
parentCategory: false,
|
||||
allowUncategorized: setting("allow_uncategorized_topics"),
|
||||
allowUncategorized: "allowUncategorized",
|
||||
},
|
||||
|
||||
modifyComponentForRow() {
|
||||
|
||||
Reference in New Issue
Block a user