|
|
@ -1,13 +1,25 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { useVModel } from '@vueuse/core' |
|
|
|
import { useVModel } from '@vueuse/core' |
|
|
|
import { useLTARStoreOrThrow } from '~/composables' |
|
|
|
import { useLTARStoreOrThrow } from '~/composables' |
|
|
|
|
|
|
|
import MdiReloadIcon from '~icons/mdi/reload' |
|
|
|
|
|
|
|
import MdiDeleteIcon from '~icons/mdi/delete-outline' |
|
|
|
|
|
|
|
import MdiUnlinkIcon from '~icons/mdi/link-variant-remove' |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{ modelValue?: boolean }>() |
|
|
|
const props = defineProps<{ modelValue?: boolean }>() |
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
const emit = defineEmits(['update:modelValue', 'attachRecord']) |
|
|
|
|
|
|
|
|
|
|
|
const vModel = useVModel(props, 'modelValue', emit) |
|
|
|
const vModel = useVModel(props, 'modelValue', emit) |
|
|
|
|
|
|
|
|
|
|
|
const { childrenList, loadChildrenList, childrenListPagination, relatedTablePrimaryValueProp, unlink } = useLTARStoreOrThrow() |
|
|
|
const { |
|
|
|
|
|
|
|
childrenList, |
|
|
|
|
|
|
|
meta, |
|
|
|
|
|
|
|
deleteRelatedRow, |
|
|
|
|
|
|
|
loadChildrenList, |
|
|
|
|
|
|
|
childrenListPagination, |
|
|
|
|
|
|
|
relatedTablePrimaryValueProp, |
|
|
|
|
|
|
|
unlink, |
|
|
|
|
|
|
|
} = |
|
|
|
|
|
|
|
useLTARStoreOrThrow() |
|
|
|
|
|
|
|
|
|
|
|
watch(vModel, () => { |
|
|
|
watch(vModel, () => { |
|
|
|
if (vModel.value) { |
|
|
|
if (vModel.value) { |
|
|
@ -24,20 +36,43 @@ const unlinkRow = async (row: Record<string, any>) => { |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<a-modal v-model:visible="vModel" :footer="null" title="Child list"> |
|
|
|
<a-modal v-model:visible="vModel" :footer="null" title="Child list"> |
|
|
|
<div class="max-h-[max(calc(100vh_-_300px)_,500px)] flex flex-col"> |
|
|
|
<div class="max-h-[max(calc(100vh_-_300px)_,500px)] flex flex-col"> |
|
|
|
<div class="flex-1 overflow-auto min-h-0"> |
|
|
|
<div class="flex mb-4 align-center gap-2"> |
|
|
|
<a-card v-for="(row, i) of childrenList?.list ?? []" :key="i" class="my-1 cursor-pointer" @click="unlinkRow(row)"> |
|
|
|
<!-- <a-input v-model:value="childrenListPagination.query" class="max-w-[200px]" size="small"></a-input> --> |
|
|
|
{{ row[relatedTablePrimaryValueProp] }} |
|
|
|
<div class="flex-1" /> |
|
|
|
</a-card> |
|
|
|
<MdiReloadIcon class="cursor-pointer text-gray-500" @click="loadChildrenList" /> |
|
|
|
|
|
|
|
<a-button type="primary" size="small" @click="emit('attachRecord')"> |
|
|
|
|
|
|
|
<div class="flex align-center gap-1"> |
|
|
|
|
|
|
|
<MdiUnlinkIcon class="text-xs text-white" @click="unlinkRow(row)" /> |
|
|
|
|
|
|
|
Link to '{{ meta.title }}' |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</a-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<a-pagination |
|
|
|
<template v-if="childrenList?.pageInfo?.totalRows"> |
|
|
|
v-if="childrenList?.pageInfo" |
|
|
|
<div class="flex-1 overflow-auto min-h-0"> |
|
|
|
v-model:current="childrenListPagination.page" |
|
|
|
<a-card v-for="(row, i) of childrenList?.list ?? []" :key="i" class="ma-2 hover:(!bg-gray-200/50 shadow-md)"> |
|
|
|
v-model:page-size="childrenListPagination.size" |
|
|
|
<div class="flex align-center"> |
|
|
|
class="mt-2 mx-auto" |
|
|
|
<div class="flex-grow overflow-hidden min-w-0"> |
|
|
|
size="small" |
|
|
|
{{ row[relatedTablePrimaryValueProp] }} |
|
|
|
:total="childrenList.pageInfo.totalRows" |
|
|
|
</div> |
|
|
|
show-less-items |
|
|
|
<div class="flex gap-2"> |
|
|
|
/> |
|
|
|
<MdiUnlinkIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="unlinkRow(row)" /> |
|
|
|
|
|
|
|
<MdiDeleteIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" |
|
|
|
|
|
|
|
@click="deleteRelatedRow(row)" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</a-card> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<a-pagination |
|
|
|
|
|
|
|
v-if="childrenList?.pageInfo" |
|
|
|
|
|
|
|
v-model:current="childrenListPagination.page" |
|
|
|
|
|
|
|
v-model:page-size="childrenListPagination.size" |
|
|
|
|
|
|
|
class="mt-2 mx-auto" |
|
|
|
|
|
|
|
size="small" |
|
|
|
|
|
|
|
:total="childrenList.pageInfo.totalRows" |
|
|
|
|
|
|
|
show-less-items |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<a-empty class="my-10" v-else /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-modal> |
|
|
|
</a-modal> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|