This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/edit-category-settings.js.es6
Dan Ungureanu c7a8bbd6a5
FIX: Show category list on subcategory page if it has subcategories too (#8768)
The category list was displayed only for top level categories, which
had no parent.
2020-01-22 20:27:30 +02:00

111 lines
2.9 KiB
JavaScript

import discourseComputed from "discourse-common/utils/decorators";
import { empty, and } from "@ember/object/computed";
import { setting } from "discourse/lib/computed";
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
import { searchPriorities } from "discourse/components/concerns/category-search-priorities";
import Group from "discourse/models/group";
const categorySortCriteria = [];
export function addCategorySortCriteria(criteria) {
categorySortCriteria.push(criteria);
}
export default buildCategoryPanel("settings", {
emailInEnabled: setting("email_in"),
showPositionInput: setting("fixed_category_positions"),
@discourseComputed("category.isParent", "category.parent_category_id")
isParentCategory(isParent, parentCategoryId) {
return isParent || !parentCategoryId;
},
showSubcategoryListStyle: and(
"category.show_subcategory_list",
"isParentCategory"
),
isDefaultSortOrder: empty("category.sort_order"),
@discourseComputed
availableSubcategoryListStyles() {
return [
{ name: I18n.t("category.subcategory_list_styles.rows"), value: "rows" },
{
name: I18n.t(
"category.subcategory_list_styles.rows_with_featured_topics"
),
value: "rows_with_featured_topics"
},
{
name: I18n.t("category.subcategory_list_styles.boxes"),
value: "boxes"
},
{
name: I18n.t(
"category.subcategory_list_styles.boxes_with_featured_topics"
),
value: "boxes_with_featured_topics"
}
];
},
groupFinder(term) {
return Group.findAll({ term, ignore_automatic: true });
},
@discourseComputed
availableViews() {
return [
{ name: I18n.t("filters.latest.title"), value: "latest" },
{ name: I18n.t("filters.top.title"), value: "top" }
];
},
@discourseComputed
availableTopPeriods() {
return ["all", "yearly", "quarterly", "monthly", "weekly", "daily"].map(
p => {
return { name: I18n.t(`filters.top.${p}.title`), value: p };
}
);
},
@discourseComputed
searchPrioritiesOptions() {
const options = [];
Object.entries(searchPriorities).forEach(entry => {
const [name, value] = entry;
options.push({
name: I18n.t(`category.search_priority.options.${name}`),
value
});
});
return options;
},
@discourseComputed
availableSorts() {
return [
"likes",
"op_likes",
"views",
"posts",
"activity",
"posters",
"category",
"created"
]
.concat(categorySortCriteria)
.map(s => ({ name: I18n.t("category.sort_options." + s), value: s }))
.sort((a, b) => a.name.localeCompare(b.name));
},
@discourseComputed
sortAscendingOptions() {
return [
{ name: I18n.t("category.sort_ascending"), value: "true" },
{ name: I18n.t("category.sort_descending"), value: "false" }
];
}
});