From eb29193d8b6ff97374d6fc333051ac7fa33bc08c Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Mon, 15 Feb 2021 13:49:14 +0530 Subject: [PATCH] fixed formatting for main validator component --- .../wizard/components/validator.js.es6 | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/assets/javascripts/wizard/components/validator.js.es6 b/assets/javascripts/wizard/components/validator.js.es6 index e272fe52..e2a656e0 100644 --- a/assets/javascripts/wizard/components/validator.js.es6 +++ b/assets/javascripts/wizard/components/validator.js.es6 @@ -4,40 +4,39 @@ import { ajax } from "discourse/lib/ajax"; import { getToken } from "wizard/lib/ajax"; export default Component.extend({ - classNameBindings: ['isValid', 'isInvalid'], - validMessageKey: null, - invalidMessageKey: null, - isValid: null, - isInvalid: not('isValid'), - layoutName: 'components/validator', // useful for sharing the template with extending components - init() { - this._super(...arguments); + classNameBindings: ["isValid", "isInvalid"], + validMessageKey: null, + invalidMessageKey: null, + isValid: null, + isInvalid: not("isValid"), + layoutName: "components/validator", // useful for sharing the template with extending components + init() { + this._super(...arguments); - if (this.get('validation.backend')) { - // set a function that can be called as often as it need to - // from the derived component - this.backendValidate = (params) => { - return ajax('/realtime-validations', { - data: { - validation: this.get('name'), - authenticity_token: getToken(), - ...params - } - }); - } - - } - }, - - didInsertElement() { - this.appEvents.on('custom-wizard:validate', this, this.checkIsValid); - }, - - willDestroyElement() { - this.appEvents.off('custom-wizard:validate', this, this.checkIsValid); - }, - - checkIsValid() { - this.set('isValid', this.validate()); + if (this.get("validation.backend")) { + // set a function that can be called as often as it need to + // from the derived component + this.backendValidate = (params) => { + return ajax("/realtime-validations", { + data: { + validation: this.get("name"), + authenticity_token: getToken(), + ...params, + }, + }); + }; } -}); \ No newline at end of file + }, + + didInsertElement() { + this.appEvents.on("custom-wizard:validate", this, this.checkIsValid); + }, + + willDestroyElement() { + this.appEvents.off("custom-wizard:validate", this, this.checkIsValid); + }, + + checkIsValid() { + this.set("isValid", this.validate()); + }, +});