FEATURE: category setting for default list filter.

This commit is contained in:
Vinoth Kannan 2020-05-25 00:04:06 +05:30
parent 058bf56b4c
commit 6f03d14c23
5 changed files with 33 additions and 1 deletions

View File

@ -68,6 +68,13 @@ export default buildCategoryPanel("settings", {
);
},
@discourseComputed
availableListFilters() {
return ["all", "none"].map(p => {
return { name: I18n.t(`category.list_filters.${p}`), value: p };
});
},
@discourseComputed
searchPrioritiesOptions() {
const options = [];

View File

@ -187,7 +187,8 @@ const Category = RestModel.extend({
),
search_priority: this.search_priority,
reviewable_by_group_name: this.reviewable_by_group_name,
read_only_banner: this.read_only_banner
read_only_banner: this.read_only_banner,
default_list_filter: this.default_list_filter
},
type: id ? "PUT" : "POST"
});

View File

@ -196,6 +196,22 @@
{{/unless}}
</div>
</section>
<section class="field">
<label for="category-default-filter">
{{i18n "category.default_list_filter"}}
</label>
<div class="controls">
{{combo-box
id="category-default-filter"
valueProperty="value"
content=availableListFilters
value=category.default_list_filter
none="category.list_filters.all"
}}
</div>
</section>
{{#if isParentCategory}}
<section class="field show-subcategory-list-field">
<label>

View File

@ -329,6 +329,7 @@ class CategoriesController < ApplicationController
:required_tag_group_name,
:min_tags_from_required_group,
:read_only_banner,
:default_list_filter,
custom_fields: [params[:custom_fields].try(:keys)],
permissions: [*p.try(:keys)],
allowed_tags: [],

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddDefaultListFilterToCategories < ActiveRecord::Migration[6.0]
def change
add_column :categories, :default_list_filter, :string, limit: 20, default: 'all'
end
end