Skip to content

Commit e8a6530

Browse files
authored
Merge pull request #3674 from bjester/category-option-selection
Resolve issue with selection mismatch between autocomplete and checkbox
2 parents fbe6016 + d767f21 commit e8a6530

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

contentcuration/contentcuration/frontend/channelEdit/components/edit/CategoryOptions.vue

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@
4141
</template>
4242

4343
<template #item="{ item }">
44-
<div style="width: 100%; height: 100%">
45-
<VDivider v-if="!item.value.includes('.')" />
44+
<VListTile
45+
:value="isSelected(item.value)"
46+
:class="{ parentOption: !item.value.includes('.') }"
47+
@mousedown.prevent
48+
@click="() => !isSelected(item.value) ? add(item.value) : remove(item.value)"
49+
>
4650
<KCheckbox
47-
:checked="dropdownSelected[item.value]"
51+
:checked="isSelected(item.value)"
4852
:label="item.text"
4953
:value="item.value"
5054
style="margin-top: 10px"
5155
:style="treeItemStyle(item)"
5256
:ripple="false"
53-
@change="checked => checked ? add(item.value) : remove(item.value)"
5457
/>
55-
</div>
58+
</VListTile>
5659
</template>
5760
</VAutocomplete>
5861
</div>
@@ -143,19 +146,6 @@
143146
};
144147
});
145148
},
146-
dropdownSelected() {
147-
const obj = {};
148-
for (let category of this.selected) {
149-
const paths = category.split('.');
150-
let cat = '';
151-
for (let path of paths) {
152-
cat += path;
153-
obj[cat] = true;
154-
cat += '.';
155-
}
156-
}
157-
return obj;
158-
},
159149
selected: {
160150
get() {
161151
return this.value;
@@ -167,16 +157,19 @@
167157
nested() {
168158
return !this.categoryText;
169159
},
160+
isSelected() {
161+
return value => this.selected.some(v => v.startsWith(value));
162+
},
170163
},
171164
methods: {
172165
treeItemStyle(item) {
173166
return this.nested ? { paddingLeft: `${item.level * 24}px` } : {};
174167
},
175-
add(item) {
176-
this.selected = [...this.selected, item];
168+
add(value) {
169+
this.selected = [...this.selected, value];
177170
},
178-
remove(item) {
179-
this.selected = this.selected.filter(i => !i.startsWith(item));
171+
remove(value) {
172+
this.selected = this.selected.filter(i => !i.startsWith(value));
180173
},
181174
removeAll() {
182175
this.selected = [];
@@ -220,12 +213,8 @@
220213
position: relative;
221214
}
222215
223-
/deep/ .v-list__tile {
224-
flex-wrap: wrap;
225-
}
226-
227-
/deep/ div[role='listitem']:first-child hr {
228-
display: none;
216+
.parentOption:not(:first-child) {
217+
border-top: 1px solid rgba(0, 0, 0, 0.12);
229218
}
230219
231220
</style>

0 commit comments

Comments
 (0)