mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-24 05:42:03 -04:00
Add Create Topic button to /categories page
This commit is contained in:
parent
df2a718446
commit
101ba5d8fe
3 changed files with 7 additions and 1 deletions
app
assets/javascripts/discourse
serializers
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue