|
|
@ -1,4 +1,4 @@ |
|
|
|
import { isSystemColumn } from 'nocodb-sdk' |
|
|
|
import { isSystemColumn, MapType, ViewTypes } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
import { IsPublicInj, computed, inject, ref, useNuxtApp, useProject, useUIPermission, watch } from '#imports' |
|
|
|
import { IsPublicInj, computed, inject, ref, useNuxtApp, useProject, useUIPermission, watch } from '#imports' |
|
|
@ -25,6 +25,13 @@ export function useViewColumns( |
|
|
|
() => isPublic.value || !isUIAllowed('hideAllColumns') || !isUIAllowed('showAllColumns') || isSharedBase.value, |
|
|
|
() => isPublic.value || !isUIAllowed('hideAllColumns') || !isUIAllowed('showAllColumns') || isSharedBase.value, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isColumnViewEssential = (column: ColumnType) => { |
|
|
|
|
|
|
|
// TODO: consider at some point ti delegate this via a cleaner design pattern to view specific check logic
|
|
|
|
|
|
|
|
// which could be inside of a view specific helper class (and generalized via an interface)
|
|
|
|
|
|
|
|
// (on the other hand, the logic complexity is still very low atm - might be overkill)
|
|
|
|
|
|
|
|
return view.value?.type === ViewTypes.MAP && (view.value?.view as MapType)?.fk_geo_data_col_id === column.id |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const metaColumnById = computed<Record<string, ColumnType>>(() => { |
|
|
|
const metaColumnById = computed<Record<string, ColumnType>>(() => { |
|
|
|
if (!meta.value?.columns) return {} |
|
|
|
if (!meta.value?.columns) return {} |
|
|
|
|
|
|
|
|
|
|
@ -38,6 +45,7 @@ export function useViewColumns( |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const loadViewColumns = async () => { |
|
|
|
const loadViewColumns = async () => { |
|
|
|
|
|
|
|
|
|
|
|
if (!meta || !view) return |
|
|
|
if (!meta || !view) return |
|
|
|
|
|
|
|
|
|
|
|
let order = 1 |
|
|
|
let order = 1 |
|
|
@ -62,8 +70,10 @@ export function useViewColumns( |
|
|
|
title: column.title, |
|
|
|
title: column.title, |
|
|
|
fk_column_id: column.id, |
|
|
|
fk_column_id: column.id, |
|
|
|
...currentColumnField, |
|
|
|
...currentColumnField, |
|
|
|
|
|
|
|
show: currentColumnField.show || isColumnViewEssential(currentColumnField), |
|
|
|
order: currentColumnField.order || order++, |
|
|
|
order: currentColumnField.order || order++, |
|
|
|
system: isSystemColumn(metaColumnById?.value?.[currentColumnField.fk_column_id!]), |
|
|
|
system: isSystemColumn(metaColumnById?.value?.[currentColumnField.fk_column_id!]), |
|
|
|
|
|
|
|
isViewEssentialField: isColumnViewEssential(column), |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.sort((a: Field, b: Field) => a.order - b.order) |
|
|
|
.sort((a: Field, b: Field) => a.order - b.order) |
|
|
@ -98,7 +108,7 @@ export function useViewColumns( |
|
|
|
if (isLocalMode.value) { |
|
|
|
if (isLocalMode.value) { |
|
|
|
fields.value = fields.value?.map((field: Field) => ({ |
|
|
|
fields.value = fields.value?.map((field: Field) => ({ |
|
|
|
...field, |
|
|
|
...field, |
|
|
|
show: false, |
|
|
|
show: !!field.isViewEssentialField, |
|
|
|
})) |
|
|
|
})) |
|
|
|
reloadData?.() |
|
|
|
reloadData?.() |
|
|
|
return |
|
|
|
return |
|
|
|