|
|
@ -1,4 +1,3 @@ |
|
|
|
import { UITypes, dateFormats, parseStringDateTime, timeFormats } from 'nocodb-sdk' |
|
|
|
|
|
|
|
import type { |
|
|
|
import type { |
|
|
|
type ColumnType, |
|
|
|
type ColumnType, |
|
|
|
type LinkToAnotherRecordType, |
|
|
|
type LinkToAnotherRecordType, |
|
|
@ -7,7 +6,9 @@ import type { |
|
|
|
type RequestParams, |
|
|
|
type RequestParams, |
|
|
|
type TableType, |
|
|
|
type TableType, |
|
|
|
} from 'nocodb-sdk' |
|
|
|
} from 'nocodb-sdk' |
|
|
|
|
|
|
|
import { UITypes, dateFormats, parseStringDateTime, timeFormats } from 'nocodb-sdk' |
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
|
|
|
|
import type { Row } from '#imports' |
|
|
|
import { |
|
|
|
import { |
|
|
|
IsPublicInj, |
|
|
|
IsPublicInj, |
|
|
|
Modal, |
|
|
|
Modal, |
|
|
@ -30,7 +31,6 @@ import { |
|
|
|
useSharedView, |
|
|
|
useSharedView, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
import type { Row } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface DataApiResponse { |
|
|
|
interface DataApiResponse { |
|
|
|
list: Record<string, any> |
|
|
|
list: Record<string, any> |
|
|
@ -43,7 +43,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
column: Ref<Required<ColumnType>>, |
|
|
|
column: Ref<Required<ColumnType>>, |
|
|
|
row: Ref<Row>, |
|
|
|
row: Ref<Row>, |
|
|
|
isNewRow: ComputedRef<boolean> | Ref<boolean>, |
|
|
|
isNewRow: ComputedRef<boolean> | Ref<boolean>, |
|
|
|
reloadData = (_params: { shouldShowLoading?: boolean }) => {}, |
|
|
|
_reloadData = (_params: { shouldShowLoading?: boolean }) => {}, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
// state
|
|
|
|
// state
|
|
|
|
const { metas, getMeta } = useMetas() |
|
|
|
const { metas, getMeta } = useMetas() |
|
|
@ -66,6 +66,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
query: '', |
|
|
|
query: '', |
|
|
|
size: 10, |
|
|
|
size: 10, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
const childrenExcludedOffsetCount = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const childrenListPagination = reactive({ |
|
|
|
const childrenListPagination = reactive({ |
|
|
|
page: 1, |
|
|
|
page: 1, |
|
|
@ -73,6 +74,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
size: 10, |
|
|
|
size: 10, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childrenListOffsetCount = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const isChildrenLoading = ref(false) |
|
|
|
const isChildrenLoading = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const isChildrenListLoading = ref<Array<boolean>>([]) |
|
|
|
const isChildrenListLoading = ref<Array<boolean>>([]) |
|
|
@ -114,7 +117,6 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
.join('___'), |
|
|
|
.join('___'), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
|
|
|
const getRelatedTableRowId = (row: Record<string, any>) => { |
|
|
|
const getRelatedTableRowId = (row: Record<string, any>) => { |
|
|
|
return relatedTableMeta.value?.columns |
|
|
|
return relatedTableMeta.value?.columns |
|
|
|
?.filter((c) => c.pk) |
|
|
|
?.filter((c) => c.pk) |
|
|
@ -122,6 +124,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
.join('___') |
|
|
|
.join('___') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
|
|
|
|
|
|
|
const loadRelatedTableMeta = async () => { |
|
|
|
const loadRelatedTableMeta = async () => { |
|
|
|
await getMeta(colOptions.value.fk_related_model_id as string) |
|
|
|
await getMeta(colOptions.value.fk_related_model_id as string) |
|
|
|
} |
|
|
|
} |
|
|
@ -182,6 +186,13 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
const loadChildrenExcludedList = async (activeState?: any) => { |
|
|
|
const loadChildrenExcludedList = async (activeState?: any) => { |
|
|
|
if (activeState) newRowState.state = activeState |
|
|
|
if (activeState) newRowState.state = activeState |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
let offset = |
|
|
|
|
|
|
|
childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1) - childrenExcludedOffsetCount.value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (offset < 0) { |
|
|
|
|
|
|
|
offset = 0 |
|
|
|
|
|
|
|
childrenExcludedOffsetCount.value = 0 |
|
|
|
|
|
|
|
} |
|
|
|
isChildrenExcludedLoading.value = true |
|
|
|
isChildrenExcludedLoading.value = true |
|
|
|
if (isPublic.value) { |
|
|
|
if (isPublic.value) { |
|
|
|
const router = useRouter() |
|
|
|
const router = useRouter() |
|
|
@ -198,7 +209,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
}, |
|
|
|
}, |
|
|
|
query: { |
|
|
|
query: { |
|
|
|
limit: childrenExcludedListPagination.size, |
|
|
|
limit: childrenExcludedListPagination.size, |
|
|
|
offset: childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1), |
|
|
|
offset, |
|
|
|
where: |
|
|
|
where: |
|
|
|
childrenExcludedListPagination.query && |
|
|
|
childrenExcludedListPagination.query && |
|
|
|
`(${relatedTableDisplayValueProp.value},like,${childrenExcludedListPagination.query})`, |
|
|
|
`(${relatedTableDisplayValueProp.value},like,${childrenExcludedListPagination.query})`, |
|
|
@ -215,7 +226,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
relatedTableMeta?.value?.id as string, |
|
|
|
relatedTableMeta?.value?.id as string, |
|
|
|
{ |
|
|
|
{ |
|
|
|
limit: childrenExcludedListPagination.size, |
|
|
|
limit: childrenExcludedListPagination.size, |
|
|
|
offset: childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1), |
|
|
|
offset, |
|
|
|
where: |
|
|
|
where: |
|
|
|
childrenExcludedListPagination.query && |
|
|
|
childrenExcludedListPagination.query && |
|
|
|
`(${relatedTableDisplayValueProp.value},like,${childrenExcludedListPagination.query})`, |
|
|
|
`(${relatedTableDisplayValueProp.value},like,${childrenExcludedListPagination.query})`, |
|
|
@ -232,7 +243,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
column?.value?.id, |
|
|
|
column?.value?.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
limit: String(childrenExcludedListPagination.size), |
|
|
|
limit: String(childrenExcludedListPagination.size), |
|
|
|
offset: String(childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1)), |
|
|
|
offset: String(offset), |
|
|
|
// todo: where clause is missing from type
|
|
|
|
// todo: where clause is missing from type
|
|
|
|
where: |
|
|
|
where: |
|
|
|
childrenExcludedListPagination.query && |
|
|
|
childrenExcludedListPagination.query && |
|
|
@ -278,6 +289,15 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
isChildrenLoading.value = true |
|
|
|
isChildrenLoading.value = true |
|
|
|
if (colOptions.value.type === 'bt') return |
|
|
|
if (colOptions.value.type === 'bt') return |
|
|
|
if (!rowId.value || !column.value) return |
|
|
|
if (!rowId.value || !column.value) return |
|
|
|
|
|
|
|
let offset = childrenListPagination.size * (childrenListPagination.page - 1) + childrenListOffsetCount.value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (offset < 0) { |
|
|
|
|
|
|
|
offset = 0 |
|
|
|
|
|
|
|
childrenListOffsetCount.value = 0 |
|
|
|
|
|
|
|
} else if (offset >= childrenListCount.value) { |
|
|
|
|
|
|
|
offset = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isPublic.value) { |
|
|
|
if (isPublic.value) { |
|
|
|
childrenList.value = await $api.public.dataNestedList( |
|
|
|
childrenList.value = await $api.public.dataNestedList( |
|
|
|
sharedView.value?.uuid as string, |
|
|
|
sharedView.value?.uuid as string, |
|
|
@ -286,7 +306,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
column.value.id, |
|
|
|
column.value.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
limit: String(childrenListPagination.size), |
|
|
|
limit: String(childrenListPagination.size), |
|
|
|
offset: String(childrenListPagination.size * (childrenListPagination.page - 1)), |
|
|
|
offset: String(offset), |
|
|
|
where: |
|
|
|
where: |
|
|
|
childrenListPagination.query && `(${relatedTableDisplayValueProp.value},like,${childrenListPagination.query})`, |
|
|
|
childrenListPagination.query && `(${relatedTableDisplayValueProp.value},like,${childrenListPagination.query})`, |
|
|
|
} as any, |
|
|
|
} as any, |
|
|
@ -306,7 +326,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
column?.value?.id, |
|
|
|
column?.value?.id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
limit: String(childrenListPagination.size), |
|
|
|
limit: String(childrenListPagination.size), |
|
|
|
offset: String(childrenListPagination.size * (childrenListPagination.page - 1)), |
|
|
|
offset: String(offset), |
|
|
|
where: |
|
|
|
where: |
|
|
|
childrenListPagination.query && `(${relatedTableDisplayValueProp.value},like,${childrenListPagination.query})`, |
|
|
|
childrenListPagination.query && `(${relatedTableDisplayValueProp.value},like,${childrenListPagination.query})`, |
|
|
|
} as any, |
|
|
|
} as any, |
|
|
@ -349,7 +369,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reloadData?.({ shouldShowLoading: false }) |
|
|
|
_reloadData?.({ shouldShowLoading: false }) |
|
|
|
|
|
|
|
|
|
|
|
/** reload child list if not a new row */ |
|
|
|
/** reload child list if not a new row */ |
|
|
|
if (!isNewRow?.value) { |
|
|
|
if (!isNewRow?.value) { |
|
|
@ -386,6 +406,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
try { |
|
|
|
try { |
|
|
|
// todo: audit
|
|
|
|
// todo: audit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childrenListOffsetCount.value = childrenListOffsetCount.value - 1 |
|
|
|
|
|
|
|
childrenExcludedOffsetCount.value = childrenExcludedOffsetCount.value - 1 |
|
|
|
|
|
|
|
|
|
|
|
isChildrenExcludedListLoading.value[index] = true |
|
|
|
isChildrenExcludedListLoading.value[index] = true |
|
|
|
isChildrenListLoading.value[index] = true |
|
|
|
isChildrenListLoading.value[index] = true |
|
|
|
await $api.dbTableRow.nestedRemove( |
|
|
|
await $api.dbTableRow.nestedRemove( |
|
|
@ -420,14 +444,11 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(`${t('msg.error.unlinkFailed')}: ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
message.error(`${t('msg.error.unlinkFailed')}: ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
// To Keep the Loading State for Minimum 600ms
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
isChildrenExcludedListLoading.value[index] = false |
|
|
|
isChildrenExcludedListLoading.value[index] = false |
|
|
|
isChildrenListLoading.value[index] = false |
|
|
|
isChildrenListLoading.value[index] = false |
|
|
|
}, 600) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reloadData?.({ shouldShowLoading: false }) |
|
|
|
_reloadData?.({ shouldShowLoading: false }) |
|
|
|
$e('a:links:unlink') |
|
|
|
$e('a:links:unlink') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -435,7 +456,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
row: Record<string, any>, |
|
|
|
row: Record<string, any>, |
|
|
|
{ metaValue = meta.value }: { metaValue?: TableType } = {}, |
|
|
|
{ metaValue = meta.value }: { metaValue?: TableType } = {}, |
|
|
|
undo = false, |
|
|
|
undo = false, |
|
|
|
index: number, |
|
|
|
index: number, // Index is For Loading and Linked State of Row
|
|
|
|
) => { |
|
|
|
) => { |
|
|
|
// todo: handle new record
|
|
|
|
// todo: handle new record
|
|
|
|
// const pid = this._extractRowId(parent, this.parentMeta);
|
|
|
|
// const pid = this._extractRowId(parent, this.parentMeta);
|
|
|
@ -454,6 +475,9 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
isChildrenExcludedListLoading.value[index] = true |
|
|
|
isChildrenExcludedListLoading.value[index] = true |
|
|
|
isChildrenListLoading.value[index] = true |
|
|
|
isChildrenListLoading.value[index] = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childrenListOffsetCount.value = childrenListOffsetCount.value + 1 |
|
|
|
|
|
|
|
childrenExcludedOffsetCount.value = childrenExcludedOffsetCount.value + 1 |
|
|
|
|
|
|
|
|
|
|
|
await $api.dbTableRow.nestedAdd( |
|
|
|
await $api.dbTableRow.nestedAdd( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
base.value.id as string, |
|
|
|
base.value.id as string, |
|
|
@ -480,6 +504,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
isChildrenExcludedListLinked.value[index] = true |
|
|
|
isChildrenExcludedListLinked.value[index] = true |
|
|
|
isChildrenListLinked.value[index] = true |
|
|
|
isChildrenListLinked.value[index] = true |
|
|
|
|
|
|
|
|
|
|
|
if (colOptions.value.type !== 'bt') { |
|
|
|
if (colOptions.value.type !== 'bt') { |
|
|
|
childrenListCount.value = childrenListCount.value + 1 |
|
|
|
childrenListCount.value = childrenListCount.value + 1 |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -491,13 +516,11 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
// To Keep the Loading State for Minimum 600ms
|
|
|
|
// To Keep the Loading State for Minimum 600ms
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
isChildrenExcludedListLoading.value[index] = false |
|
|
|
isChildrenExcludedListLoading.value[index] = false |
|
|
|
isChildrenListLoading.value[index] = false |
|
|
|
isChildrenListLoading.value[index] = false |
|
|
|
}, 600) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reloadData?.({ shouldShowLoading: false }) |
|
|
|
_reloadData?.({ shouldShowLoading: false }) |
|
|
|
$e('a:links:link') |
|
|
|
$e('a:links:link') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -525,6 +548,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( |
|
|
|
childrenExcludedList, |
|
|
|
childrenExcludedList, |
|
|
|
childrenList, |
|
|
|
childrenList, |
|
|
|
childrenListCount, |
|
|
|
childrenListCount, |
|
|
|
|
|
|
|
childrenListOffsetCount, |
|
|
|
|
|
|
|
childrenExcludedOffsetCount, |
|
|
|
rowId, |
|
|
|
rowId, |
|
|
|
childrenExcludedListPagination, |
|
|
|
childrenExcludedListPagination, |
|
|
|
childrenListPagination, |
|
|
|
childrenListPagination, |
|
|
|