mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: per-category default topic list sort order
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
import { setting } from 'discourse/lib/computed';
|
||||
import { buildCategoryPanel } from 'discourse/components/edit-category-panel';
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default buildCategoryPanel('settings', {
|
||||
emailInEnabled: setting('email_in'),
|
||||
showPositionInput: setting('fixed_category_positions'),
|
||||
|
||||
isDefaultSortOrder: Em.computed.empty('category.sort_order'),
|
||||
|
||||
@computed
|
||||
availableSorts() {
|
||||
return ['likes', 'op_likes', 'views', 'posts', 'activity', 'posters', 'category', 'created']
|
||||
.map(s => ({ name: I18n.t('category.sort_options.' + s), value: s }))
|
||||
.sort((a,b) => { return a.name > b.name; });
|
||||
},
|
||||
|
||||
@computed
|
||||
sortAscendingOptions() {
|
||||
return [
|
||||
{name: I18n.t('category.sort_ascending'), value: 'true'},
|
||||
{name: I18n.t('category.sort_descending'), value: 'false'}
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -98,7 +98,9 @@ const Category = RestModel.extend({
|
||||
topic_template: this.get('topic_template'),
|
||||
suppress_from_homepage: this.get('suppress_from_homepage'),
|
||||
allowed_tags: this.get('allowed_tags'),
|
||||
allowed_tag_groups: this.get('allowed_tag_groups')
|
||||
allowed_tag_groups: this.get('allowed_tag_groups'),
|
||||
sort_order: this.get('sort_order'),
|
||||
sort_ascending: this.get('sort_ascending')
|
||||
},
|
||||
type: id ? 'PUT' : 'POST'
|
||||
});
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section class="field">
|
||||
<label>
|
||||
{{i18n "category.sort_order"}}
|
||||
{{combo-box valueAttribute="value" content=availableSorts value=category.sort_order none="category.sort_options.default"}}
|
||||
{{#unless isDefaultSortOrder}}
|
||||
{{combo-box valueAttribute="value" content=sortAscendingOptions value=category.sort_ascending none="category.sort_options.default"}}
|
||||
{{/unless}}
|
||||
</label>
|
||||
</section>
|
||||
|
||||
{{#if emailInEnabled}}
|
||||
<section class='field'>
|
||||
<label>
|
||||
|
||||
@@ -238,6 +238,8 @@ class CategoriesController < ApplicationController
|
||||
:slug,
|
||||
:allow_badges,
|
||||
:topic_template,
|
||||
:sort_order,
|
||||
:sort_ascending,
|
||||
:custom_fields => [params[:custom_fields].try(:keys)],
|
||||
:permissions => [*p.try(:keys)],
|
||||
:allowed_tags => [],
|
||||
|
||||
@@ -536,6 +536,8 @@ end
|
||||
# topic_template :text
|
||||
# suppress_from_homepage :boolean default(FALSE)
|
||||
# contains_messages :boolean
|
||||
# sort_order :string
|
||||
# sort_ascending :boolean
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
||||
@@ -19,7 +19,9 @@ class BasicCategorySerializer < ApplicationSerializer
|
||||
:notification_level,
|
||||
:can_edit,
|
||||
:topic_template,
|
||||
:has_children
|
||||
:has_children,
|
||||
:sort_order,
|
||||
:sort_ascending
|
||||
|
||||
def include_parent_category_id?
|
||||
parent_category_id
|
||||
|
||||
Reference in New Issue
Block a user