Browse Source

fix(nc-gui): new added field reorder issue in form view

pull/7664/head
Ramesh Mane 9 months ago
parent
commit
f0e2411798
  1. 12
      packages/nc-gui/components/smartsheet/Form.vue
  2. 16
      packages/nc-gui/composables/useViewData.ts

12
packages/nc-gui/components/smartsheet/Form.vue

@ -100,8 +100,6 @@ const columns = computed(() => meta?.value?.columns || [])
const localColumns = ref<Record<string, any>[]>([]) const localColumns = ref<Record<string, any>[]>([])
const hiddenColumns = ref<Record<string, any>[]>([])
const draggableRef = ref() const draggableRef = ref()
const systemFieldsIds = ref<Record<string, any>[]>([]) const systemFieldsIds = ref<Record<string, any>[]>([])
@ -238,7 +236,7 @@ function onMove(event: any, isVisibleFormFields = false) {
$e('a:form-view:reorder') $e('a:form-view:reorder')
} }
function showOrHideColumn(column: Record<string, any>, show: boolean, isSidePannel = false) { async function showOrHideColumn(column: Record<string, any>, show: boolean, isSidePannel = false) {
if (shouldSkipColumn(column)) { if (shouldSkipColumn(column)) {
// Required field can't be moved // Required field can't be moved
!isSidePannel && message.info(t('msg.info.requriedFieldsCantBeMoved')) !isSidePannel && message.info(t('msg.info.requriedFieldsCantBeMoved'))
@ -248,7 +246,7 @@ function showOrHideColumn(column: Record<string, any>, show: boolean, isSidePann
const fieldIndex = fields.value?.findIndex((f) => f?.fk_column_id === column.fk_column_id) const fieldIndex = fields.value?.findIndex((f) => f?.fk_column_id === column.fk_column_id)
if (fieldIndex !== -1 && fieldIndex !== undefined) { if (fieldIndex !== -1 && fieldIndex !== undefined) {
saveOrUpdate( await saveOrUpdate(
{ {
...column, ...column,
show, show,
@ -333,9 +331,6 @@ function setFormData() {
.sort((a, b) => a.order - b.order) .sort((a, b) => a.order - b.order)
.map((c) => ({ ...c, required: !!c.required })) .map((c) => ({ ...c, required: !!c.required }))
hiddenColumns.value = col.filter(
(f) => !f.show && !systemFieldsIds.value.includes(f.fk_column_id) && !hiddenColTypes.includes(f.uidt),
)
} }
function isRequired(_columnObj: Record<string, any>, required = false) { function isRequired(_columnObj: Record<string, any>, required = false) {
@ -1147,8 +1142,7 @@ useEventListener(
<!-- Show this message --> <!-- Show this message -->
<div> <div>
<div class="text-gray-800 mb-2"> <div class="text-gray-800 mb-2">
Display Message {{ $t('msg.info.formDisplayMessage') }}
<!-- {{ $t('msg.info.formDisplayMessage') }} -->
</div> </div>
<a-textarea <a-textarea
v-model:value="formViewData.success_msg" v-model:value="formViewData.success_msg"

16
packages/nc-gui/composables/useViewData.ts

@ -278,16 +278,16 @@ export function useViewData(
if (!viewMeta?.value?.id) return if (!viewMeta?.value?.id) return
try { try {
const { columns, ...view } = await $api.dbView.formRead(viewMeta.value.id) const { columns, ...view } = await $api.dbView.formRead(viewMeta.value.id)
let order = 1
const fieldById = (columns || []).reduce( const fieldById = (columns || []).reduce((o: Record<string, any>, f: Record<string, any>) => {
(o: Record<string, any>, f: Record<string, any>) => ({ if (order < f.order) {
order = f.order
}
return {
...o, ...o,
[f.fk_column_id]: f, [f.fk_column_id]: f,
}), }
{} as Record<string, FormColumnType>, }, {} as Record<string, FormColumnType>)
)
let order = 1
formViewData.value = view formViewData.value = view

Loading…
Cancel
Save