多维表格
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.

168 lines
4.1 KiB

<script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import {
ActiveCellInj,
CellValueInj,
ColumnInj,
IsFormInj,
IsUnderLookupInj,
ReadonlyInj,
ReloadRowDataHookInj,
RowInj,
computed,
createEventHook,
inject,
ref,
useProvideLTARStore,
useRoles,
useSelectedCellKeyupListener,
useSmartsheetRowStoreOrThrow,
} from '#imports'
const column = inject(ColumnInj)!
const reloadRowTrigger = inject(ReloadRowDataHookInj, createEventHook())
const cellValue = inject(CellValueInj, ref<any>(null))
const row = inject(RowInj)!
const active = inject(ActiveCellInj)!
const readOnly = inject(ReadonlyInj, ref(false))
const isForm = inject(IsFormInj, ref(false))
const isUnderLookup = inject(IsUnderLookupInj, ref(false))
const { isUIAllowed } = useRoles()
const listItemsDlg = ref(false)
Nc feat/link record dropdown (#8345) * feat(nc-gui): link record dropdown setup * fix(nc-gui): move link record pagination to the bottom * feat(nc-gui): link record new design * fix(nc-gui): update bank state subtitle * fix(nc-gui): small changes * fix(nc-gui): update skeleton of link records item * fix(nc-gui): ui break issue * fix(nc-gui): increase z index of link dropdown overlay * fix(nc-gui): update link record dropdown header * fix(nc-gui): update link record dropdown * fix(nc-gui): new changes * fix: remove margin * fix(nc-gui): unlinked records empty state alignment * fix(nc-gui): make tooltip text size 14px * fix(nc-gui): reduce subtext font size * fix(nc-gui): link record item rich text cell alignment issue * fix(nc-gui): on esc link record dropdown should close * fix(nc-gui): update link record header and footer height * fix(nc-gui): add link record dropdown for bt cell * fix(nc-gui): fix invalid offset issue * fix(nc-gui): link record z index issue * fix: PW link unlink corrections * fix(nc-gui): link record dropdown close on outside issue in expanded form * fix(nc-gui): close dropdown after adding link in bt cell * fix(nc-gui): allow close link record dropdown on esc * fix(nc-gui): add link record dropdown in mm component * fix(nc-gui): add link record dropdown in hm component * fix(nc-gui): add link record dropdown in oo component * fix: auto close for BT * fix: ltar modal operations * fix: close link modal * fix: PW tests (wip) * test: fix link modal close in share view * test: fix LTAR in cell handling * fix(nc-gui): reduce link items skeleton height * fix(nc-gui): expanded form open issue on clicking bt cell record * fix(nc-gui): hide back btn if user directly opens record list dropdown * fix(nc-gui): reset offset when user opens link record dropdwon and switch between linked and unlinked records * fix(nc-gui): link record item height * fix(nc-gui): linked record list reload issue on link/unlink * fix(nc-gui): link record item subtext fields width should be same * fix(nc-gui): email, url cell truncate text issue * fix(nc-gui): shared form link record dropdwon ui * chore(nc-gui): lint * fix(nc-gu): small changes * fix(nc-gui): ai review changes * fix(nc-gui): link record list offset issue * fix(nc-gui): show plus btn in bt cell even if it is not blank * fix(nc-gui): barcode visiblility issue in link record dropdown * fix(nc-gui): do not focus links cell plus btn on close dropdown * fix(nc-gui): text color * fix(nc-gui): skip showing qr code null value * fix(nc-gui): virtual cell margin left issue in link record dropdwon * fix(nc-gui): link record subtext order should be same as default view col order * chore(nc-gui): lint * refactor(nocodb): add default view column order in col meta * fix(nc-gui): update default view order on reordering column from fields menu --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
7 months ago
const isOpen = ref(false)
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, relatedTableDisplayValuePropId, unlink } =
useProvideLTARStore(column as Ref<Required<ColumnType>>, row, isNew, reloadRowTrigger.trigger)
await loadRelatedTableMeta()
const value = computed(() => {
if (cellValue?.value) {
return cellValue?.value
} else if (isNew.value) {
return state?.value?.[column?.value.title as string]
}
return null
})
const unlinkRef = async (rec: Record<string, any>) => {
if (isNew.value) {
await removeLTARRef(rec, column?.value as ColumnType)
} else {
await unlink(rec)
}
}
useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
switch (e.key) {
case 'Enter':
listItemsDlg.value = true
e.stopPropagation()
break
}
})
const belongsToColumn = computed(
() =>
relatedTableMeta.value?.columns?.find((c: any) => c.title === relatedTableDisplayValueProp.value) as ColumnType | undefined,
)
Nc feat/link record dropdown (#8345) * feat(nc-gui): link record dropdown setup * fix(nc-gui): move link record pagination to the bottom * feat(nc-gui): link record new design * fix(nc-gui): update bank state subtitle * fix(nc-gui): small changes * fix(nc-gui): update skeleton of link records item * fix(nc-gui): ui break issue * fix(nc-gui): increase z index of link dropdown overlay * fix(nc-gui): update link record dropdown header * fix(nc-gui): update link record dropdown * fix(nc-gui): new changes * fix: remove margin * fix(nc-gui): unlinked records empty state alignment * fix(nc-gui): make tooltip text size 14px * fix(nc-gui): reduce subtext font size * fix(nc-gui): link record item rich text cell alignment issue * fix(nc-gui): on esc link record dropdown should close * fix(nc-gui): update link record header and footer height * fix(nc-gui): add link record dropdown for bt cell * fix(nc-gui): fix invalid offset issue * fix(nc-gui): link record z index issue * fix: PW link unlink corrections * fix(nc-gui): link record dropdown close on outside issue in expanded form * fix(nc-gui): close dropdown after adding link in bt cell * fix(nc-gui): allow close link record dropdown on esc * fix(nc-gui): add link record dropdown in mm component * fix(nc-gui): add link record dropdown in hm component * fix(nc-gui): add link record dropdown in oo component * fix: auto close for BT * fix: ltar modal operations * fix: close link modal * fix: PW tests (wip) * test: fix link modal close in share view * test: fix LTAR in cell handling * fix(nc-gui): reduce link items skeleton height * fix(nc-gui): expanded form open issue on clicking bt cell record * fix(nc-gui): hide back btn if user directly opens record list dropdown * fix(nc-gui): reset offset when user opens link record dropdwon and switch between linked and unlinked records * fix(nc-gui): link record item height * fix(nc-gui): linked record list reload issue on link/unlink * fix(nc-gui): link record item subtext fields width should be same * fix(nc-gui): email, url cell truncate text issue * fix(nc-gui): shared form link record dropdwon ui * chore(nc-gui): lint * fix(nc-gu): small changes * fix(nc-gui): ai review changes * fix(nc-gui): link record list offset issue * fix(nc-gui): show plus btn in bt cell even if it is not blank * fix(nc-gui): barcode visiblility issue in link record dropdown * fix(nc-gui): do not focus links cell plus btn on close dropdown * fix(nc-gui): text color * fix(nc-gui): skip showing qr code null value * fix(nc-gui): virtual cell margin left issue in link record dropdwon * fix(nc-gui): link record subtext order should be same as default view col order * chore(nc-gui): lint * refactor(nocodb): add default view column order in col meta * fix(nc-gui): update default view order on reordering column from fields menu --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
7 months ago
watch(listItemsDlg, () => {
isOpen.value = listItemsDlg.value
})
// When isOpen is false, ensure the listItemsDlg is also closed.
watch(
isOpen,
(next) => {
if (!next) {
listItemsDlg.value = false
}
},
{ flush: 'post' },
)
Nc feat/link record dropdown (#8345) * feat(nc-gui): link record dropdown setup * fix(nc-gui): move link record pagination to the bottom * feat(nc-gui): link record new design * fix(nc-gui): update bank state subtitle * fix(nc-gui): small changes * fix(nc-gui): update skeleton of link records item * fix(nc-gui): ui break issue * fix(nc-gui): increase z index of link dropdown overlay * fix(nc-gui): update link record dropdown header * fix(nc-gui): update link record dropdown * fix(nc-gui): new changes * fix: remove margin * fix(nc-gui): unlinked records empty state alignment * fix(nc-gui): make tooltip text size 14px * fix(nc-gui): reduce subtext font size * fix(nc-gui): link record item rich text cell alignment issue * fix(nc-gui): on esc link record dropdown should close * fix(nc-gui): update link record header and footer height * fix(nc-gui): add link record dropdown for bt cell * fix(nc-gui): fix invalid offset issue * fix(nc-gui): link record z index issue * fix: PW link unlink corrections * fix(nc-gui): link record dropdown close on outside issue in expanded form * fix(nc-gui): close dropdown after adding link in bt cell * fix(nc-gui): allow close link record dropdown on esc * fix(nc-gui): add link record dropdown in mm component * fix(nc-gui): add link record dropdown in hm component * fix(nc-gui): add link record dropdown in oo component * fix: auto close for BT * fix: ltar modal operations * fix: close link modal * fix: PW tests (wip) * test: fix link modal close in share view * test: fix LTAR in cell handling * fix(nc-gui): reduce link items skeleton height * fix(nc-gui): expanded form open issue on clicking bt cell record * fix(nc-gui): hide back btn if user directly opens record list dropdown * fix(nc-gui): reset offset when user opens link record dropdwon and switch between linked and unlinked records * fix(nc-gui): link record item height * fix(nc-gui): linked record list reload issue on link/unlink * fix(nc-gui): link record item subtext fields width should be same * fix(nc-gui): email, url cell truncate text issue * fix(nc-gui): shared form link record dropdwon ui * chore(nc-gui): lint * fix(nc-gu): small changes * fix(nc-gui): ai review changes * fix(nc-gui): link record list offset issue * fix(nc-gui): show plus btn in bt cell even if it is not blank * fix(nc-gui): barcode visiblility issue in link record dropdown * fix(nc-gui): do not focus links cell plus btn on close dropdown * fix(nc-gui): text color * fix(nc-gui): skip showing qr code null value * fix(nc-gui): virtual cell margin left issue in link record dropdwon * fix(nc-gui): link record subtext order should be same as default view col order * chore(nc-gui): lint * refactor(nocodb): add default view column order in col meta * fix(nc-gui): update default view order on reordering column from fields menu --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
7 months ago
watch(value, (next) => {
if (next) {
isOpen.value = false
}
})
</script>
<template>
<div class="flex w-full chips-wrapper items-center" :class="{ active }">
Nc feat/link record dropdown (#8345) * feat(nc-gui): link record dropdown setup * fix(nc-gui): move link record pagination to the bottom * feat(nc-gui): link record new design * fix(nc-gui): update bank state subtitle * fix(nc-gui): small changes * fix(nc-gui): update skeleton of link records item * fix(nc-gui): ui break issue * fix(nc-gui): increase z index of link dropdown overlay * fix(nc-gui): update link record dropdown header * fix(nc-gui): update link record dropdown * fix(nc-gui): new changes * fix: remove margin * fix(nc-gui): unlinked records empty state alignment * fix(nc-gui): make tooltip text size 14px * fix(nc-gui): reduce subtext font size * fix(nc-gui): link record item rich text cell alignment issue * fix(nc-gui): on esc link record dropdown should close * fix(nc-gui): update link record header and footer height * fix(nc-gui): add link record dropdown for bt cell * fix(nc-gui): fix invalid offset issue * fix(nc-gui): link record z index issue * fix: PW link unlink corrections * fix(nc-gui): link record dropdown close on outside issue in expanded form * fix(nc-gui): close dropdown after adding link in bt cell * fix(nc-gui): allow close link record dropdown on esc * fix(nc-gui): add link record dropdown in mm component * fix(nc-gui): add link record dropdown in hm component * fix(nc-gui): add link record dropdown in oo component * fix: auto close for BT * fix: ltar modal operations * fix: close link modal * fix: PW tests (wip) * test: fix link modal close in share view * test: fix LTAR in cell handling * fix(nc-gui): reduce link items skeleton height * fix(nc-gui): expanded form open issue on clicking bt cell record * fix(nc-gui): hide back btn if user directly opens record list dropdown * fix(nc-gui): reset offset when user opens link record dropdwon and switch between linked and unlinked records * fix(nc-gui): link record item height * fix(nc-gui): linked record list reload issue on link/unlink * fix(nc-gui): link record item subtext fields width should be same * fix(nc-gui): email, url cell truncate text issue * fix(nc-gui): shared form link record dropdwon ui * chore(nc-gui): lint * fix(nc-gu): small changes * fix(nc-gui): ai review changes * fix(nc-gui): link record list offset issue * fix(nc-gui): show plus btn in bt cell even if it is not blank * fix(nc-gui): barcode visiblility issue in link record dropdown * fix(nc-gui): do not focus links cell plus btn on close dropdown * fix(nc-gui): text color * fix(nc-gui): skip showing qr code null value * fix(nc-gui): virtual cell margin left issue in link record dropdwon * fix(nc-gui): link record subtext order should be same as default view col order * chore(nc-gui): lint * refactor(nocodb): add default view column order in col meta * fix(nc-gui): update default view order on reordering column from fields menu --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
7 months ago
<LazyVirtualCellComponentsLinkRecordDropdown v-model:is-open="isOpen">
<div class="flex items-center w-full">
<div class="nc-cell-field chips flex items-center flex-1">
<template v-if="value && (relatedTableDisplayValueProp || relatedTableDisplayValuePropId)">
<VirtualCellComponentsItemChip
:item="value"
:value="
!Array.isArray(value) && typeof value === 'object'
? value[relatedTableDisplayValueProp] ?? value[relatedTableDisplayValuePropId]
: value
"
:column="belongsToColumn"
:show-unlink-button="true"
@unlink="unlinkRef(value)"
/>
</template>
</div>
<div
v-if="!readOnly && (isUIAllowed('dataEdit') || isForm) && !isUnderLookup"
class="flex-none flex group items-center min-w-4"
tabindex="0"
@keydown.enter.stop="listItemsDlg = true"
>
<GeneralIcon
icon="plus"
class="flex-none select-none !text-md text-gray-700 nc-action-icon nc-plus invisible group-hover:visible group-focus:visible"
@click.stop="listItemsDlg = true"
/>
</div>
</div>
<template #overlay>
<LazyVirtualCellComponentsUnLinkedItems
v-if="listItemsDlg"
v-model="listItemsDlg"
:column="belongsToColumn"
Nc feat/link record dropdown (#8345) * feat(nc-gui): link record dropdown setup * fix(nc-gui): move link record pagination to the bottom * feat(nc-gui): link record new design * fix(nc-gui): update bank state subtitle * fix(nc-gui): small changes * fix(nc-gui): update skeleton of link records item * fix(nc-gui): ui break issue * fix(nc-gui): increase z index of link dropdown overlay * fix(nc-gui): update link record dropdown header * fix(nc-gui): update link record dropdown * fix(nc-gui): new changes * fix: remove margin * fix(nc-gui): unlinked records empty state alignment * fix(nc-gui): make tooltip text size 14px * fix(nc-gui): reduce subtext font size * fix(nc-gui): link record item rich text cell alignment issue * fix(nc-gui): on esc link record dropdown should close * fix(nc-gui): update link record header and footer height * fix(nc-gui): add link record dropdown for bt cell * fix(nc-gui): fix invalid offset issue * fix(nc-gui): link record z index issue * fix: PW link unlink corrections * fix(nc-gui): link record dropdown close on outside issue in expanded form * fix(nc-gui): close dropdown after adding link in bt cell * fix(nc-gui): allow close link record dropdown on esc * fix(nc-gui): add link record dropdown in mm component * fix(nc-gui): add link record dropdown in hm component * fix(nc-gui): add link record dropdown in oo component * fix: auto close for BT * fix: ltar modal operations * fix: close link modal * fix: PW tests (wip) * test: fix link modal close in share view * test: fix LTAR in cell handling * fix(nc-gui): reduce link items skeleton height * fix(nc-gui): expanded form open issue on clicking bt cell record * fix(nc-gui): hide back btn if user directly opens record list dropdown * fix(nc-gui): reset offset when user opens link record dropdwon and switch between linked and unlinked records * fix(nc-gui): link record item height * fix(nc-gui): linked record list reload issue on link/unlink * fix(nc-gui): link record item subtext fields width should be same * fix(nc-gui): email, url cell truncate text issue * fix(nc-gui): shared form link record dropdwon ui * chore(nc-gui): lint * fix(nc-gu): small changes * fix(nc-gui): ai review changes * fix(nc-gui): link record list offset issue * fix(nc-gui): show plus btn in bt cell even if it is not blank * fix(nc-gui): barcode visiblility issue in link record dropdown * fix(nc-gui): do not focus links cell plus btn on close dropdown * fix(nc-gui): text color * fix(nc-gui): skip showing qr code null value * fix(nc-gui): virtual cell margin left issue in link record dropdwon * fix(nc-gui): link record subtext order should be same as default view col order * chore(nc-gui): lint * refactor(nocodb): add default view column order in col meta * fix(nc-gui): update default view order on reordering column from fields menu --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
7 months ago
hide-back-btn
/> </template
></LazyVirtualCellComponentsLinkRecordDropdown>
</div>
</template>
<style scoped lang="scss">
.nc-action-icon {
11 months ago
@apply cursor-pointer;
}
.chips-wrapper:hover,
.chips-wrapper.active {
.nc-action-icon {
@apply inline-block;
}
}
11 months ago
.chips-wrapper:hover {
.nc-action-icon {
@apply visible;
}
}
</style>