FIX: normalize category badge code on edit category modal

This commit is contained in:
Neil Lalonde 2014-04-04 16:48:01 -04:00
parent 5b602cc043
commit 45e75f3d48
2 changed files with 11 additions and 13 deletions

View File

@ -70,18 +70,16 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
return "background-color: #" + (this.get('color')) + "; color: #" + (this.get('text_color')) + ";"; return "background-color: #" + (this.get('color')) + "; color: #" + (this.get('text_color')) + ";";
}.property('color', 'text_color'), }.property('color', 'text_color'),
parentStyle: function() { categoryBadgePreview: function() {
if (this.get('parent_category_id')) { var c = Discourse.Category.create({
var parent = Discourse.Category.list().findBy('id', parseInt(this.get('parent_category_id'), 10)); name: this.get('categoryName'),
if (parent) { color: this.get('color'),
return 'background-color: #' + parent.get('color') + ';'; text_color: this.get('text_color'),
} else { parent_category_id: parseInt(this.get('parent_category_id'),10),
return 'display: none'; read_restricted: this.get('model.read_restricted')
} });
} else { return Discourse.HTML.categoryBadge(c, {showParent: true, link: false});
return 'display: none;'; }.property('parent_category_id', 'categoryName', 'color', 'text_color'),
}
}.property('parent_category_id'),
// background colors are available as a pipe-separated string // background colors are available as a pipe-separated string
backgroundColors: function() { backgroundColors: function() {

View File

@ -52,7 +52,7 @@
<section class='field'> <section class='field'>
<label>{{i18n category.badge_colors}}</label> <label>{{i18n category.badge_colors}}</label>
<div class="category-color-editor"> <div class="category-color-editor">
<span class='badge-category-parent' {{bind-attr style="parentStyle"}}>&nbsp;</span><span class='badge-category' {{bind-attr style="colorStyle"}}>{{categoryName}}</span> {{{categoryBadgePreview}}}
<div class='input-prepend input-append' style="margin-top: 10px;"> <div class='input-prepend input-append' style="margin-top: 10px;">
<span class='color-title'>{{i18n category.background_color}}:</span> <span class='color-title'>{{i18n category.background_color}}:</span>