Files
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

69 lines
1.6 KiB
Vue

<template>
<div ref="cell" class="grid-view__cell active">
<div class="grid-field-rating">
<Rating
:read-only="readOnly"
:rating-style="field.style"
:color="field.color"
:value="value"
:max-value="field.max_value"
@update="update"
/>
</div>
</div>
</template>
<script>
import gridField from '@baserow/modules/database/mixins/gridField'
import Rating from '@baserow/modules/database/components/Rating'
export default {
components: { Rating },
mixins: [gridField],
emits: ['update'],
mounted() {
window.addEventListener('keyup', this.keyup)
},
beforeUnmount() {
window.removeEventListener('keyup', this.keyup)
},
methods: {
update(newValue) {
this.$emit('update', newValue, this.value)
},
keyup(event) {
// Allow keyboard modification
const { key } = event
let newValue = this.value
if ('0123456789'.includes(key)) {
// Transform digit in value
newValue = parseInt(key, 10)
} else {
// +, > to increase -, < to decrease
switch (key) {
case '+':
case '>':
newValue = this.value + 1
break
case '-':
case '<':
newValue = this.value - 1
break
}
}
if (newValue !== this.value) {
// Clamp value
if (newValue > this.field.max_value) {
newValue = this.field.max_value
}
if (newValue < 0) {
newValue = 0
}
this.$emit('update', newValue, this.value)
}
},
},
}
</script>