mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
9 changed files with 215 additions and 336 deletions
@ -1,62 +0,0 @@
|
||||
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' |
||||
import type { Ref } from 'vue' |
||||
|
||||
export default (column: Ref<ColumnType>) => { |
||||
const { $api } = useNuxtApp() |
||||
const { metas, getMeta } = useMetas() |
||||
|
||||
const colOptions = computed<LinkToAnotherRecordType>(() => column.value.colOptions as LinkToAnotherRecordType) |
||||
const relatedTableMeta = computed<TableType>( |
||||
() => colOptions?.value && metas.value?.[colOptions.value?.fk_related_model_id as string], |
||||
) |
||||
|
||||
const removeChild = () => { |
||||
// todo: audit
|
||||
// await this.$api.dbTableRow.nestedRemove(
|
||||
// 'noco',
|
||||
// this.projectName,
|
||||
// this.meta.title,
|
||||
// id,
|
||||
// 'bt',
|
||||
// this.column.title,
|
||||
// parent[this.parentPrimaryKey]
|
||||
// );
|
||||
} |
||||
|
||||
const addChild = () => { |
||||
// await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, id, 'bt', this.column.title, pid);
|
||||
} |
||||
|
||||
const loadRelatedTableMeta = async () => { |
||||
return getMeta(colOptions.value?.fk_related_model_id as string) |
||||
} |
||||
|
||||
// this.data = await this.$api.dbTableRow.nestedChildrenExcludedList(
|
||||
// 'noco',
|
||||
// this.projectName,
|
||||
// this.parentMeta.title,
|
||||
// this.rowId,
|
||||
// this.column.colOptions.type,
|
||||
// this.column.title,
|
||||
// {
|
||||
// limit: this.size,
|
||||
// offset: this.size * (this.page - 1),
|
||||
// where: this.query && `(${this.primaryCol},like,${this.query})`,
|
||||
// }
|
||||
// );
|
||||
|
||||
// this.data = await this.$api.dbTableRow.nestedList(
|
||||
// 'noco',
|
||||
// this.projectName,
|
||||
// this.parentMeta.title,
|
||||
// this.rowId,
|
||||
// this.column.colOptions.type,
|
||||
// this.column.title,
|
||||
// {
|
||||
// limit: this.size,
|
||||
// offset: this.size * (this.page - 1),
|
||||
// }
|
||||
// );
|
||||
|
||||
return { addChild, removeChild, loadRelatedTableMeta, relatedTableMeta } |
||||
} |
@ -1,19 +0,0 @@
|
||||
import type { ColumnType, TableType } from 'nocodb-sdk' |
||||
import { useMetas } from './useMetas' |
||||
|
||||
export function useBelongsTo(column: ColumnType) { |
||||
const { metas, getMeta } = useMetas() |
||||
const parentMeta = computed<TableType>(() => { |
||||
return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] |
||||
}) |
||||
|
||||
const loadParentMeta = async () => { |
||||
await getMeta((column.colOptions as any)?.fk_related_model_id as string) |
||||
} |
||||
|
||||
const primaryValueProp = computed(() => { |
||||
return (parentMeta?.value?.columns?.find((c) => c.pv) || parentMeta?.value?.columns?.[0])?.title |
||||
}) |
||||
|
||||
return { parentMeta, loadParentMeta, primaryValueProp } |
||||
} |
@ -1,19 +0,0 @@
|
||||
import type { ColumnType, TableType } from 'nocodb-sdk' |
||||
import { useMetas } from './useMetas' |
||||
|
||||
export function useHasMany(column: ColumnType) { |
||||
const { metas, getMeta } = useMetas() |
||||
const childMeta = computed<TableType>(() => { |
||||
return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] |
||||
}) |
||||
|
||||
const loadChildMeta = async () => { |
||||
await getMeta((column.colOptions as any)?.fk_related_model_id as string) |
||||
} |
||||
|
||||
const primaryValueProp = computed(() => { |
||||
return (childMeta?.value?.columns?.find((c) => c.pv) || childMeta?.value?.columns?.[0])?.title |
||||
}) |
||||
|
||||
return { childMeta, loadChildMeta, primaryValueProp } |
||||
} |
@ -1,19 +0,0 @@
|
||||
import type { ColumnType, TableType } from 'nocodb-sdk' |
||||
import { useMetas } from './useMetas' |
||||
|
||||
export function useManyToMany(column: ColumnType) { |
||||
const { metas, getMeta } = useMetas() |
||||
const childMeta = computed<TableType>(() => { |
||||
return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] |
||||
}) |
||||
|
||||
const loadChildMeta = async () => { |
||||
await getMeta((column.colOptions as any)?.fk_related_model_id as string) |
||||
} |
||||
|
||||
const primaryValueProp = computed(() => { |
||||
return (childMeta?.value?.columns?.find((c) => c.pv) || childMeta?.value?.columns?.[0])?.title |
||||
}) |
||||
|
||||
return { childMeta, loadChildMeta, primaryValueProp } |
||||
} |
Loading…
Reference in new issue