diff --git a/app/assets/javascripts/discourse/controllers/edit_category_controller.js b/app/assets/javascripts/discourse/controllers/edit_category_controller.js index c2a05af4931..3e73bfdbb35 100644 --- a/app/assets/javascripts/discourse/controllers/edit_category_controller.js +++ b/app/assets/javascripts/discourse/controllers/edit_category_controller.js @@ -135,19 +135,18 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M this.set('saving', true); model.set('parentCategory', parentCategory); + self.set('saving', false); this.get('model').save().then(function(result) { - // success self.send('closeModal'); - model.set('slug', result.category.slug); + model.setProperties({slug: result.category.slug, id: result.category.id }); Discourse.URL.redirectTo("/category/" + Discourse.Category.slugFor(model)); - }).fail(function(error) { + }).fail(function(error) { if (error && error.responseText) { self.flash($.parseJSON(error.responseText).errors[0]); } else { self.flash(I18n.t('generic_error')); } - self.set('saving', false); }); }, diff --git a/app/assets/javascripts/discourse/controllers/list_controller.js b/app/assets/javascripts/discourse/controllers/list_controller.js index 96eae597d22..232ada03a8f 100644 --- a/app/assets/javascripts/discourse/controllers/list_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_controller.js @@ -13,12 +13,11 @@ Discourse.ListController = Discourse.Controller.extend({ needs: ["composer", "modal", "listTopics"], availableNavItems: function() { - var loggedOn = !!Discourse.User.current(); var category = this.get("category"); return Discourse.SiteSettings.top_menu.split("|").map(function(i) { return Discourse.NavItem.fromText(i, { - loggedOn: loggedOn, + loggedOn: !!Discourse.User.current(), category: category }); }).filter(function(i) { diff --git a/app/assets/javascripts/discourse/models/nav_item.js b/app/assets/javascripts/discourse/models/nav_item.js index 0a58954beb8..4946677b54f 100644 --- a/app/assets/javascripts/discourse/models/nav_item.js +++ b/app/assets/javascripts/discourse/models/nav_item.js @@ -37,17 +37,16 @@ Discourse.NavItem = Discourse.Model.extend({ // href from this item filterMode: function() { var name = this.get('name'); + if( name.split('/')[0] === 'category' ) { - return 'category/' + this.get('categorySlug'); + return 'category/' + this.get('categorySlug') } else { - var mode = ""; - var category = this.get("category"); + var mode = "", + category = this.get("category"); + if(category){ mode += "category/"; - - var parentSlug = category.get('parentCategory.slug'); - if (parentSlug) { mode += parentSlug + "/"; } - mode += category.get("slug") + "/l/"; + mode += Discourse.Category.slugFor(this.get('category')) + "/l/"; } return mode + name.replace(' ', '-'); } diff --git a/app/assets/javascripts/discourse/views/nav_item_view.js b/app/assets/javascripts/discourse/views/nav_item_view.js index 065219acd09..143d3475ac4 100644 --- a/app/assets/javascripts/discourse/views/nav_item_view.js +++ b/app/assets/javascripts/discourse/views/nav_item_view.js @@ -17,9 +17,10 @@ Discourse.NavItemView = Discourse.View.extend({ active: Discourse.computed.propertyEqual('content.filterMode', 'controller.filterMode'), title: function() { - var categoryName, extra, name; - name = this.get('content.name'); - categoryName = this.get('content.categoryName'); + var categoryName = this.get('content.categoryName'), + name = this.get('content.name'), + extra; + if (categoryName) { extra = { categoryName: categoryName }; name = "category"; @@ -29,12 +30,12 @@ Discourse.NavItemView = Discourse.View.extend({ name: function() { - var categoryName, extra, name; - name = this.get('content.name'); - categoryName = this.get('content.categoryName'); - extra = { - count: this.get('content.count') || 0 - }; + var categoryName = this.get('content.categoryName'), + name = this.get('content.name'), + extra = { + count: this.get('content.count') || 0 + }; + if (categoryName) { name = 'category'; extra.categoryName = Discourse.Formatter.toTitleCase(categoryName);