FIX: Don't allow moving a category with children underneath another
category (creating grandchildren)
This commit is contained in:
parent
b9989dd24b
commit
bf951689e8
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -22,8 +22,15 @@
|
|||
</section>
|
||||
|
||||
<section class='field'>
|
||||
<label>{{i18n category.parent}}</label>
|
||||
{{categoryChooser valueAttribute="id" value=parent_category_id categories=parentCategories}}
|
||||
{{#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}}
|
||||
|
|
|
@ -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}."
|
||||
|
|
Loading…
Reference in New Issue