diff --git a/app/assets/javascripts/discourse/components/categories-boxes.js.es6 b/app/assets/javascripts/discourse/components/categories-boxes.js.es6 new file mode 100644 index 00000000000..c4603a8235d --- /dev/null +++ b/app/assets/javascripts/discourse/components/categories-boxes.js.es6 @@ -0,0 +1,11 @@ +import computed from 'ember-addons/ember-computed-decorators'; + +export default Ember.Component.extend({ + tagName: "section", + classNameBindings: [':category-boxes', 'anyLogos:with-logos:no-logos'], + + @computed('categories.[].uploaded_logo.url') + anyLogos() { + return this.get("categories").any((c) => { return !Ember.isEmpty(c.get('uploaded_logo.url')); }); + } +}); diff --git a/app/assets/javascripts/discourse/components/edit-category-panel.js.es6 b/app/assets/javascripts/discourse/components/edit-category-panel.js.es6 index 5cf7a0e1f8f..470dc5237fe 100644 --- a/app/assets/javascripts/discourse/components/edit-category-panel.js.es6 +++ b/app/assets/javascripts/discourse/components/edit-category-panel.js.es6 @@ -1,11 +1,10 @@ -const EditCategoryPanel = Ember.Component.extend({ - classNameBindings: [':modal-tab', 'activeTab::invisible'], -}); +const EditCategoryPanel = Ember.Component.extend({}); export default EditCategoryPanel; export function buildCategoryPanel(tab, extras) { return EditCategoryPanel.extend({ - activeTab: Ember.computed.equal('selectedTab', tab) + activeTab: Ember.computed.equal('selectedTab', tab), + classNameBindings: [':modal-tab', 'activeTab::invisible', `:edit-category-tab-${tab}`] }, extras || {}); } diff --git a/app/assets/javascripts/discourse/components/edit-category-settings.js.es6 b/app/assets/javascripts/discourse/components/edit-category-settings.js.es6 index f1b089ac1ae..4a384fe5857 100644 --- a/app/assets/javascripts/discourse/components/edit-category-settings.js.es6 +++ b/app/assets/javascripts/discourse/components/edit-category-settings.js.es6 @@ -5,9 +5,27 @@ import computed from "ember-addons/ember-computed-decorators"; export default buildCategoryPanel('settings', { emailInEnabled: setting('email_in'), showPositionInput: setting('fixed_category_positions'), - + isParentCategory: Em.computed.empty('category.parent_category_id'), + showSubcategoryListStyle: Em.computed.and('category.show_subcategory_list', 'isParentCategory'), isDefaultSortOrder: Em.computed.empty('category.sort_order'), + @computed + 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'} + ]; + }, + + @computed + availableViews() { + return [ + {name: I18n.t('filters.latest.title'), value: 'latest'}, + {name: I18n.t('filters.top.title'), value: 'top'} + ]; + }, + @computed availableSorts() { return ['likes', 'op_likes', 'views', 'posts', 'activity', 'posters', 'category', 'created'] @@ -21,13 +39,5 @@ export default buildCategoryPanel('settings', { {name: I18n.t('category.sort_ascending'), value: 'true'}, {name: I18n.t('category.sort_descending'), value: 'false'} ]; - }, - - @computed - availableViews() { - return [ - {name: I18n.t('filters.latest.title'), value: 'latest'}, - {name: I18n.t('filters.top.title'), value: 'top'} - ]; } }); diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index 19d6ae6b800..c412ccebc42 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -19,7 +19,22 @@ export default DiscoveryController.extend({ @computed("model.parentCategory") categoryPageStyle(parentCategory) { - const style = this.siteSettings.desktop_category_page_style; + let style = this.siteSettings.desktop_category_page_style; + + if (parentCategory) { + switch(parentCategory.get('subcategory_list_style')) { + case 'rows': + style = "categories_only"; + break; + case 'rows_with_featured_topics': + style = "categories_with_featured_topics"; + break; + case 'boxes': + style = "categories_boxes"; + break; + } + } + const componentName = (parentCategory && style === "categories_and_latest_topics") ? "categories_only" : style; diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6 index 1ac1a9ca0c4..8550159ddd3 100644 --- a/app/assets/javascripts/discourse/models/category.js.es6 +++ b/app/assets/javascripts/discourse/models/category.js.es6 @@ -105,7 +105,8 @@ const Category = RestModel.extend({ topic_featured_link_allowed: this.get('topic_featured_link_allowed'), show_subcategory_list: this.get('show_subcategory_list'), num_featured_topics: this.get('num_featured_topics'), - default_view: this.get('default_view') + default_view: this.get('default_view'), + subcategory_list_style: this.get('subcategory_list_style') }, type: id ? 'PUT' : 'POST' }); diff --git a/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs b/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs new file mode 100644 index 00000000000..0010294581d --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs @@ -0,0 +1,16 @@ +{{#if categories}} + {{#each categories as |c|}} +
+ + {{cdn-img src=c.uploaded_logo.url class="logo"}} + +
+

{{c.name}}

+
+ {{c.description}} +
+
+
+
+ {{/each}} +{{/if}} diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs index d3e6a73d3a4..e12846ea3c0 100644 --- a/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs +++ b/app/assets/javascripts/discourse/templates/components/edit-category-settings.hbs @@ -19,14 +19,51 @@ -{{#unless category.parent_category_id}} -
+{{#if isParentCategory}} +
-{{/unless}} +{{/if}} + +{{#if showSubcategoryListStyle}} +
+ +
+{{/if}} + +
+ +
+ +
+ +
+ +
{{/if}} -
- -
- -
- -
- {{#if emailInEnabled}}