Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit b6c9f3a

Browse files
committed
Do not use alert() as it's not working on Chrome
1 parent 828678d commit b6c9f3a

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

js/options.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@
7878
this.optionsForm.addEventListener('submit', function(e) {
7979
e.preventDefault();
8080

81-
if (self.userDisabledAllFeatures()) {
82-
alert('That would make the extension useless! Please enable at least one feature.');
83-
84-
return false;
85-
}
86-
8781
if (!self.initializeVisualFeedbackOnSubmitButton()) {
8882
return false;
8983
}
@@ -93,11 +87,15 @@
9387

9488
this.displaySourceAndTargetBranchesCheckbox.addEventListener('change', function() {
9589
self.displaySourceTargetBranchesOptionsDiv.classList.toggle('is-hidden', !this.checked);
90+
91+
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
9692
});
9793

9894
this.enableButtonToCopyMrInfoCheckbox.addEventListener('change', function() {
9995
self.copyMrInfoOptionsDiv.classList.toggle('is-hidden', !this.checked);
10096
self.copyMrInfoFormatTextarea.toggleAttribute('required', this.checked);
97+
98+
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
10199
});
102100

103101
this.enableJiraTicketLinkCheckbox.addEventListener('change', function() {
@@ -107,6 +105,12 @@
107105
self.jiraTicketLinkLabelTypeRadioButtons.forEach(function(el) {
108106
el.toggleAttribute('required', this.checked);
109107
}, this);
108+
109+
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
110+
});
111+
112+
this.enableButtonToToggleWipStatusCheckbox.addEventListener('change', function() {
113+
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
110114
});
111115
}
112116

@@ -141,13 +145,26 @@
141145
}
142146

143147
/**
144-
* Check if the user disabled all the features of the extension (which is useless).
148+
* Force the user to enable at least one feature if he disabled all the features of
149+
* the extension (which is useless).
145150
*/
146-
userDisabledAllFeatures() {
147-
return !this.displaySourceAndTargetBranchesCheckbox.checked
151+
forceUserToEnableAtLeastOneFeatureIfNecessarily() {
152+
let hasUserDisabledAllFeatures = !this.displaySourceAndTargetBranchesCheckbox.checked
148153
&& !this.enableButtonToCopyMrInfoCheckbox.checked
149154
&& !this.enableJiraTicketLinkCheckbox.checked
150155
&& !this.enableButtonToToggleWipStatusCheckbox.checked;
156+
157+
if (hasUserDisabledAllFeatures) {
158+
this.displaySourceAndTargetBranchesCheckbox.required = true;
159+
this.enableButtonToCopyMrInfoCheckbox.required = true;
160+
this.enableJiraTicketLinkCheckbox.required = true;
161+
this.enableButtonToToggleWipStatusCheckbox.required = true;
162+
} else {
163+
this.displaySourceAndTargetBranchesCheckbox.required = false;
164+
this.enableButtonToCopyMrInfoCheckbox.required = false;
165+
this.enableJiraTicketLinkCheckbox.required = false;
166+
this.enableButtonToToggleWipStatusCheckbox.required = false;
167+
}
151168
}
152169

153170
/**

0 commit comments

Comments
 (0)