|
66 | 66 | }).checked = true; |
67 | 67 |
|
68 | 68 | self.enableButtonToToggleWipStatusCheckbox.checked = preferences.enable_button_to_toggle_wip_status; |
| 69 | + self.enableButtonToToggleWipStatusCheckbox.dispatchEvent(new CustomEvent('change')); |
69 | 70 | }); |
70 | 71 | } |
71 | 72 |
|
|
78 | 79 | this.optionsForm.addEventListener('submit', function(e) { |
79 | 80 | e.preventDefault(); |
80 | 81 |
|
| 82 | + if (self.hasUserDisabledAllFeatures()) { |
| 83 | + return false; |
| 84 | + } |
| 85 | + |
81 | 86 | if (!self.initializeVisualFeedbackOnSubmitButton()) { |
82 | 87 | return false; |
83 | 88 | } |
|
149 | 154 | * the extension (which is useless). |
150 | 155 | */ |
151 | 156 | forceUserToEnableAtLeastOneFeatureIfNecessarily() { |
152 | | - let hasUserDisabledAllFeatures = !this.displaySourceAndTargetBranchesCheckbox.checked |
| 157 | + if (this.hasUserDisabledAllFeatures() && !this.submitButtonInOptionsForm.disabled) { |
| 158 | + this.submitButtonInOptionsForm.disabled = true; |
| 159 | + this.submitButtonInOptionsForm.dataset.originalTextContent = this.submitButtonInOptionsForm.textContent; |
| 160 | + this.submitButtonInOptionsForm.textContent = '⚠️ Please enable at least one feature'; |
| 161 | + } else if (this.submitButtonInOptionsForm.disabled) { |
| 162 | + this.submitButtonInOptionsForm.disabled = false; |
| 163 | + this.submitButtonInOptionsForm.textContent = this.submitButtonInOptionsForm.dataset.originalTextContent; |
| 164 | + |
| 165 | + delete this.submitButtonInOptionsForm.dataset.originalTextContent; |
| 166 | + } |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Determine if the user has disabled all the features of the extension (which is useless). |
| 171 | + */ |
| 172 | + hasUserDisabledAllFeatures() { |
| 173 | + return !this.displaySourceAndTargetBranchesCheckbox.checked |
153 | 174 | && !this.enableButtonToCopyMrInfoCheckbox.checked |
154 | 175 | && !this.enableJiraTicketLinkCheckbox.checked |
155 | 176 | && !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 | | - } |
168 | 177 | } |
169 | 178 |
|
170 | 179 | /** |
|
0 commit comments