Show Create Topic button on /categories page, unless Create Category button is shown

This commit is contained in:
Neil Lalonde 2014-07-01 16:05:03 -04:00
parent 288bb5588f
commit 9a09817767
2 changed files with 11 additions and 2 deletions

View File

@ -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'));
}
}
});

View File

@ -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}}