Skip to content

Commit b154495

Browse files
feat: New select and deselect buttons
1 parent 70d7309 commit b154495

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

i18n/translations/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
"delete": "Delete",
4545
"delete.all": "Delete all",
4646

47+
"deselect": "Deselect",
48+
"deselect.all": "Deselect all",
49+
4750
"dialog.fields.empty": "This dialog has no fields",
4851
"dialog.files.empty": "No files to select",
4952
"dialog.pages.empty": "No pages to select",
@@ -664,6 +667,7 @@
664667

665668
"security": "Security",
666669
"select": "Select",
670+
"select.all": "Select all",
667671
"server": "Server",
668672
"settings": "Settings",
669673
"show": "Show",

panel/public/img/icons.svg

Lines changed: 6 additions & 0 deletions
Loading

panel/src/components/Forms/Field/CheckboxesField.vue

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,28 @@
1414
class="k-field-counter"
1515
/>
1616

17-
<label v-if="batch">
18-
<input ref="batch" type="checkbox" @input="batchSelect" />
19-
<span class="sr-only">select/deselect all</span>
20-
</label>
17+
<k-button-group v-if="batch" layout="collapsed">
18+
<k-button
19+
:disabled="value.length === 0"
20+
:responsive="true"
21+
icon="deselect-all"
22+
size="xs"
23+
variant="filled"
24+
@click="deselectAll"
25+
>
26+
{{ $t("deselect.all") }}
27+
</k-button>
28+
<k-button
29+
:disabled="value.length === options.length"
30+
:responsive="true"
31+
icon="select-all"
32+
size="xs"
33+
variant="filled"
34+
@click="selectAll"
35+
>
36+
{{ $t("select.all") }}
37+
</k-button>
38+
</k-button-group>
2139
</template>
2240

2341
<k-empty
@@ -49,29 +67,12 @@ export default {
4967
props: {
5068
batch: Boolean
5169
},
52-
watch: {
53-
value() {
54-
this.checkBatchToggleState();
55-
}
56-
},
57-
mounted() {
58-
this.checkBatchToggleState();
59-
},
6070
methods: {
61-
batchSelect(e) {
62-
if (e.target.checked) {
63-
this.$refs.input.selectAll();
64-
} else {
65-
this.$refs.input.deselectAll();
66-
}
71+
deselectAll() {
72+
this.$refs.input.deselectAll();
6773
},
68-
checkBatchToggleState() {
69-
// indeterminate state
70-
this.$refs.batch.indeterminate =
71-
this.value.length > 0 && this.value.length !== this.options.length;
72-
73-
// checked state
74-
this.$refs.batch.checked = this.value.length === this.options.length;
74+
selectAll() {
75+
this.$refs.input.selectAll();
7576
},
7677
focus() {
7778
this.$refs.input.focus();

0 commit comments

Comments
 (0)