diff --git a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 index a75fac64..6e7daa9e 100644 --- a/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 +++ b/assets/javascripts/discourse/components/wizard-realtime-validations.js.es6 @@ -4,34 +4,40 @@ import { cloneJSON } from "discourse-common/lib/object"; import Category from "discourse/models/category"; export default Component.extend({ - classNames: ['realtime-validations'], - - init(){ - this._super(...arguments); - if (!this.validations) return; + classNames: ["realtime-validations"], - if (!this.field.validations) { - const validations = {}; - this.validations.forEach((validation) => { - validations[validation] = {}; - }); + init() { + this._super(...arguments); + if (!this.validations) return; - this.set('field.validations', EmberObject.create(validations)); - } + if (!this.field.validations) { + const validations = {}; + this.validations.forEach((validation) => { + validations[validation] = {}; + }); - const validationBuffer = cloneJSON(this.get('field.validations')); - let bufferCategories; - if( validationBuffer.similar_topics && (bufferCategories = validationBuffer.similar_topics.categories)) { - const categories = Category.findByIds(bufferCategories); - validationBuffer.similar_topics.categories = categories; - } - this.set('validationBuffer', validationBuffer); - }, - - actions: { - updateValidationCategories(name, validation, categories) { - this.set(`validationBuffer.${name}.categories`, categories); - this.set(`field.validations.${name}.categories`, categories.map(category => category.id)); - } + this.set("field.validations", EmberObject.create(validations)); } + + const validationBuffer = cloneJSON(this.get("field.validations")); + let bufferCategories; + if ( + validationBuffer.similar_topics && + (bufferCategories = validationBuffer.similar_topics.categories) + ) { + const categories = Category.findByIds(bufferCategories); + validationBuffer.similar_topics.categories = categories; + } + this.set("validationBuffer", validationBuffer); + }, + + actions: { + updateValidationCategories(name, validation, categories) { + this.set(`validationBuffer.${name}.categories`, categories); + this.set( + `field.validations.${name}.categories`, + categories.map((category) => category.id) + ); + }, + }, });