Commit c5e28a7b authored by kushalpandya's avatar kushalpandya Committed by Jarka Kadlecova

Validate config form only when service is marked active

parent 791e5024
...@@ -22,7 +22,7 @@ export default class IntegrationSettingsForm { ...@@ -22,7 +22,7 @@ export default class IntegrationSettingsForm {
init() { init() {
// Initialize View // Initialize View
this.toggleSubmitBtnLabel(this.$serviceToggle.is(':checked')); this.toggleServiceState(this.$serviceToggle.is(':checked'));
// Bind Event Listeners // Bind Event Listeners
this.$serviceToggle.on('change', this.handleServiceToggle); this.$serviceToggle.on('change', this.handleServiceToggle);
...@@ -31,13 +31,24 @@ export default class IntegrationSettingsForm { ...@@ -31,13 +31,24 @@ export default class IntegrationSettingsForm {
handleSettingsSave(e) { handleSettingsSave(e) {
if (this.$serviceToggle.is(':checked')) { if (this.$serviceToggle.is(':checked')) {
if (this.$form.get(0).checkValidity()) {
e.preventDefault(); e.preventDefault();
this.testSettings(this.$form.serialize()); this.testSettings(this.$form.serialize());
} }
} }
}
handleServiceToggle(e) { handleServiceToggle(e) {
this.toggleSubmitBtnLabel($(e.currentTarget).is(':checked')); this.toggleServiceState($(e.currentTarget).is(':checked'));
}
toggleServiceState(serviceActive) {
this.toggleSubmitBtnLabel(serviceActive);
if (serviceActive) {
this.$form.removeAttr('novalidate');
} else if (!this.$form.attr('novalidate')) {
this.$form.attr('novalidate', 'novalidate');
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment