Browse Source

fix: shared view sqlUis

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3573/head
mertmit 2 years ago
parent
commit
879dcee082
  1. 3
      packages/nc-gui/components/smartsheet/header/CellIcon.ts
  2. 7
      packages/nc-gui/composables/useProject.ts
  3. 4
      packages/nc-gui/composables/useSharedFormViewStore.ts
  4. 4
      packages/nc-gui/composables/useSharedView.ts

3
packages/nc-gui/components/smartsheet/header/CellIcon.ts

@ -19,6 +19,7 @@ import {
isJSON, isJSON,
isPercent, isPercent,
isPhoneNumber, isPhoneNumber,
isPrimaryKey,
isRating, isRating,
isSet, isSet,
isSingleSelect, isSingleSelect,
@ -120,7 +121,7 @@ export default defineComponent({
const { sqlUis } = useProject() const { sqlUis } = useProject()
const sqlUi = ref(columnMeta.value?.base_id ? sqlUis.value[columnMeta.value?.base_id] : Object.values(sqlUis.value)[0]) const sqlUi = ref(column.value?.base_id ? sqlUis.value[column.value?.base_id] : Object.values(sqlUis.value)[0])
const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value)) const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value))

7
packages/nc-gui/composables/useProject.ts

@ -42,7 +42,9 @@ const [setup, use] = useInjectionState(() => {
const lastOpenedViewMap = ref<Record<string, string>>({}) const lastOpenedViewMap = ref<Record<string, string>>({})
const projectId = computed(() => route.params.projectId as string) let forced_project_id: string | undefined
const projectId = computed(() => forced_project_id || (route.params.projectId as string))
// todo: refactor path param name and variable name // todo: refactor path param name and variable name
const projectType = $computed(() => route.params.projectType as string) const projectType = $computed(() => route.params.projectType as string)
@ -104,7 +106,8 @@ const [setup, use] = useInjectionState(() => {
} }
} }
async function loadProject(withTheme = true) { async function loadProject(withTheme = true, forced_id?: string) {
if (forced_id) forced_project_id = forced_id
if (projectType === 'base') { if (projectType === 'base') {
try { try {
const baseData = await api.public.sharedBaseGet(route.params.projectId as string) const baseData = await api.public.sharedBaseGet(route.params.projectId as string)

4
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -43,6 +43,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
const { metas, setMeta } = useMetas() const { metas, setMeta } = useMetas()
const { loadProject } = useProject()
const { t } = useI18n() const { t } = useI18n()
const formState = ref<Record<string, any>>({}) const formState = ref<Record<string, any>>({})
@ -84,6 +86,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
await setMeta(viewMeta.model) await setMeta(viewMeta.model)
await loadProject(true, viewMeta.project_id)
const relatedMetas = { ...viewMeta.relatedMetas } const relatedMetas = { ...viewMeta.relatedMetas }
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key])) Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key]))

4
packages/nc-gui/composables/useSharedView.ts

@ -17,6 +17,8 @@ export function useSharedView() {
const { appInfo } = $(useGlobal()) const { appInfo } = $(useGlobal())
const { loadProject } = useProject()
const appInfoDefaultLimit = appInfo.defaultLimit || 25 const appInfoDefaultLimit = appInfo.defaultLimit || 25
const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: appInfoDefaultLimit })) const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: appInfoDefaultLimit }))
@ -71,6 +73,8 @@ export function useSharedView() {
await setMeta(viewMeta.model) await setMeta(viewMeta.model)
await loadProject(true, viewMeta.project_id)
const relatedMetas = { ...viewMeta.relatedMetas } const relatedMetas = { ...viewMeta.relatedMetas }
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key])) Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key]))
} }

Loading…
Cancel
Save