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
3 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { ColumnInj, computed, inject } from '#imports'
|
||
|
import { EditModeInj } from '~/context'
|
||
3 years ago
|
|
||
3 years ago
|
interface Props {
|
||
2 years ago
|
modelValue?: number | null | undefined
|
||
3 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)!
|
||
3 years ago
|
|
||
2 years ago
|
const editEnabled = inject(EditModeInj)
|
||
2 years ago
|
|
||
3 years ago
|
const ratingMeta = computed(() => {
|
||
|
return {
|
||
|
icon: {
|
||
|
full: 'mdi-star',
|
||
|
empty: 'mdi-star-outline',
|
||
|
},
|
||
|
color: '#fcb401',
|
||
|
max: 5,
|
||
2 years ago
|
...(column.value?.meta || {}),
|
||
3 years ago
|
}
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
const vModel = computed({
|
||
|
get: () => modelValue ?? NaN,
|
||
|
set: (val) => emits('update:modelValue', val),
|
||
|
})
|
||
3 years ago
|
</script>
|
||
|
|
||
3 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>
|
||
3 years ago
|
</template>
|