mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { ColumnInj, computed, inject } from '#imports'
|
||
|
import { EditModeInj } from '~/context'
|
||
2 years ago
|
|
||
2 years ago
|
interface Props {
|
||
2 years ago
|
modelValue?: number | null | undefined
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const { modelValue } = defineProps<Props>()
|
||
2 years ago
|
|
||
2 years ago
|
const emits = defineEmits(['update:modelValue'])
|
||
2 years ago
|
|
||
2 years ago
|
const column = inject(ColumnInj)!
|
||
2 years ago
|
|
||
2 years ago
|
const editEnabled = inject(EditModeInj)
|
||
2 years ago
|
|
||
2 years ago
|
const ratingMeta = computed(() => {
|
||
|
return {
|
||
|
icon: {
|
||
|
full: 'mdi-star',
|
||
|
empty: 'mdi-star-outline',
|
||
|
},
|
||
|
color: '#fcb401',
|
||
|
max: 5,
|
||
2 years ago
|
...(column.value?.meta || {}),
|
||
2 years ago
|
}
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
const vModel = computed({
|
||
|
get: () => modelValue ?? NaN,
|
||
|
set: (val) => emits('update:modelValue', val),
|
||
|
})
|
||
2 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<a-rate v-model:value="vModel" :count="ratingMeta.max" :style="`color: ${ratingMeta.color}`" :disabled="!editEnabled">
|
||
2 years ago
|
<template #character>
|
||
2 years ago
|
<MdiStar v-if="ratingMeta.icon.full === 'mdi-star'" class="text-sm" />
|
||
|
<MdiHeart v-if="ratingMeta.icon.full === 'mdi-heart'" class="text-sm" />
|
||
|
<MdiMoonFull v-if="ratingMeta.icon.full === 'mdi-moon-full'" class="text-sm" />
|
||
|
<MdiThumbUp v-if="ratingMeta.icon.full === 'mdi-thumb-up'" class="text-sm" />
|
||
|
<MdiFlag v-if="ratingMeta.icon.full === 'mdi-flag'" class="text-sm" />
|
||
2 years ago
|
</template>
|
||
|
</a-rate>
|
||
2 years ago
|
</template>
|