From 23daa9d8ce8a0bef4736f329ba2da2796a39c6c4 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 2 Jul 2015 12:06:24 -0400 Subject: [PATCH] Refactor and add tests for category editing --- .../discourse/controllers/edit-category.js.es6 | 13 ++++--------- .../templates/modal/edit-category-general.hbs | 2 +- .../discourse/templates/modal/edit-category.hbs | 11 ++++++++--- .../acceptance/category-edit-test.js.es6 | 14 +++++++++++++- test/javascripts/helpers/create-pretender.js.es6 | 5 +++++ test/javascripts/test_helper.js | 6 ++++++ 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 index 52e0e45bc2..ad1e1f2351 100644 --- a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 @@ -100,16 +100,12 @@ export default ObjectController.extend(ModalFunctionality, { return name.trim().length > 0 ? name : I18n.t("preview"); }.property('name'), - buttonTitle: function() { - if (this.get('saving')) return I18n.t("saving"); - if (this.get('model.isUncategorizedCategory')) return I18n.t("save"); - return (this.get('model.id') ? I18n.t("category.save") : I18n.t("category.create")); + saveLabel: function() { + if (this.get('saving')) return "saving"; + if (this.get('model.isUncategorizedCategory')) return "save"; + return this.get('model.id') ? "category.save" : "category.create"; }.property('saving', 'model.id'), - deleteButtonTitle: function() { - return I18n.t('category.delete'); - }.property(), - showDescription: function() { return !this.get('model.isUncategorizedCategory') && this.get('model.id'); }.property('model.isUncategorizedCategory', 'model.id'), @@ -149,7 +145,6 @@ export default ObjectController.extend(ModalFunctionality, { self.send('closeModal'); model.setProperties({slug: result.category.slug, id: result.category.id }); Discourse.URL.redirectTo("/c/" + Discourse.Category.slugFor(model)); - }).catch(function(error) { if (error && error.responseText) { self.flash($.parseJSON(error.responseText).errors[0], 'error'); diff --git a/app/assets/javascripts/discourse/templates/modal/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/modal/edit-category-general.hbs index e04fd2a76a..21c724abee 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit-category-general.hbs +++ b/app/assets/javascripts/discourse/templates/modal/edit-category-general.hbs @@ -53,7 +53,7 @@
{{i18n 'category.foreground_color'}}: #{{text-field value=model.text_color placeholderKey="category.color_placeholder" maxlength="6"}} - {{color-picker colors=foregroundColors value=model.text_color}} + {{color-picker colors=foregroundColors value=model.text_color id='edit-text-color'}}
diff --git a/app/assets/javascripts/discourse/templates/modal/edit-category.hbs b/app/assets/javascripts/discourse/templates/modal/edit-category.hbs index bfd64468a6..ac5ff05850 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit-category.hbs +++ b/app/assets/javascripts/discourse/templates/modal/edit-category.hbs @@ -9,15 +9,20 @@