Browse Source

fix(gui-v2): pass isNewRow reference to LTAR store

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3025/head
Pranav C 2 years ago
parent
commit
b88517d696
  1. 3
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  2. 9
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  3. 4
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  4. 2
      packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue
  5. 8
      packages/nc-gui-v2/composables/useLTARStore.ts

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

@ -23,14 +23,15 @@ const listItemsDlg = ref(false)
const isForm = inject(IsFormInj)
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Ref<Required<ColumnType>>,
row,
isNew,
reloadTrigger.trigger,
)
await loadRelatedTableMeta()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const value = computed(() => {
if (cellValue?.value) {

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

@ -4,10 +4,9 @@ import type { Ref } from 'vue'
import ItemChip from './components/ItemChip.vue'
import ListChildItems from './components/ListChildItems.vue'
import ListItems from './components/ListItems.vue'
import { useProvideSmartsheetRowStore, useSmartsheetRowStoreOrThrow } from '~/composables/useSmartsheetRowStore'
import { useSmartsheetRowStoreOrThrow } from '~/composables/useSmartsheetRowStore'
import { computed, inject, ref, useProvideLTARStore } from '#imports'
import { CellValueInj, ColumnInj, IsFormInj, ReloadViewDataHookInj, RowInj } from '~/context'
import { useProvideLTARStore } from '#imports'
import { CellValueInj, ColumnInj, IsFormInj, ReloadViewDataHookInj, RowInj } from '~/context'
@ -27,17 +26,15 @@ const listItemsDlg = ref(false)
const childListDlg = ref(false)
const { state, isNew } = useSmartsheetRowStoreOrThrow()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Ref<Required<ColumnType>>,
row,
isNew,
reloadTrigger.trigger,
)
await loadRelatedTableMeta()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const localCellValue = computed(() => {
if (cellValue?.value) {
return cellValue?.value

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

@ -24,16 +24,16 @@ const listItemsDlg = ref(false)
const childListDlg = ref(false)
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore(
column as Ref<Required<ColumnType>>,
row,
isNew,
reloadTrigger.trigger,
)
await loadRelatedTableMeta()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const localCellValue = computed(() => {
if (cellValue?.value) {
return cellValue?.value

2
packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue

@ -34,7 +34,7 @@ const linkRow = async (row: Record<string, any>) => {
watch(vModel, () => {
if (vModel.value) {
loadChildrenExcludedList(isNew.value)
loadChildrenExcludedList()
}
})
</script>

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

@ -1,5 +1,5 @@
import type { ColumnType, LinkToAnotherRecordType, PaginatedType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import type { ComputedRef, Ref } from 'vue'
import { Modal, notification } from 'ant-design-vue'
import { useInjectionState, useMetas, useProject } from '#imports'
import { NOCO } from '~/lib'
@ -13,7 +13,7 @@ interface DataApiResponse {
/** Store for managing Link to another cells */
const [useProvideLTARStore, useLTARStore] = useInjectionState(
(column: Ref<Required<ColumnType>>, row?: Ref<Row>, reloadData = () => {}) => {
(column: Ref<Required<ColumnType>>, row?: Ref<Row>, isNewRow: ComputedRef<boolean>, reloadData = () => {}) => {
// state
const { metas, getMeta } = useMetas()
const { project } = useProject()
@ -69,10 +69,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
return (meta?.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
})
const loadChildrenExcludedList = async (isNewRow = false) => {
const loadChildrenExcludedList = async () => {
try {
/** if new row load all records */
if (isNewRow) {
if (isNewRow?.value) {
childrenExcludedList.value = await $api.dbTableRow.list(
NOCO,
project.value.id as string,

Loading…
Cancel
Save