Skip to content

Commit

Permalink
feat: add checkbox to j-vselection
Browse files Browse the repository at this point in the history
  • Loading branch information
phojie committed Dec 1, 2022
1 parent 7049bc5 commit 63ab7c2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions resources/js/j-components/JVSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ interface VSelect {
}
const props = withDefaults(defineProps<VSelect>(), {
deselectFromDropdown: true,
})
const emit = defineEmits(['update:modelValue'])
const value = useVModel(props, 'modelValue', emit)
const isChecked = (name: string) => {
const namesList = _.map(props.modelValue, 'name')
if (namesList.includes(name))
return true
return false
}
</script>

<template>
Expand All @@ -46,7 +54,20 @@ const value = useVModel(props, 'modelValue', emit)
:options="options"
:close-on-select="closeOnSelect"
:deselect-from-dropdown="deselectFromDropdown"
/>
>
<template #option="option">
<div class="py-2">
<JCheckbox
:id="option.name"
:model-value="isChecked(option.name)"
>
<template #label>
{{ option.name }}
</template>
</JCheckbox>
</div>
</template>
</VSelect>
</div>
</div>
</template>

0 comments on commit 63ab7c2

Please sign in to comment.