Browse Source

fix: load table meta if not loaded already

pull/7392/head
Pranav C 11 months ago
parent
commit
078ef13e00
  1. 16
      packages/nc-gui/components/smartsheet/column/LookupOptions.vue
  2. 17
      packages/nc-gui/components/smartsheet/column/RollupOptions.vue

16
packages/nc-gui/components/smartsheet/column/LookupOptions.vue

@ -22,7 +22,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore)
const { metas } = useMetas()
const { metas, getMeta } = useMetas()
setAdditionalValidations({
fk_relation_column_id: [{ required: true, message: t('general.required') }],
@ -48,12 +48,15 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
})
const selectedTable = computed(() => {
return refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
})
const columns = computed<ColumnType[]>(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
if (!selectedTable?.id) {
if (!selectedTable.value?.id) {
return []
}
return metas.value[selectedTable.id].columns.filter(
return metas.value[selectedTable.id]?.columns.filter(
(c: ColumnType) =>
vModel.value.fk_lookup_column_id === c.id || (!isSystemColumn(c) && c.id !== vModel.value.id && c.uidt !== UITypes.Links),
)
@ -66,7 +69,10 @@ onMounted(() => {
}
})
const onRelationColChange = () => {
const onRelationColChange = async () => {
if (selectedTable.value) {
await getMeta(selectedTable.value.id)
}
vModel.value.fk_lookup_column_id = columns.value?.[0]?.id
onDataTypeChange()
}

17
packages/nc-gui/components/smartsheet/column/RollupOptions.vue

@ -35,7 +35,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore)
const { metas } = useMetas()
const { metas, getMeta } = useMetas()
const { t } = useI18n()
@ -70,14 +70,16 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
})
const columns = computed(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
const selectedTable = computed(() => {
return refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
})
if (!selectedTable?.id) {
const columns = computed<ColumnType[]>(() => {
if (!selectedTable.value?.id) {
return []
}
return metas.value[selectedTable.id].columns.filter(
return metas.value[selectedTable.id]?.columns.filter(
(c: ColumnType) => !isVirtualCol(c.uidt as UITypes) && (!isSystemColumn(c) || c.pk),
)
})
@ -90,7 +92,10 @@ onMounted(() => {
}
})
const onRelationColChange = () => {
const onRelationColChange = async () => {
if (selectedTable.value) {
await getMeta(selectedTable.value.id)
}
vModel.value.fk_rollup_column_id = columns.value?.[0]?.id
onDataTypeChange()
}

Loading…
Cancel
Save