Skip to content

Commit 3555b02

Browse files
committed
add unselect all option
1 parent 7e131e7 commit 3555b02

File tree

1 file changed

+57
-24
lines changed

1 file changed

+57
-24
lines changed

src/components/inspector/variables-to-submit.vue

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@
4343

4444
<!-- Select All and Search Section -->
4545
<div class="controls-section">
46-
<button
47-
type="button"
48-
class="select-all-button"
49-
@click="selectAll"
50-
:disabled="filteredVariables.length === 0 || selectedVariables.length === filteredVariables.length"
46+
<b-form-checkbox
47+
:checked="allSelected"
48+
:indeterminate="someSelected"
49+
@change="toggleSelectAll"
50+
:disabled="filteredVariables.length === 0"
51+
class="select-all-checkbox"
5152
data-cy="variables-to-submit-select-all"
5253
>
5354
{{ $t('Select All') }}
54-
</button>
55+
</b-form-checkbox>
5556
<button
5657
type="button"
5758
class="search-button"
@@ -168,9 +169,9 @@ export default {
168169
// Extract watcher output variables
169170
Object.assign(variables, this.extractWatcherVariables());
170171
171-
// Filter: exclude _parent variables, include all others
172+
// Filter: exclude _parent variables and invalid variable names
172173
return Object.keys(variables)
173-
.filter(variable => !variable.startsWith('_parent.'))
174+
.filter(variable => this.isValidVariableName(variable))
174175
.sort();
175176
},
176177
@@ -214,6 +215,22 @@ export default {
214215
return this.requiredVariables.filter(
215216
variable => !this.selectedVariables.includes(variable)
216217
);
218+
},
219+
220+
/**
221+
* Check if all filtered variables are selected
222+
*/
223+
allSelected() {
224+
return this.filteredVariables.length > 0 &&
225+
this.filteredVariables.every(v => this.selectedVariables.includes(v));
226+
},
227+
228+
/**
229+
* Check if some (but not all) filtered variables are selected
230+
*/
231+
someSelected() {
232+
const selectedCount = this.filteredVariables.filter(v => this.selectedVariables.includes(v)).length;
233+
return selectedCount > 0 && selectedCount < this.filteredVariables.length;
217234
}
218235
},
219236
watch: {
@@ -297,13 +314,38 @@ export default {
297314
this.selectedVariables = this.selectedVariables.filter(v => !filteredSet.has(v));
298315
},
299316
317+
toggleSelectAll(checked) {
318+
if (checked) {
319+
this.selectAll();
320+
} else {
321+
this.deselectAll();
322+
}
323+
},
324+
300325
toggleSearch() {
301326
this.showSearch = !this.showSearch;
302327
if (!this.showSearch) {
303328
this.searchQuery = '';
304329
}
305330
},
306331
332+
/**
333+
* Check if a variable name is valid
334+
* Uses same logic as dot_notation validation rule
335+
*/
336+
isValidVariableName(name) {
337+
if (!name || typeof name !== 'string') {
338+
return false;
339+
}
340+
if (name.startsWith('_parent.')) {
341+
return false;
342+
}
343+
// Same regex as dot_notation: starts with letter, followed by letters, numbers, or underscores
344+
const validPartRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;
345+
const parts = name.split('.');
346+
return parts.every(part => validPartRegex.test(part));
347+
},
348+
307349
/**
308350
* Extract calculated variables (computed properties) from the screen
309351
* Searches in multiple locations: App.vue, builder, or parent components
@@ -681,25 +723,16 @@ export default {
681723
margin-top: 0;
682724
}
683725
684-
.select-all-button {
685-
background: none;
686-
border: none;
687-
padding: 0;
688-
color: #0d6efd;
689-
font-size: 15px;
726+
.select-all-checkbox {
727+
margin: 0;
728+
font-size: 14px;
690729
font-weight: 600;
691-
cursor: pointer;
692-
text-decoration: none;
693-
}
694-
695-
.select-all-button:hover:not(:disabled) {
696-
color: #0a58ca;
697-
text-decoration: none;
730+
color: #495057;
698731
}
699732
700-
.select-all-button:disabled {
701-
color: #adb5bd;
702-
cursor: not-allowed;
733+
.select-all-checkbox >>> .custom-control-label {
734+
cursor: pointer;
735+
user-select: none;
703736
}
704737
705738
.search-button {

0 commit comments

Comments
 (0)