diff --git a/app/assets/javascripts/discourse/controllers/edit_category_controller.js b/app/assets/javascripts/discourse/controllers/edit_category_controller.js index 4580d69953d..67bf51dbcd8 100644 --- a/app/assets/javascripts/discourse/controllers/edit_category_controller.js +++ b/app/assets/javascripts/discourse/controllers/edit_category_controller.js @@ -95,27 +95,6 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M return Em.String.i18n('category.delete'); }.property(), - didInsertElement: function() { - this._super(); - - if (this.get('id')) { - this.set('loading', true); - var categoryController = this; - - // We need the topic_count to be correct, so get the most up-to-date info about this category from the server. - Discourse.Category.findBySlugOrId( this.get('slug') || this.get('id') ).then( function(cat) { - categoryController.set('category', cat); - Discourse.Site.instance().updateCategory(cat); - categoryController.set('id', categoryController.get('slug')); - categoryController.set('loading', false); - }); - } else if( this.get('isUncategorized') ) { - this.set('category', Discourse.Category.uncategorizedInstance()); - } else { - this.set('category', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 })); - } - }, - showCategoryTopic: function() { $('#discourse-modal').modal('hide'); Discourse.URL.routeTo(this.get('topic_url')); diff --git a/app/assets/javascripts/discourse/routes/application_route.js b/app/assets/javascripts/discourse/routes/application_route.js index 290af9ce1a5..af2fc799dde 100644 --- a/app/assets/javascripts/discourse/routes/application_route.js +++ b/app/assets/javascripts/discourse/routes/application_route.js @@ -36,10 +36,18 @@ Discourse.ApplicationRoute = Em.Route.extend({ editCategory: function(category) { var router = this; - Discourse.Category.findBySlugOrId(category.get('slug')).then(function (c) { - Discourse.Route.showModal(router, 'editCategory', c); + + if (category.get('isUncategorized')) { + Discourse.Route.showModal(router, 'editCategory', category); router.controllerFor('editCategory').set('selectedTab', 'general'); - }) + } else { + Discourse.Category.findBySlugOrId(category.get('slug')).then(function (c) { + Discourse.Site.instance().updateCategory(c); + Discourse.Route.showModal(router, 'editCategory', c); + router.controllerFor('editCategory').set('selectedTab', 'general'); + }); + } + } } diff --git a/app/assets/javascripts/discourse/routes/list_categories_route.js b/app/assets/javascripts/discourse/routes/list_categories_route.js index 817bc615666..0ef914f9a9b 100644 --- a/app/assets/javascripts/discourse/routes/list_categories_route.js +++ b/app/assets/javascripts/discourse/routes/list_categories_route.js @@ -11,7 +11,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({ events: { createCategory: function() { - Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create()); + Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 })); this.controllerFor('editCategory').set('selectedTab', 'general'); }