Show Create Topic button on /categories page, unless Create Category button is shown
This commit is contained in:
parent
288bb5588f
commit
9a09817767
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend({
|
||||
Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
||||
renderTemplate: function() {
|
||||
this.render('navigation/categories', { outlet: 'navigation-bar' });
|
||||
this.render('discovery/categories', { outlet: 'list-container' });
|
||||
|
@ -34,7 +34,10 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend({
|
|||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
Discourse.set('title', I18n.t('filters.categories.title'));
|
||||
|
||||
// Only show either the Create Category or Create Topic button
|
||||
this.controllerFor('navigation/categories').set('canCreateCategory', model.get('can_create_category'));
|
||||
this.controllerFor('navigation/categories').set('canCreateTopic', model.get('can_create_topic') && !model.get('can_create_category'));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -44,6 +47,10 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend({
|
|||
available_groups: Discourse.Site.current().group_names
|
||||
}));
|
||||
this.controllerFor('editCategory').set('selectedTab', 'general');
|
||||
},
|
||||
|
||||
createTopic: function() {
|
||||
this.openComposer(this.controllerFor('discovery/categories'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,4 +10,6 @@
|
|||
{{#if canCreateCategory}}
|
||||
<button class='btn btn-default' {{action createCategory}}><i class='fa fa-plus'></i>{{i18n category.create}}</button>
|
||||
{{/if}}
|
||||
|
||||
{{#if canCreateTopic}}
|
||||
<button id="create-topic" class='btn btn-default' {{action createTopic}}><i class='fa fa-plus'></i>{{i18n topic.create}}</button>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue