1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-24 13:04:06 +00:00
bramw_baserow/web-frontend/modules/database/components/Rating.vue
Evren Ozkan 03dc4e13aa refactor: Clean up rating element code & fix linting errors
* Remove print statement from registry and reorder imports
* Fix imports ordering and unused imports in rating tests
* Order element and collection field type registrations alphabetically
* Clean up pytest parameters for rating elements
2025-03-27 10:12:46 +00:00

59 lines
1.1 KiB
Vue

<template functional>
<div
class="rating"
:class="[
data.staticClass,
`color--${props.color}`,
props.readOnly ? '' : 'editing',
]"
>
<i
v-for="index in props.readOnly && !props.showUnselectedInReadOnly
? props.value
: props.maxValue"
:key="index"
class="rating__star"
:class="{
[`baserow-icon-${props.ratingStyle}`]: true,
'rating__star--selected': index <= props.value,
}"
@click="
!props.readOnly &&
listeners['update'] &&
listeners['update'](index === props.value ? 0 : index)
"
/>
</div>
</template>
<script>
export default {
name: 'Rating',
props: {
readOnly: {
type: Boolean,
default: false,
},
value: {
required: true,
validator: () => true,
},
maxValue: {
required: true,
type: Number,
},
ratingStyle: {
default: 'star',
type: String,
},
color: {
default: 'dark-orange',
type: String,
},
showUnselectedInReadOnly: {
type: Boolean,
default: false,
},
},
}
</script>