Fix a case when editing uncategorized all the hidden form controls become visible

This commit is contained in:
Neil Lalonde 2013-05-03 18:26:49 -04:00
parent 52942d2de6
commit 5b33992604
3 changed files with 10 additions and 9 deletions

View File

@ -8,6 +8,11 @@
**/
Discourse.Category = Discourse.Model.extend({
init: function() {
this._super();
if (!this.get('id') && this.get('name')) this.set('is_uncategorized', true);
},
url: function() {
return Discourse.getURL("/category/") + (this.get('slug'));
}.property('name'),
@ -20,10 +25,6 @@ Discourse.Category = Discourse.Model.extend({
return this.get('topic_count') > Discourse.SiteSettings.category_featured_topics;
}.property('topic_count'),
isUncategorized: function() {
return (!this.get('id') && this.get('name'));
}.property('id', 'name'),
save: function(args) {
var url = Discourse.getURL("/categories");
if (this.get('id')) {

View File

@ -8,7 +8,7 @@
{{view Discourse.TextField valueBinding="name" placeholderKey="category.name_placeholder" maxlength="50"}}
</section>
{{#unless isUncategorized}}
{{#unless is_uncategorized}}
<section class='field'>
<label>{{i18n category.description}}</label>

View File

@ -47,7 +47,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
title: function() {
if (this.get('category.id')) return Em.String.i18n("category.edit_long");
if (this.get('category.isUncategorized')) return Em.String.i18n("category.edit_uncategorized");
if (this.get('category.is_uncategorized')) return Em.String.i18n("category.edit_uncategorized");
return Em.String.i18n("category.create");
}.property('category.id'),
@ -58,7 +58,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n("saving");
if (this.get('category.isUncategorized')) return Em.String.i18n("save");
if (this.get('category.is_uncategorized')) return Em.String.i18n("save");
return (this.get('category.id') ? Em.String.i18n("category.save") : Em.String.i18n("category.create"));
}.property('saving', 'category.id'),
@ -80,7 +80,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
categoryView.set('id', categoryView.get('category.slug'));
categoryView.set('loading', false);
});
} else if( this.get('category.isUncategorized') ) {
} else if( this.get('category.is_uncategorized') ) {
this.set('category', this.get('category'));
} else {
this.set('category', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
@ -96,7 +96,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
saveCategory: function() {
var categoryView = this;
this.set('saving', true);
if( this.get('category.isUncategorized') ) {
if( this.get('category.is_uncategorized') ) {
$.when(
Discourse.SiteSetting.update('uncategorized_color', this.get('category.color')),
Discourse.SiteSetting.update('uncategorized_text_color', this.get('category.text_color')),