mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 04:23:01 +08:00
Fix a case when editing uncategorized all the hidden form controls become visible
This commit is contained in:
parent
52942d2de6
commit
5b33992604
|
@ -8,6 +8,11 @@
|
||||||
**/
|
**/
|
||||||
Discourse.Category = Discourse.Model.extend({
|
Discourse.Category = Discourse.Model.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
this._super();
|
||||||
|
if (!this.get('id') && this.get('name')) this.set('is_uncategorized', true);
|
||||||
|
},
|
||||||
|
|
||||||
url: function() {
|
url: function() {
|
||||||
return Discourse.getURL("/category/") + (this.get('slug'));
|
return Discourse.getURL("/category/") + (this.get('slug'));
|
||||||
}.property('name'),
|
}.property('name'),
|
||||||
|
@ -20,10 +25,6 @@ Discourse.Category = Discourse.Model.extend({
|
||||||
return this.get('topic_count') > Discourse.SiteSettings.category_featured_topics;
|
return this.get('topic_count') > Discourse.SiteSettings.category_featured_topics;
|
||||||
}.property('topic_count'),
|
}.property('topic_count'),
|
||||||
|
|
||||||
isUncategorized: function() {
|
|
||||||
return (!this.get('id') && this.get('name'));
|
|
||||||
}.property('id', 'name'),
|
|
||||||
|
|
||||||
save: function(args) {
|
save: function(args) {
|
||||||
var url = Discourse.getURL("/categories");
|
var url = Discourse.getURL("/categories");
|
||||||
if (this.get('id')) {
|
if (this.get('id')) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{{view Discourse.TextField valueBinding="name" placeholderKey="category.name_placeholder" maxlength="50"}}
|
{{view Discourse.TextField valueBinding="name" placeholderKey="category.name_placeholder" maxlength="50"}}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{#unless isUncategorized}}
|
{{#unless is_uncategorized}}
|
||||||
<section class='field'>
|
<section class='field'>
|
||||||
<label>{{i18n category.description}}</label>
|
<label>{{i18n category.description}}</label>
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
||||||
|
|
||||||
title: function() {
|
title: function() {
|
||||||
if (this.get('category.id')) return Em.String.i18n("category.edit_long");
|
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");
|
return Em.String.i18n("category.create");
|
||||||
}.property('category.id'),
|
}.property('category.id'),
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
||||||
|
|
||||||
buttonTitle: function() {
|
buttonTitle: function() {
|
||||||
if (this.get('saving')) return Em.String.i18n("saving");
|
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"));
|
return (this.get('category.id') ? Em.String.i18n("category.save") : Em.String.i18n("category.create"));
|
||||||
}.property('saving', 'category.id'),
|
}.property('saving', 'category.id'),
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
||||||
categoryView.set('id', categoryView.get('category.slug'));
|
categoryView.set('id', categoryView.get('category.slug'));
|
||||||
categoryView.set('loading', false);
|
categoryView.set('loading', false);
|
||||||
});
|
});
|
||||||
} else if( this.get('category.isUncategorized') ) {
|
} else if( this.get('category.is_uncategorized') ) {
|
||||||
this.set('category', this.get('category'));
|
this.set('category', this.get('category'));
|
||||||
} else {
|
} else {
|
||||||
this.set('category', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
|
this.set('category', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
|
||||||
|
@ -96,7 +96,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
||||||
saveCategory: function() {
|
saveCategory: function() {
|
||||||
var categoryView = this;
|
var categoryView = this;
|
||||||
this.set('saving', true);
|
this.set('saving', true);
|
||||||
if( this.get('category.isUncategorized') ) {
|
if( this.get('category.is_uncategorized') ) {
|
||||||
$.when(
|
$.when(
|
||||||
Discourse.SiteSetting.update('uncategorized_color', this.get('category.color')),
|
Discourse.SiteSetting.update('uncategorized_color', this.get('category.color')),
|
||||||
Discourse.SiteSetting.update('uncategorized_text_color', this.get('category.text_color')),
|
Discourse.SiteSetting.update('uncategorized_text_color', this.get('category.text_color')),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user