Browse Source

refactor(gui-v2): use vModel

pull/2907/head
Wing-Kam Wong 2 years ago
parent
commit
844792f812
  1. 12
      packages/nc-gui-v2/components/cell/Rating.vue

12
packages/nc-gui-v2/components/cell/Rating.vue

@ -12,9 +12,9 @@ interface Props {
readOnly?: boolean
}
const { modelValue: value, readOnly } = defineProps<Props>()
const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
const emits = defineEmits(['update:modelValue'])
const column = inject(ColumnInj)
@ -29,14 +29,12 @@ const ratingMeta = computed(() => {
...(column?.meta || {}),
}
})
const localState = computed({
get: () => value,
set: (val: any) => emit('update:modelValue', val),
})
const vModel = useVModel(props, 'modelValue', emits)
</script>
<template>
<a-rate v-model:value="localState" :count="ratingMeta.max" :style="`color: ${ratingMeta.color}`">
<a-rate v-model:value="vModel" :count="ratingMeta.max" :style="`color: ${ratingMeta.color}`" :disabled="props.readOnly">
<template #character>
<MdiStarIcon v-if="ratingMeta.icon.full === 'mdi-star'" class="text-sm" />
<MdiHeartIcon v-if="ratingMeta.icon.full === 'mdi-heart'" class="text-sm" />

Loading…
Cancel
Save