Browse Source

feat(nc-gui): pass belongsToColumn to ItemChip & ListItems

pull/5724/head
Wing-Kam Wong 1 year ago
parent
commit
6ce3ee312f
  1. 16
      packages/nc-gui/components/virtual-cell/BelongsTo.vue

16
packages/nc-gui/components/virtual-cell/BelongsTo.vue

@ -42,7 +42,7 @@ const listItemsDlg = ref(false)
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow() const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { loadRelatedTableMeta, relatedTableDisplayValueProp, unlink } = useProvideLTARStore( const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, unlink } = useProvideLTARStore(
column as Ref<Required<ColumnType>>, column as Ref<Required<ColumnType>>,
row, row,
isNew, isNew,
@ -78,13 +78,23 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
break break
} }
}) })
const belongsToColumn = computed(
() =>
relatedTableMeta.value?.columns?.find((c: any) => c.title === relatedTableDisplayValueProp.value) as ColumnType | undefined,
)
</script> </script>
<template> <template>
<div class="flex w-full chips-wrapper items-center" :class="{ active }"> <div class="flex w-full chips-wrapper items-center" :class="{ active }">
<div class="chips flex items-center flex-1"> <div class="chips flex items-center flex-1">
<template v-if="value && relatedTableDisplayValueProp"> <template v-if="value && relatedTableDisplayValueProp">
<VirtualCellComponentsItemChip :item="value" :value="value[relatedTableDisplayValueProp]" @unlink="unlinkRef(value)" /> <VirtualCellComponentsItemChip
:item="value"
:value="value[relatedTableDisplayValueProp]"
:column="belongsToColumn"
@unlink="unlinkRef(value)"
/>
</template> </template>
</div> </div>
@ -99,7 +109,7 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
/> />
</div> </div>
<LazyVirtualCellComponentsListItems v-model="listItemsDlg" @attach-record="listItemsDlg = true" /> <LazyVirtualCellComponentsListItems v-model="listItemsDlg" :column="belongsToColumn" @attach-record="listItemsDlg = true" />
</div> </div>
</template> </template>

Loading…
Cancel
Save