Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
fixed formatting for main validator component
Dieser Commit ist enthalten in:
Ursprung
4e12e872be
Commit
eb29193d8b
1 geänderte Dateien mit 34 neuen und 35 gelöschten Zeilen
|
@ -4,40 +4,39 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import { getToken } from "wizard/lib/ajax";
|
import { getToken } from "wizard/lib/ajax";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: ['isValid', 'isInvalid'],
|
classNameBindings: ["isValid", "isInvalid"],
|
||||||
validMessageKey: null,
|
validMessageKey: null,
|
||||||
invalidMessageKey: null,
|
invalidMessageKey: null,
|
||||||
isValid: null,
|
isValid: null,
|
||||||
isInvalid: not('isValid'),
|
isInvalid: not("isValid"),
|
||||||
layoutName: 'components/validator', // useful for sharing the template with extending components
|
layoutName: "components/validator", // useful for sharing the template with extending components
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (this.get('validation.backend')) {
|
if (this.get("validation.backend")) {
|
||||||
// set a function that can be called as often as it need to
|
// set a function that can be called as often as it need to
|
||||||
// from the derived component
|
// from the derived component
|
||||||
this.backendValidate = (params) => {
|
this.backendValidate = (params) => {
|
||||||
return ajax('/realtime-validations', {
|
return ajax("/realtime-validations", {
|
||||||
data: {
|
data: {
|
||||||
validation: this.get('name'),
|
validation: this.get("name"),
|
||||||
authenticity_token: getToken(),
|
authenticity_token: getToken(),
|
||||||
...params
|
...params,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.appEvents.on('custom-wizard:validate', this, this.checkIsValid);
|
this.appEvents.on("custom-wizard:validate", this, this.checkIsValid);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.appEvents.off('custom-wizard:validate', this, this.checkIsValid);
|
this.appEvents.off("custom-wizard:validate", this, this.checkIsValid);
|
||||||
},
|
},
|
||||||
|
|
||||||
checkIsValid() {
|
checkIsValid() {
|
||||||
this.set('isValid', this.validate());
|
this.set("isValid", this.validate());
|
||||||
}
|
},
|
||||||
});
|
});
|
Laden …
In neuem Issue referenzieren