Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: Lock pre-filled as readonly is not working for virtual links fields

Ramesh Maneb7cf7b690693
diff --git a/packages/nc-gui/components/virtual-cell/BelongsTo.vue b/packages/nc-gui/components/virtual-cell/BelongsTo.vue
index 35f08a6b17..fc4ed637ab 100644
--- a/packages/nc-gui/components/virtual-cell/BelongsTo.vue
+++ b/packages/nc-gui/components/virtual-cell/BelongsTo.vue
@@ -47,7 +47,7 @@ const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, re
await loadRelatedTableMeta()
const hasEditPermission = computed(() => {
- return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || isForm.value
+ return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || (isForm.value && !readOnly.value)
})
const value = computed(() => {
@@ -165,6 +165,7 @@ onUnmounted(() => {
"
:column="belongsToColumn"
:show-unlink-button="true"
+ :readonly="readOnly"
@unlink="unlinkRef(value)"
/>
</template>
diff --git a/packages/nc-gui/components/virtual-cell/HasMany.vue b/packages/nc-gui/components/virtual-cell/HasMany.vue
index e73b441ed3..6f8060b116 100644
--- a/packages/nc-gui/components/virtual-cell/HasMany.vue
+++ b/packages/nc-gui/components/virtual-cell/HasMany.vue
@@ -56,7 +56,7 @@ const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, un
await loadRelatedTableMeta()
const hasEditPermission = computed(() => {
- return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || isForm.value
+ return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || (isForm.value && !readOnly.value)
})
const localCellValue = computed<any[]>(() => {
@@ -215,6 +215,7 @@ onUnmounted(() => {
:column="hasManyColumn"
:show-unlink-button="false"
:truncate="false"
+ :readonly="readOnly"
@unlink="unlinkRef(cell.item)"
/>
diff --git a/packages/nc-gui/components/virtual-cell/Links.vue b/packages/nc-gui/components/virtual-cell/Links.vue
index f7c946496b..c13bb49a5a 100644
--- a/packages/nc-gui/components/virtual-cell/Links.vue
+++ b/packages/nc-gui/components/virtual-cell/Links.vue
@@ -58,7 +58,7 @@ const relatedTableDisplayColumn = computed(
loadRelatedTableMeta()
const hasEditPermission = computed(() => {
- return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || isForm.value
+ return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || (isForm.value && !readOnly.value)
})
const textVal = computed(() => {
@@ -203,8 +203,8 @@ onUnmounted(() => {
class="text-center nc-datatype-link underline-transparent nc-canvas-links-text font-weight-500"
:class="{ '!text-gray-300': !textVal }"
:tabindex="readOnly ? -1 : 0"
- @click.stop.prevent="isForm && !isExpandedFormOpen ? openListDlg() : openChildList()"
- @keydown.enter.stop.prevent="isForm && !isExpandedFormOpen ? openListDlg() : openChildList"
+ @click.stop.prevent="isForm && !isExpandedFormOpen && hasEditPermission ? openListDlg() : openChildList()"
+ @keydown.enter.stop.prevent="isForm && !isExpandedFormOpen && hasEditPermission ? openListDlg() : openChildList"
>
{{ textVal }}
</component>
diff --git a/packages/nc-gui/components/virtual-cell/ManyToMany.vue b/packages/nc-gui/components/virtual-cell/ManyToMany.vue
index c072080c03..a377baaa39 100644
--- a/packages/nc-gui/components/virtual-cell/ManyToMany.vue
+++ b/packages/nc-gui/components/virtual-cell/ManyToMany.vue
@@ -55,7 +55,7 @@ const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, un
await loadRelatedTableMeta()
const hasEditPermission = computed(() => {
- return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || isForm.value
+ return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || (isForm.value && !readOnly.value)
})
const localCellValue = computed<any[]>(() => {
@@ -213,6 +213,7 @@ onUnmounted(() => {
:column="m2mColumn"
:show-unlink-button="false"
:truncate="false"
+ :readonly="readOnly"
@unlink="unlinkRef(cell.item)"
/>
diff --git a/packages/nc-gui/components/virtual-cell/OneToOne.vue b/packages/nc-gui/components/virtual-cell/OneToOne.vue
index f20ef68521..48455bfe28 100644
--- a/packages/nc-gui/components/virtual-cell/OneToOne.vue
+++ b/packages/nc-gui/components/virtual-cell/OneToOne.vue
@@ -47,7 +47,7 @@ const { relatedTableMeta, loadRelatedTableMeta, relatedTableDisplayValueProp, re
await loadRelatedTableMeta()
const hasEditPermission = computed(() => {
- return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || isForm.value
+ return (!readOnly.value && isUIAllowed('dataEdit') && !isUnderLookup.value) || (isForm.value && !readOnly.value)
})
const addIcon = computed(() => (cellValue?.value ? 'maximize' : 'plus'))
@@ -162,6 +162,7 @@ onUnmounted(() => {
"
:column="belongsToColumn"
:show-unlink-button="true"
+ :readonly="readOnly"
@unlink="unlinkRef(value)"
/>
</template>
diff --git a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue b/packages/nc-gui/components/virtual-cell/components/ItemChip.vue
index 5cd443783e..8b97501bec 100644
--- a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue
+++ b/packages/nc-gui/components/virtual-cell/components/ItemChip.vue
@@ -12,7 +12,12 @@ interface Props {
truncate?: boolean
}
-const { value, item, column, showUnlinkButton, border = true, readonly: readonlyProp, truncate = true } = defineProps<Props>()
+const props = withDefaults(defineProps<Props>(), {
+ border: true,
+ truncate: true,
+})
+
+const { item, value, column, readonly: readonlyProp } = toRefs(props)
const emit = defineEmits(['unlink'])
@@ -22,6 +27,8 @@ const { isUIAllowed } = useRoles()
provide(IsUnderLTARInj, ref(true))
+provide(MetaInj, relatedTableMeta)
+
const readOnly = inject(ReadonlyInj, ref(false))
const active = inject(ActiveCellInj, ref(false))
@@ -45,11 +52,11 @@ const { open } = useExpandedFormDetached()
function openExpandedForm() {
if (isClickDisabled.value) return
- const rowId = extractPkFromRow(item, relatedTableMeta.value.columns as ColumnType[])
- if (!isPublic.value && !readonlyProp && rowId) {
+ const rowId = extractPkFromRow(item.value, relatedTableMeta.value.columns as ColumnType[])
+ if (!isPublic.value && !readonlyProp.value && rowId) {
open({
isOpen: true,
- row: { row: item, rowMeta: {}, oldRow: { ...item } },
+ row: { row: item.value, rowMeta: {}, oldRow: { ...item.value } },
meta: relatedTableMeta.value,
rowId,
useMetaFields: true,
diff --git a/packages/nc-gui/components/virtual-cell/components/ListItem.vue b/packages/nc-gui/components/virtual-cell/components/ListItem.vue
index 090f4db478..48ab7b0338 100644
--- a/packages/nc-gui/components/virtual-cell/components/ListItem.vue
+++ b/packages/nc-gui/components/virtual-cell/components/ListItem.vue
@@ -159,7 +159,7 @@ const attachments: ComputedRef<Attachment[]> = computed(() => {
</div>
</div>
</div>
- <div v-if="!isForm && !isPublic" class="flex-none flex items-center w-7" @clcik.stop>
+ <div v-if="!isForm && !isPublic" class="flex-none flex items-center w-7" @click.stop>
<NcTooltip class="flex" hide-on-click>
<template #title>{{ $t('title.expand') }}</template>
@@ -173,7 +173,7 @@ const attachments: ComputedRef<Attachment[]> = computed(() => {
</button>
</NcTooltip>
</div>
- <template v-if="(!isPublic && !readOnly) || isForm">
+ <template v-if="(!isPublic && !readOnly) || (isForm && !readOnly)">
<PermissionsTooltip
class="z-10 flex"
:entity="PermissionEntity.FIELD"