Browse Source

fix: load table meta if not loaded already

pull/7392/head
Pranav C 10 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 { tables } = storeToRefs(baseStore)
const { metas } = useMetas() const { metas, getMeta } = useMetas()
setAdditionalValidations({ setAdditionalValidations({
fk_relation_column_id: [{ required: true, message: t('general.required') }], 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> }>[] 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 columns = computed<ColumnType[]>(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id) if (!selectedTable.value?.id) {
if (!selectedTable?.id) {
return [] return []
} }
return metas.value[selectedTable.id].columns.filter( return metas.value[selectedTable.id]?.columns.filter(
(c: ColumnType) => (c: ColumnType) =>
vModel.value.fk_lookup_column_id === c.id || (!isSystemColumn(c) && c.id !== vModel.value.id && c.uidt !== UITypes.Links), 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 vModel.value.fk_lookup_column_id = columns.value?.[0]?.id
onDataTypeChange() onDataTypeChange()
} }

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

@ -35,7 +35,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore) const { tables } = storeToRefs(baseStore)
const { metas } = useMetas() const { metas, getMeta } = useMetas()
const { t } = useI18n() const { t } = useI18n()
@ -70,14 +70,16 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[] return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
}) })
const columns = computed(() => { const selectedTable = computed(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id) 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 []
} }
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), (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 vModel.value.fk_rollup_column_id = columns.value?.[0]?.id
onDataTypeChange() onDataTypeChange()
} }

Loading…
Cancel
Save