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.
124 lines
2.7 KiB
124 lines
2.7 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { getMdiIcon } from '@/utils'
|
||
2 years ago
|
|
||
2 years ago
|
interface Props {
|
||
|
value: Record<string, any>
|
||
|
}
|
||
|
|
||
|
const props = defineProps<Props>()
|
||
|
const emit = defineEmits(['update:value'])
|
||
|
const vModel = useVModel(props, 'value', emit)
|
||
2 years ago
|
|
||
|
// cater existing v1 cases
|
||
2 years ago
|
const iconList = [
|
||
2 years ago
|
{
|
||
|
full: 'mdi-star',
|
||
|
empty: 'mdi-star-outline',
|
||
|
},
|
||
|
{
|
||
|
full: 'mdi-heart',
|
||
|
empty: 'mdi-heart-outline',
|
||
|
},
|
||
|
{
|
||
|
full: 'mdi-moon-full',
|
||
|
empty: 'mdi-moon-new',
|
||
|
},
|
||
|
{
|
||
|
full: 'mdi-thumb-up',
|
||
|
empty: 'mdi-thumb-up-outline',
|
||
|
},
|
||
|
{
|
||
|
full: 'mdi-flag',
|
||
|
empty: 'mdi-flag-outline',
|
||
|
},
|
||
2 years ago
|
]
|
||
2 years ago
|
|
||
2 years ago
|
const picked = computed({
|
||
2 years ago
|
get: () => vModel.value.meta.color,
|
||
2 years ago
|
set: (val) => {
|
||
2 years ago
|
vModel.value.meta.color = val
|
||
2 years ago
|
},
|
||
|
})
|
||
2 years ago
|
|
||
|
// set default value
|
||
2 years ago
|
vModel.value.meta = {
|
||
2 years ago
|
iconIdx: 0,
|
||
|
icon: {
|
||
2 years ago
|
full: 'mdi-star',
|
||
|
empty: 'mdi-star-outline',
|
||
|
},
|
||
|
color: '#fcb401',
|
||
|
max: 5,
|
||
2 years ago
|
...vModel.value.meta,
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
// antdv doesn't support object as value
|
||
|
// use iconIdx as value and update back in watch
|
||
|
const iconIdx = iconList.findIndex(
|
||
2 years ago
|
(ele) => ele.full === vModel.value.meta.icon.full && ele.empty === vModel.value.meta.icon.empty,
|
||
2 years ago
|
)
|
||
|
|
||
2 years ago
|
vModel.value.meta.iconIdx = iconIdx === -1 ? 0 : iconIdx
|
||
2 years ago
|
|
||
|
watch(
|
||
2 years ago
|
() => vModel.value.meta.iconIdx,
|
||
2 years ago
|
(v) => {
|
||
2 years ago
|
vModel.value.meta.icon = iconList[v]
|
||
2 years ago
|
},
|
||
|
)
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<a-row :gutter="8">
|
||
2 years ago
|
<a-col :span="12">
|
||
|
<a-form-item label="Icon">
|
||
2 years ago
|
<a-select v-model:value="vModel.meta.iconIdx" class="w-52">
|
||
2 years ago
|
<a-select-option v-for="(icon, i) of iconList" :key="i" :value="i">
|
||
2 years ago
|
<div class="flex items-center">
|
||
|
<component
|
||
|
:is="getMdiIcon(icon.full)"
|
||
|
class="mx-1"
|
||
|
:style="{
|
||
2 years ago
|
color: vModel.meta.color,
|
||
2 years ago
|
}"
|
||
|
/>
|
||
|
<component
|
||
|
:is="getMdiIcon(icon.empty)"
|
||
|
:style="{
|
||
2 years ago
|
color: vModel.meta.color,
|
||
2 years ago
|
}"
|
||
|
/>
|
||
|
</div>
|
||
2 years ago
|
</a-select-option>
|
||
|
</a-select>
|
||
|
</a-form-item>
|
||
|
</a-col>
|
||
|
<a-col :span="12">
|
||
|
<a-form-item label="Max">
|
||
2 years ago
|
<a-select v-model:value="vModel.meta.max" class="w-52">
|
||
2 years ago
|
<a-select-option v-for="(v, i) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" :key="i" :value="v">
|
||
|
{{ v }}
|
||
|
</a-select-option>
|
||
|
</a-select>
|
||
|
</a-form-item>
|
||
|
</a-col>
|
||
|
</a-row>
|
||
2 years ago
|
<a-row class="w-full justify-center">
|
||
2 years ago
|
<GeneralColorPicker
|
||
|
v-model="picked"
|
||
|
:row-size="8"
|
||
|
:colors="['#fcb401', '#faa307', '#f48c06', '#e85d04', '#dc2f02', '#d00000', '#9d0208', '#777']"
|
||
|
/>
|
||
2 years ago
|
</a-row>
|
||
2 years ago
|
</template>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
.color-selector:hover {
|
||
|
@apply brightness-90;
|
||
|
}
|
||
|
|
||
|
.color-selector.selected {
|
||
|
@apply py-[5px] px-[10px] brightness-90;
|
||
|
}
|
||
|
</style>
|