From 1cb745160dac1828a34485ae79a6a4c8a349ddbf Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 5 Aug 2022 16:14:16 +0800 Subject: [PATCH 1/2] fix(gui-v2): rating select object value issue --- .../smartsheet-column/RatingOptions.vue | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue b/packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue index 7907a710e6..b5d4bf9640 100644 --- a/packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue +++ b/packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue @@ -35,7 +35,8 @@ const picked = ref(formState.value.meta.color || enumColor.light[0]) // set default value formState.value.meta = { - icons: { + iconIdx: 0, + icon: { full: 'mdi-star', empty: 'mdi-star-outline', }, @@ -43,22 +44,36 @@ formState.value.meta = { max: 5, ...formState.value.meta, } + +// antdv doesn't support object as value +// use iconIdx as value and update back in watch +const iconIdx = iconList.findIndex( + (ele) => ele.full === formState.value.meta.icon.full && ele.empty === formState.value.meta.icon.empty, +) + +formState.value.meta.iconIdx = iconIdx === -1 ? 0 : iconIdx + +watch( + () => formState.value.meta.iconIdx, + (v) => { + formState.value.meta.icon = iconList[v] + }, +)