From 45e75f3d48c7ba74cc2f736a8c1b8d3daa870c19 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 4 Apr 2014 16:48:01 -0400 Subject: [PATCH] FIX: normalize category badge code on edit category modal --- .../controllers/edit_category_controller.js | 22 +++++++++---------- .../modal/edit_category.js.handlebars | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/edit_category_controller.js b/app/assets/javascripts/discourse/controllers/edit_category_controller.js index 5f85d617733..cff1f1ffb5f 100644 --- a/app/assets/javascripts/discourse/controllers/edit_category_controller.js +++ b/app/assets/javascripts/discourse/controllers/edit_category_controller.js @@ -70,18 +70,16 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M return "background-color: #" + (this.get('color')) + "; color: #" + (this.get('text_color')) + ";"; }.property('color', 'text_color'), - parentStyle: function() { - if (this.get('parent_category_id')) { - var parent = Discourse.Category.list().findBy('id', parseInt(this.get('parent_category_id'), 10)); - if (parent) { - return 'background-color: #' + parent.get('color') + ';'; - } else { - return 'display: none'; - } - } else { - return 'display: none;'; - } - }.property('parent_category_id'), + categoryBadgePreview: function() { + var c = Discourse.Category.create({ + name: this.get('categoryName'), + color: this.get('color'), + text_color: this.get('text_color'), + parent_category_id: parseInt(this.get('parent_category_id'),10), + read_restricted: this.get('model.read_restricted') + }); + return Discourse.HTML.categoryBadge(c, {showParent: true, link: false}); + }.property('parent_category_id', 'categoryName', 'color', 'text_color'), // background colors are available as a pipe-separated string backgroundColors: function() { diff --git a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars index b0656358213..31755892822 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/edit_category.js.handlebars @@ -52,7 +52,7 @@
-  {{categoryName}} + {{{categoryBadgePreview}}}
{{i18n category.background_color}}: