|
|
@ -1,8 +1,9 @@ |
|
|
|
import useVuelidate from '@vuelidate/core' |
|
|
|
import useVuelidate from '@vuelidate/core' |
|
|
|
import { minLength, required } from '@vuelidate/validators' |
|
|
|
import { minLength, required } from '@vuelidate/validators' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' |
|
|
|
import type { ColumnType, FormType, LinkToAnotherRecordType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
import { ErrorMessages, RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { ErrorMessages, RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' |
|
|
|
|
|
|
|
import { Ref } from 'vue' |
|
|
|
import { SharedViewPasswordInj } from '~/context' |
|
|
|
import { SharedViewPasswordInj } from '~/context' |
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils' |
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils' |
|
|
|
import { useInjectionState, useMetas } from '#imports' |
|
|
|
import { useInjectionState, useMetas } from '#imports' |
|
|
@ -17,8 +18,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
|
|
|
|
|
|
|
|
provide(SharedViewPasswordInj, password) |
|
|
|
provide(SharedViewPasswordInj, password) |
|
|
|
|
|
|
|
|
|
|
|
// todo: type
|
|
|
|
const sharedView = ref<ViewType>() |
|
|
|
const sharedView = ref<any>() |
|
|
|
const sharedFormView = ref<FormType>() |
|
|
|
const meta = ref<TableType>() |
|
|
|
const meta = ref<TableType>() |
|
|
|
const columns = ref<(ColumnType & { required?: boolean })[]>() |
|
|
|
const columns = ref<(ColumnType & { required?: boolean })[]>() |
|
|
|
|
|
|
|
|
|
|
@ -27,7 +28,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
const formState = ref({}) |
|
|
|
const formState = ref({}) |
|
|
|
|
|
|
|
|
|
|
|
const { state: additionalState } = useProvideSmartsheetRowStore( |
|
|
|
const { state: additionalState } = useProvideSmartsheetRowStore( |
|
|
|
meta, |
|
|
|
meta as Ref<TableType>, |
|
|
|
ref({ |
|
|
|
ref({ |
|
|
|
row: formState, |
|
|
|
row: formState, |
|
|
|
rowMeta: { new: true }, |
|
|
|
rowMeta: { new: true }, |
|
|
@ -51,7 +52,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
const loadSharedView = async () => { |
|
|
|
const loadSharedView = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// todo: swagger type correction
|
|
|
|
// todo: swagger type correction
|
|
|
|
const viewMeta: any = await $api.public.sharedViewMetaGet(sharedViewId, { |
|
|
|
const viewMeta = await $api.public.sharedViewMetaGet(sharedViewId, { |
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
'xc-password': password.value, |
|
|
|
'xc-password': password.value, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -60,8 +61,9 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
passwordDlg.value = false |
|
|
|
passwordDlg.value = false |
|
|
|
|
|
|
|
|
|
|
|
sharedView.value = viewMeta |
|
|
|
sharedView.value = viewMeta |
|
|
|
|
|
|
|
sharedFormView.value = viewMeta.view |
|
|
|
meta.value = viewMeta.model |
|
|
|
meta.value = viewMeta.model |
|
|
|
columns.value = viewMeta.model.columns |
|
|
|
columns.value = viewMeta.model?.columns |
|
|
|
|
|
|
|
|
|
|
|
setMeta(viewMeta.model) |
|
|
|
setMeta(viewMeta.model) |
|
|
|
|
|
|
|
|
|
|
@ -180,6 +182,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
sharedView, |
|
|
|
sharedView, |
|
|
|
|
|
|
|
sharedFormView, |
|
|
|
loadSharedView, |
|
|
|
loadSharedView, |
|
|
|
columns, |
|
|
|
columns, |
|
|
|
submitForm, |
|
|
|
submitForm, |
|
|
|