Browse Source

fix(gui-v2): maintain the sort order

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3188/head
Pranav C 2 years ago
parent
commit
005e286fbc
  1. 4
      packages/nc-gui-v2/components/shared-view/Form.vue
  2. 18
      packages/nc-gui-v2/composables/useSharedFormViewStore.ts

4
packages/nc-gui-v2/components/shared-view/Form.vue

@ -99,7 +99,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
</div> </div>
<div v-if="isVirtualCol(field)" class="mt-0"> <div v-if="isVirtualCol(field)" class="mt-0">
<SmartsheetVirtualCell class="mt-0 nc-input" :column="field" /> <SmartsheetVirtualCell class="mt-0 nc-input" :column="field" />
<div class="text-gray-500 text-[10px] mb-2 ml-1" v-if="field.description">{{ field.description }}</div> <div v-if="field.description" class="text-gray-500 text-[10px] mb-2 ml-1">{{ field.description }}</div>
<template v-if="v$.virtual.$dirty && v$.virtual?.[field.title]"> <template v-if="v$.virtual.$dirty && v$.virtual?.[field.title]">
<div v-for="error of v$.virtual[field.title].$errors" :key="error" class="text-xs text-red-500"> <div v-for="error of v$.virtual[field.title].$errors" :key="error" class="text-xs text-red-500">
{{ error.$message }} {{ error.$message }}
@ -113,7 +113,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
:column="field" :column="field"
:edit-enabled="true" :edit-enabled="true"
/> />
<div class="text-gray-500 text-[10px] mb-2 ml-1" v-if="field.description">{{ field.description }}</div> <div v-if="field.description" class="text-gray-500 text-[10px] mb-2 ml-1">{{ field.description }}</div>
<template v-if="v$.localState.$dirty && v$.localState?.[field.title]"> <template v-if="v$.localState.$dirty && v$.localState?.[field.title]">
<div v-for="error of v$.localState[field.title].$errors" :key="error" class="text-xs text-red-500"> <div v-for="error of v$.localState[field.title].$errors" :key="error" class="text-xs text-red-500">
{{ error.$message }} {{ error.$message }}

18
packages/nc-gui-v2/composables/useSharedFormViewStore.ts

@ -3,7 +3,7 @@ import { minLength, required } from '@vuelidate/validators'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import type { ColumnType, FormType, LinkToAnotherRecordType, TableType, ViewType } 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 type { 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'
@ -21,7 +21,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
const sharedView = ref<ViewType>() const sharedView = ref<ViewType>()
const sharedFormView = ref<FormType>() const sharedFormView = ref<FormType>()
const meta = ref<TableType>() const meta = ref<TableType>()
const columns = ref<(ColumnType & { required?: boolean })[]>() const columns = ref<(ColumnType & { required?: boolean; show?: boolean })[]>()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { metas, setMeta } = useMetas() const { metas, setMeta } = useMetas()
@ -36,18 +36,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
}), }),
) )
const formColumns = computed( const formColumns = computed(() =>
() => columns?.value?.filter((c) => c.show)?.filter((col) => !isVirtualCol(col) || col.uidt === UITypes.LinkToAnotherRecord),
columns?.value
?.filter?.(
(f: Record<string, any>) =>
f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup && f.uidt !== UITypes.Formula,
)
.sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order)
.map<ColumnType & { required: boolean }>((c: ColumnType & { required?: boolean }) => ({
...c,
required: !!(c.required || 0),
})) ?? [],
) )
const loadSharedView = async () => { const loadSharedView = async () => {
try { try {

Loading…
Cancel
Save