Add Create Topic button to /categories page

This commit is contained in:
Neil Lalonde 2013-05-14 12:45:54 -04:00
parent df2a718446
commit 101ba5d8fe
3 changed files with 7 additions and 1 deletions
app
assets/javascripts/discourse
serializers

View file

@ -36,6 +36,7 @@ Discourse.CategoryList.reopenClass({
return Discourse.ajax("/" + filter + ".json").then(function(result) {
var categoryList = Discourse.TopicList.create();
categoryList.set('can_create_category', result.category_list.can_create_category);
categoryList.set('can_create_topic', result.category_list.can_create_topic);
categoryList.set('categories', route.categoriesFrom(result));
categoryList.set('loaded', true);
return categoryList;

View file

@ -25,6 +25,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
controller: 'listCategories'
});
listController.set('canCreateCategory', categoryList.get('can_create_category'));
listController.set('canCreateTopic', categoryList.get('can_create_topic'));
listController.set('category', null);
_this.controllerFor('listCategories').set('content', categoryList);
});

View file

@ -1,6 +1,6 @@
class CategoryListSerializer < ApplicationSerializer
attributes :can_create_category
attributes :can_create_category, :can_create_topic
has_many :categories, serializer: CategoryDetailedSerializer, embed: :objects
@ -8,4 +8,8 @@ class CategoryListSerializer < ApplicationSerializer
scope.can_create?(Category)
end
def can_create_topic
scope.can_create?(Topic)
end
end