Browse Source

chore(gui-v2): remove unused files

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2990/head
Pranav C 2 years ago
parent
commit
e751a7aeae
  1. 9
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  2. 9
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  3. 16
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  4. 62
      packages/nc-gui-v2/composables/columns/useLTARColumn.ts
  5. 3
      packages/nc-gui-v2/composables/index.ts
  6. 19
      packages/nc-gui-v2/composables/useBelongsTo.ts
  7. 19
      packages/nc-gui-v2/composables/useHasMany.ts
  8. 13
      packages/nc-gui-v2/composables/useLTARStore.ts
  9. 19
      packages/nc-gui-v2/composables/useManyToMany.ts

9
packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue

@ -17,7 +17,7 @@ const listItemsDlg = ref(false)
const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Required<ColumnType>, column as Required<ColumnType>,
row, row,
() => reloadTrigger?.trigger() () => reloadTrigger?.trigger(),
) )
await loadRelatedTableMeta() await loadRelatedTableMeta()
</script> </script>
@ -34,11 +34,12 @@ await loadRelatedTableMeta()
<ListItems v-model="listItemsDlg" /> <ListItems v-model="listItemsDlg" />
</div> </div>
</template> </template>
<style scoped> <style scoped>
.nc-action-icon{ .nc-action-icon {
@apply hidden @apply hidden;
} }
.chips-wrapper:hover .nc-action-icon { .chips-wrapper:hover .nc-action-icon {
@apply inline-block @apply inline-block;
} }
</style> </style>

9
packages/nc-gui-v2/components/virtual-cell/HasMany.vue

@ -19,7 +19,7 @@ const childListDlg = ref(false)
const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Required<ColumnType>, column as Required<ColumnType>,
row, row,
() => reloadTrigger?.trigger() () => reloadTrigger?.trigger(),
) )
await loadRelatedTableMeta() await loadRelatedTableMeta()
</script> </script>
@ -39,11 +39,12 @@ await loadRelatedTableMeta()
<ListChildItems v-model="childListDlg" /> <ListChildItems v-model="childListDlg" />
</div> </div>
</template> </template>
<style scoped> <style scoped>
.nc-action-icon{ .nc-action-icon {
@apply hidden @apply hidden;
} }
.chips-wrapper:hover .nc-action-icon { .chips-wrapper:hover .nc-action-icon {
@apply inline-block @apply inline-block;
} }
</style> </style>

16
packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue

@ -19,7 +19,7 @@ const childListDlg = ref(false)
const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Required<ColumnType>, column as Required<ColumnType>,
row, row,
() => reloadTrigger?.trigger() () => reloadTrigger?.trigger(),
) )
await loadRelatedTableMeta() await loadRelatedTableMeta()
@ -42,21 +42,19 @@ await loadRelatedTableMeta()
<span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span> <span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span>
</template> </template>
</div> </div>
<div class="flex-1"/> <div class="flex-1" />
<MdiExpandIcon <MdiExpandIcon class="nc-action-icon text-gray-500/50 hover:text-gray-500" @click="childListDlg = true" />
class="nc-action-icon text-gray-500/50 hover:text-gray-500"
@click="childListDlg = true"
/>
<MdiPlusIcon class="nc-action-icon w-[20px] text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" /> <MdiPlusIcon class="nc-action-icon w-[20px] text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" />
<ListItems v-model="listItemsDlg" /> <ListItems v-model="listItemsDlg" />
<ListChildItems v-model="childListDlg" /> <ListChildItems v-model="childListDlg" />
</div> </div>
</template> </template>
<style scoped> <style scoped>
.nc-action-icon{ .nc-action-icon {
@apply hidden @apply hidden;
} }
.chips-wrapper:hover .nc-action-icon { .chips-wrapper:hover .nc-action-icon {
@apply inline-block @apply inline-block;
} }
</style> </style>

62
packages/nc-gui-v2/composables/columns/useLTARColumn.ts

@ -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 }
}

3
packages/nc-gui-v2/composables/index.ts

@ -3,12 +3,9 @@ export * from './useGlobal'
export * from './useInjectionState' export * from './useInjectionState'
export * from './useUIPermission' export * from './useUIPermission'
export * from './useAttachment' export * from './useAttachment'
export * from './useBelongsTo'
export * from './useColors' export * from './useColors'
export * from './useColumn' export * from './useColumn'
export * from './useGridViewColumnWidth' export * from './useGridViewColumnWidth'
export * from './useHasMany'
export * from './useManyToMany'
export * from './useMetas' export * from './useMetas'
export * from './useProject' export * from './useProject'
export * from './useTable' export * from './useTable'

19
packages/nc-gui-v2/composables/useBelongsTo.ts

@ -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 }
}

19
packages/nc-gui-v2/composables/useHasMany.ts

@ -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 }
}

13
packages/nc-gui-v2/composables/useLTARStore.ts

@ -1,8 +1,6 @@
import type { ColumnType, LinkToAnotherRecordType, PaginatedType, TableType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, PaginatedType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { useMetas } from './useMetas' import { useInjectionState, useMetas, useProject } from '#imports'
import { useInjectionState } from '#imports'
import { useProject } from '~/composables/useProject'
import { NOCO } from '~/lib' import { NOCO } from '~/lib'
import type { Row } from '~/composables' import type { Row } from '~/composables'
@ -11,7 +9,8 @@ interface DataApiResponse {
pageInfo: PaginatedType pageInfo: PaginatedType
} }
const [useProvideLTARStore, useLTARStore] = useInjectionState((column: Required<ColumnType>, row?: Ref<Row>, reloadData = () => {}) => { const [useProvideLTARStore, useLTARStore] = useInjectionState(
(column: Required<ColumnType>, row?: Ref<Row>, reloadData = () => {}) => {
// state // state
const { metas, getMeta } = useMetas() const { metas, getMeta } = useMetas()
const { project } = useProject() const { project } = useProject()
@ -60,7 +59,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState((column: Required<
return (relatedTableMeta?.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title return (relatedTableMeta?.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
}) })
const primaryValueProp = computed(() => { const primaryValueProp = computed(() => {
return (meta?.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title return (meta?.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
}) })
const loadChildrenExcludedList = async () => { const loadChildrenExcludedList = async () => {
@ -194,7 +193,9 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState((column: Required<
loadChildrenList, loadChildrenList,
row, row,
} }
}, 'ltar-store') },
'ltar-store',
)
export { useProvideLTARStore } export { useProvideLTARStore }

19
packages/nc-gui-v2/composables/useManyToMany.ts

@ -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…
Cancel
Save