|
|
|
@ -3,8 +3,8 @@ import { Empty, Modal } from 'ant-design-vue'
|
|
|
|
|
import type { ColumnType } from 'nocodb-sdk' |
|
|
|
|
import { |
|
|
|
|
ColumnInj, |
|
|
|
|
EditModeInj, |
|
|
|
|
IsFormInj, |
|
|
|
|
ReadonlyInj, |
|
|
|
|
computed, |
|
|
|
|
useLTARStoreOrThrow, |
|
|
|
|
useSmartsheetRowStoreOrThrow, |
|
|
|
@ -24,7 +24,7 @@ const isForm = inject(IsFormInj, ref(false))
|
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj) |
|
|
|
|
|
|
|
|
|
const editEnabled = inject(EditModeInj) |
|
|
|
|
const readonly = inject(ReadonlyInj, false) |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
childrenList, |
|
|
|
@ -43,7 +43,7 @@ const { isNew, state, removeLTARRef } = useSmartsheetRowStoreOrThrow()
|
|
|
|
|
watch( |
|
|
|
|
[vModel, isForm], |
|
|
|
|
(nextVal) => { |
|
|
|
|
if (nextVal[0] || nextVal[1]) { |
|
|
|
|
if ((nextVal[0] || nextVal[1]) && !isNew.value) { |
|
|
|
|
loadChildrenList() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -59,6 +59,12 @@ const unlinkRow = async (row: Record<string, any>) => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const unlinkIfNewRow = async (row: Record<string, any>) => { |
|
|
|
|
if (isNew.value) { |
|
|
|
|
removeLTARRef(row, column?.value as ColumnType) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const container = computed(() => |
|
|
|
|
isForm?.value |
|
|
|
|
? h('div', { |
|
|
|
@ -79,7 +85,7 @@ const expandedFormRow = ref()
|
|
|
|
|
|
|
|
|
|
<MdiReload v-if="!isForm" class="cursor-pointer text-gray-500" @click="loadChildrenList" /> |
|
|
|
|
|
|
|
|
|
<a-button v-if="editEnabled" type="primary" ghost class="!text-xs" size="small" @click="emit('attachRecord')"> |
|
|
|
|
<a-button v-if="!readonly" type="primary" ghost class="!text-xs" size="small" @click="emit('attachRecord')"> |
|
|
|
|
<div class="flex align-center gap-1"> |
|
|
|
|
<MdiLinkVariantRemove class="text-xs" type="primary" @click="unlinkRow(row)" /> |
|
|
|
|
Link to '{{ meta.title }}' |
|
|
|
@ -101,18 +107,19 @@ const expandedFormRow = ref()
|
|
|
|
|
> |
|
|
|
|
<div class="flex align-center"> |
|
|
|
|
<div class="flex-grow overflow-hidden min-w-0"> |
|
|
|
|
{{ row[relatedTablePrimaryValueProp] |
|
|
|
|
}}<span class="text-gray-400 text-[11px] ml-1">(Primary key : {{ getRelatedTableRowId(row) }})</span> |
|
|
|
|
{{ row[relatedTablePrimaryValueProp] }} |
|
|
|
|
<span class="text-gray-400 text-[11px] ml-1">(Primary key : {{ getRelatedTableRowId(row) }})</span> |
|
|
|
|
</div> |
|
|
|
|
<div class="flex-1"></div> |
|
|
|
|
<div v-if="editEnabled" class="flex gap-2"> |
|
|
|
|
<div v-if="!readonly" class="flex gap-2"> |
|
|
|
|
<MdiLinkVariantRemove |
|
|
|
|
class="text-xs text-grey hover:(!text-red-500) cursor-pointer" |
|
|
|
|
@click.stop="unlinkRow(row)" |
|
|
|
|
/> |
|
|
|
|
<MdiDeleteOutline |
|
|
|
|
v-if="!readonly" |
|
|
|
|
class="text-xs text-grey hover:(!text-red-500) cursor-pointer" |
|
|
|
|
@click.stop="deleteRelatedRow(row)" |
|
|
|
|
@click.stop="deleteRelatedRow(row, unlinkIfNewRow)" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -128,7 +135,12 @@ const expandedFormRow = ref()
|
|
|
|
|
show-less-items |
|
|
|
|
/> |
|
|
|
|
</template> |
|
|
|
|
<a-empty v-else class="my-10" :image="Empty.PRESENTED_IMAGE_SIMPLE" /> |
|
|
|
|
<a-empty |
|
|
|
|
v-else |
|
|
|
|
:class="{ 'my-10': !isForm, 'my-1 !text-xs': isForm }" |
|
|
|
|
:image="Empty.PRESENTED_IMAGE_SIMPLE" |
|
|
|
|
:image-style="isForm ? { height: '20px' } : {}" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<Suspense> |
|
|
|
|