New categories weren't getting correct default colors

This commit is contained in:
Robin Ward 2013-05-31 13:42:46 -04:00
parent fea3f326a9
commit a4d88fbaa7
3 changed files with 12 additions and 25 deletions

View File

@ -95,27 +95,6 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
return Em.String.i18n('category.delete'); return Em.String.i18n('category.delete');
}.property(), }.property(),
didInsertElement: function() {
this._super();
if (this.get('id')) {
this.set('loading', true);
var categoryController = this;
// We need the topic_count to be correct, so get the most up-to-date info about this category from the server.
Discourse.Category.findBySlugOrId( this.get('slug') || this.get('id') ).then( function(cat) {
categoryController.set('category', cat);
Discourse.Site.instance().updateCategory(cat);
categoryController.set('id', categoryController.get('slug'));
categoryController.set('loading', false);
});
} else if( this.get('isUncategorized') ) {
this.set('category', Discourse.Category.uncategorizedInstance());
} else {
this.set('category', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
}
},
showCategoryTopic: function() { showCategoryTopic: function() {
$('#discourse-modal').modal('hide'); $('#discourse-modal').modal('hide');
Discourse.URL.routeTo(this.get('topic_url')); Discourse.URL.routeTo(this.get('topic_url'));

View File

@ -36,10 +36,18 @@ Discourse.ApplicationRoute = Em.Route.extend({
editCategory: function(category) { editCategory: function(category) {
var router = this; var router = this;
if (category.get('isUncategorized')) {
Discourse.Route.showModal(router, 'editCategory', category);
router.controllerFor('editCategory').set('selectedTab', 'general');
} else {
Discourse.Category.findBySlugOrId(category.get('slug')).then(function (c) { Discourse.Category.findBySlugOrId(category.get('slug')).then(function (c) {
Discourse.Site.instance().updateCategory(c);
Discourse.Route.showModal(router, 'editCategory', c); Discourse.Route.showModal(router, 'editCategory', c);
router.controllerFor('editCategory').set('selectedTab', 'general'); router.controllerFor('editCategory').set('selectedTab', 'general');
}) });
}
} }
} }

View File

@ -11,7 +11,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
events: { events: {
createCategory: function() { createCategory: function() {
Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create()); Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
this.controllerFor('editCategory').set('selectedTab', 'general'); this.controllerFor('editCategory').set('selectedTab', 'general');
} }