Skip to content

Commit

Permalink
update DropdownSelect component to make it reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-kamil committed Aug 28, 2023
1 parent 1740e47 commit c10e84f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions resources/js/components/atoms/DropdownSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
{{ title }}
</h3>
<select
id="regions"
class="w-full rounded-md border border-black bg-white px-2.5 py-1 text-sm text-black focus:border-blue focus:ring-blue"
@change="onChange"
>
<option selected>{{ placeholder }}</option>
<option v-for="option in filters" :key="option.key" :value="value">
{{ __('regions.' + option.title) }}<template v-if="option.items !== undefined">&nbsp;({{ option.items }})</template>
<option>{{ placeholder }}</option>
<option v-for="option in filters" :key="option.key" :value="option.key" :selected="isSelected(option)">
{{ __('regions.' + option.title)
}}<template v-if="option.items !== undefined">&nbsp;({{ option.items }})</template>
</option>
</select>
</div>
Expand All @@ -35,5 +36,13 @@ export default {
required: true,
},
},
methods: {
isSelected(option) {
return this.value.find((o) => o.key === option.key)
},
onChange(event) {
this.$emit('input', [this.filters.find((o) => o.key == event.target.value) || ''])
},
},
}
</script>

0 comments on commit c10e84f

Please sign in to comment.