From 4c5ffe2a9aa34c33727597def01b52c21834e67b Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 2 Sep 2015 10:01:20 +0100 Subject: [PATCH] Minor validations fixes no issue - clear private blog password validation errors on enable/disable - validate maximum tag name length - fix sticky validations when moving between tags or navigating to/from tags manager --- core/client/app/controllers/settings/general.js | 1 + core/client/app/controllers/settings/tags.js | 2 ++ core/client/app/validators/tag-settings.js | 3 +++ 3 files changed, 6 insertions(+) diff --git a/core/client/app/controllers/settings/general.js b/core/client/app/controllers/settings/general.js index 2e49291025..26d6d53a5f 100644 --- a/core/client/app/controllers/settings/general.js +++ b/core/client/app/controllers/settings/general.js @@ -58,6 +58,7 @@ export default Ember.Controller.extend(SettingsSaveMixin, { }).readOnly(), generatePassword: Ember.observer('model.isPrivate', function () { + this.get('model.errors').remove('password'); if (this.get('model.isPrivate') && this.get('model.isDirty')) { this.get('model').set('password', randomPassword()); } diff --git a/core/client/app/controllers/settings/tags.js b/core/client/app/controllers/settings/tags.js index 838d70b8e6..0403da9d03 100644 --- a/core/client/app/controllers/settings/tags.js +++ b/core/client/app/controllers/settings/tags.js @@ -111,10 +111,12 @@ export default Ember.Controller.extend(PaginationMixin, SettingsMenuMixin, { actions: { newTag: function () { this.set('activeTag', this.store.createRecord('tag', {post_count: 0})); + this.get('activeTag.errors').clear(); this.send('openSettingsMenu'); }, editTag: function (tag) { + tag.validate(); this.set('activeTag', tag); this.send('openSettingsMenu'); }, diff --git a/core/client/app/validators/tag-settings.js b/core/client/app/validators/tag-settings.js index 4830790cb5..606b0b6c83 100644 --- a/core/client/app/validators/tag-settings.js +++ b/core/client/app/validators/tag-settings.js @@ -11,6 +11,9 @@ var TagSettingsValidator = BaseValidator.create({ } else if (name.match(/^,/)) { model.get('errors').add('name', 'Tag names can\'t start with commas.'); this.invalidate(); + } else if (!validator.isLength(name, 0, 150)) { + model.get('errors').add('name', 'Tag names cannot be longer than 150 characters.'); + this.invalidate(); } }, metaTitle: function (model) {