FEATURE: each category can control how many topics to show on categories page

This commit is contained in:
Neil Lalonde
2017-03-01 12:03:12 -05:00
parent ca951f2cf2
commit 262016604d
44 changed files with 71 additions and 105 deletions

View File

@@ -70,7 +70,7 @@ const Category = RestModel.extend({
@computed("topic_count")
moreTopics(topicCount) {
return topicCount > Discourse.SiteSettings.category_featured_topics;
return topicCount > (this.get('num_featured_topics') || 2);
},
save() {
@@ -103,7 +103,8 @@ const Category = RestModel.extend({
sort_order: this.get('sort_order'),
sort_ascending: this.get('sort_ascending'),
topic_featured_link_allowed: this.get('topic_featured_link_allowed'),
show_subcategory_list: this.get('show_subcategory_list')
show_subcategory_list: this.get('show_subcategory_list'),
num_featured_topics: this.get('num_featured_topics')
},
type: id ? 'PUT' : 'POST'
});
@@ -149,7 +150,7 @@ const Category = RestModel.extend({
@computed("topics")
featuredTopics(topics) {
if (topics && topics.length) {
return topics.slice(0, Discourse.SiteSettings.category_featured_topics || 2);
return topics.slice(0, this.get('num_featured_topics') || 2);
}
},

View File

@@ -75,8 +75,17 @@
{{plugin-outlet name="category-email-in" args=(hash category=category)}}
{{/if}}
{{#unless category.parent_category_id}}
<section class="field num-featured-topics-fields">
<label>
{{i18n "category.num_featured_topics"}}
{{text-field value=category.num_featured_topics}}
</label>
</section>
{{/unless}}
{{#if showPositionInput}}
<section class='field'>
<section class='field position-fields'>
<label>
{{i18n 'category.position'}}
{{text-field value=category.position class="position-input"}}