|
78 | 78 | this.optionsForm.addEventListener('submit', function(e) { |
79 | 79 | e.preventDefault(); |
80 | 80 |
|
81 | | - if (self.userDisabledAllFeatures()) { |
82 | | - alert('That would make the extension useless! Please enable at least one feature.'); |
83 | | - |
84 | | - return false; |
85 | | - } |
86 | | - |
87 | 81 | if (!self.initializeVisualFeedbackOnSubmitButton()) { |
88 | 82 | return false; |
89 | 83 | } |
|
93 | 87 |
|
94 | 88 | this.displaySourceAndTargetBranchesCheckbox.addEventListener('change', function() { |
95 | 89 | self.displaySourceTargetBranchesOptionsDiv.classList.toggle('is-hidden', !this.checked); |
| 90 | + |
| 91 | + self.forceUserToEnableAtLeastOneFeatureIfNecessarily(); |
96 | 92 | }); |
97 | 93 |
|
98 | 94 | this.enableButtonToCopyMrInfoCheckbox.addEventListener('change', function() { |
99 | 95 | self.copyMrInfoOptionsDiv.classList.toggle('is-hidden', !this.checked); |
100 | 96 | self.copyMrInfoFormatTextarea.toggleAttribute('required', this.checked); |
| 97 | + |
| 98 | + self.forceUserToEnableAtLeastOneFeatureIfNecessarily(); |
101 | 99 | }); |
102 | 100 |
|
103 | 101 | this.enableJiraTicketLinkCheckbox.addEventListener('change', function() { |
|
107 | 105 | self.jiraTicketLinkLabelTypeRadioButtons.forEach(function(el) { |
108 | 106 | el.toggleAttribute('required', this.checked); |
109 | 107 | }, this); |
| 108 | + |
| 109 | + self.forceUserToEnableAtLeastOneFeatureIfNecessarily(); |
| 110 | + }); |
| 111 | + |
| 112 | + this.enableButtonToToggleWipStatusCheckbox.addEventListener('change', function() { |
| 113 | + self.forceUserToEnableAtLeastOneFeatureIfNecessarily(); |
110 | 114 | }); |
111 | 115 | } |
112 | 116 |
|
|
141 | 145 | } |
142 | 146 |
|
143 | 147 | /** |
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). |
145 | 150 | */ |
146 | | - userDisabledAllFeatures() { |
147 | | - return !this.displaySourceAndTargetBranchesCheckbox.checked |
| 151 | + forceUserToEnableAtLeastOneFeatureIfNecessarily() { |
| 152 | + let hasUserDisabledAllFeatures = !this.displaySourceAndTargetBranchesCheckbox.checked |
148 | 153 | && !this.enableButtonToCopyMrInfoCheckbox.checked |
149 | 154 | && !this.enableJiraTicketLinkCheckbox.checked |
150 | 155 | && !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 | + } |
151 | 168 | } |
152 | 169 |
|
153 | 170 | /** |
|
0 commit comments