Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checkboxes from tags multi-select filters (members page) #1678

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
:value="option"
>
<div
v-if="config.id !== 'tags'"
class="h-4 el-checkbox filter-checkbox"
:class="{ 'is-checked': props.modelValue.value.includes(option.value) }"
>
Expand Down Expand Up @@ -113,7 +114,24 @@ watch(() => props.modelValue.value, (value?: string[]) => {
}
}, { immediate: true });

watch(() => data.value.selected, (value) => {
watch(() => data.value.selected, (value, oldValue) => {
if (props.config.id === 'tags') {
filteredOptions.value = filteredOptions.value.filter((option) => !value.map((v: any) => v.value).includes(option.value));

const removedOption: any = oldValue?.find((option: any) => !value.includes(option));

if (removedOption && !filteredOptions.value.some((option) => option.value === removedOption.value)) {
const position = oldValue.findIndex((option: any) => option.value === removedOption.value);

if (position >= 0) {
filteredOptions.value.splice(position, 0, {
label: removedOption.label,
value: removedOption.value,
});
}
}
}

emit('update:modelValue', {
...props.modelValue,
value: value.map((v) => v.value),
Expand All @@ -127,7 +145,15 @@ const searchOptions = (query: string) => {
loading.value = true;
props.remoteMethod(query)
.then((options) => {
filteredOptions.value = options;
if (props.config.id === 'tags') {
const mappedOptions = options.map((option) => ({
label: option.label,
value: option.value,
}));
filteredOptions.value = mappedOptions;
} else {
filteredOptions.value = options;
}
})
.finally(() => {
loading.value = false;
Expand Down
Loading