This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/OpinionListInput.vue

34 lines
1.4 KiB
Vue
Raw Normal View History

2020-10-24 12:50:08 -07:00
<template>
2020-10-25 04:30:55 -07:00
<ListInput v-model="v" :prototype="{key: '', value: 0}" v-slot="s" :group="group">
2020-10-24 12:50:08 -07:00
<div class="input-group-prepend">
<button type="button" :class="['btn', parseInt(s.val.value) === 1 ? 'btn-primary' : 'btn-outline-secondary']"
2020-10-31 08:08:48 -07:00
:aria-label="$t('profile.opinion.yes')"
2020-10-24 12:50:08 -07:00
@click="s.update({key: s.val.key, value: 1})">
<Icon v="heart"/>
</button>
<button type="button" :class="['btn', parseInt(s.val.value) === 0 ? 'btn-primary' : 'btn-outline-secondary']"
2020-10-31 08:08:48 -07:00
:aria-label="$t('profile.opinion.meh')"
2020-10-24 12:50:08 -07:00
@click="s.update({key: s.val.key, value: 0})">
<Icon v="thumbs-up"/>
</button>
<button type="button" :class="['btn', parseInt(s.val.value) === -1 ? 'btn-primary' : 'btn-outline-secondary']"
2020-10-31 08:08:48 -07:00
:aria-label="$t('profile.opinion.no')"
2020-10-24 12:50:08 -07:00
@click="s.update({key: s.val.key, value: -1})">
<Icon v="thumbs-down"/>
</button>
</div>
<input v-model="s.val.key" class="form-control" @keyup="s.update(s.val)" required/>
</ListInput>
</template>
<script>
export default {
2020-10-25 04:30:55 -07:00
props: {
value: {},
group: {},
},
2020-10-24 12:50:08 -07:00
data() { return { v: this.value } },
watch: { v() { this.$emit('input', this.v); } }
}
</script>