Commit 44f2504a authored by kushalpandya's avatar kushalpandya Committed by Jarka Kadlecova

Initialize canTestService from form meta

parent 095d9b5b
...@@ -6,6 +6,7 @@ export default class IntegrationSettingsForm { ...@@ -6,6 +6,7 @@ export default class IntegrationSettingsForm {
// Form Metadata // Form Metadata
this.endPoint = this.$form.attr('action'); this.endPoint = this.$form.attr('action');
this.canTestService = this.$form.data('can-test');
// Form Child Elements // Form Child Elements
this.$serviceToggle = this.$form.find('#service_active'); this.$serviceToggle = this.$form.find('#service_active');
...@@ -31,7 +32,8 @@ export default class IntegrationSettingsForm { ...@@ -31,7 +32,8 @@ export default class IntegrationSettingsForm {
handleSettingsSave(e) { handleSettingsSave(e) {
if (this.$serviceToggle.is(':checked')) { if (this.$serviceToggle.is(':checked')) {
if (this.$form.get(0).checkValidity()) { if (this.$form.get(0).checkValidity() &&
this.canTestService) {
e.preventDefault(); e.preventDefault();
this.testSettings(this.$form.serialize()); this.testSettings(this.$form.serialize());
} }
...@@ -43,7 +45,7 @@ export default class IntegrationSettingsForm { ...@@ -43,7 +45,7 @@ export default class IntegrationSettingsForm {
} }
toggleServiceState(serviceActive) { toggleServiceState(serviceActive) {
this.toggleSubmitBtnLabel(serviceActive); this.toggleSubmitBtnLabel(serviceActive, this.canTestService);
if (serviceActive) { if (serviceActive) {
this.$form.removeAttr('novalidate'); this.$form.removeAttr('novalidate');
} else if (!this.$form.attr('novalidate')) { } else if (!this.$form.attr('novalidate')) {
...@@ -54,9 +56,9 @@ export default class IntegrationSettingsForm { ...@@ -54,9 +56,9 @@ export default class IntegrationSettingsForm {
/** /**
* Toggle Submit button label based on Integration status * Toggle Submit button label based on Integration status
*/ */
toggleSubmitBtnLabel(serviceActive) { toggleSubmitBtnLabel(serviceActive, canTestService) {
this.$submitBtnLabel.text( this.$submitBtnLabel.text(
serviceActive ? serviceActive && canTestService ?
'Test settings and save changes' : 'Test settings and save changes' :
'Save changes'); 'Save changes');
} }
......
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