FIX: Don't allow moving a category with children underneath another

category (creating grandchildren)
This commit is contained in:
Robin Ward 2014-02-03 15:09:35 -05:00
parent b9989dd24b
commit bf951689e8
4 changed files with 21 additions and 3 deletions

View file

@ -20,6 +20,11 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
});
}.property(),
// We can change the parent if there are no children
subCategories: function() {
return Discourse.Category.list().filterBy('parent_category_id', this.get('id'));
}.property('model.id'),
onShow: function() {
this.changeSize();
this.titleChanged();

View file

@ -73,6 +73,12 @@ Handlebars.registerHelper('categoryLinkRaw', function(property, options) {
return categoryLinkHTML(property, options);
});
Handlebars.registerHelper('categoryBadge', function(property, options) {
var category = Em.Handlebars.get(this, property, options),
style = Discourse.HTML.categoryStyle(category);
return new Handlebars.SafeString("<span class='badge-category' style='" + style + "'>" + category.get('name') + "</span>");
});
/**
Produces a bound link to a category

View file

@ -22,8 +22,15 @@
</section>
<section class='field'>
{{#if subCategories}}
<label>{{i18n categories.subcategories}}</label>
{{#each subCategories}}
{{categoryBadge this}}
{{/each}}
{{else}}
<label>{{i18n category.parent}}</label>
{{categoryChooser valueAttribute="id" value=parent_category_id categories=parentCategories}}
{{/if}}
</section>
{{#unless isUncategorized}}

View file

@ -196,7 +196,7 @@ en:
latest: "Latest"
latest_by: "latest by"
toggle_ordering: "toggle ordering control"
subcategories: "Subcategories:"
subcategories: "Subcategories"
topic_stats: "The number of new topics."
topic_stat_sentence:
one: "%{count} new topic in the past %{unit}."