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>
|
||||
|
||||
Reference in New Issue
Block a user