Browse Source

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

pull/7664/head
Ramesh Mane 8 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 hiddenColumns = ref<Record<string, any>[]>([])
const draggableRef = ref()
const systemFieldsIds = ref<Record<string, any>[]>([])
@ -238,7 +236,7 @@ function onMove(event: any, isVisibleFormFields = false) {
$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)) {
// Required field can't be moved
!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)
if (fieldIndex !== -1 && fieldIndex !== undefined) {
saveOrUpdate(
await saveOrUpdate(
{
...column,
show,
@ -333,9 +331,6 @@ function setFormData() {
.sort((a, b) => a.order - b.order)
.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) {
@ -1147,8 +1142,7 @@ useEventListener(
<!-- Show this message -->
<div>
<div class="text-gray-800 mb-2">
Display Message
<!-- {{ $t('msg.info.formDisplayMessage') }} -->
{{ $t('msg.info.formDisplayMessage') }}
</div>
<a-textarea
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
try {
const { columns, ...view } = await $api.dbView.formRead(viewMeta.value.id)
const fieldById = (columns || []).reduce(
(o: Record<string, any>, f: Record<string, any>) => ({
let order = 1
const fieldById = (columns || []).reduce((o: Record<string, any>, f: Record<string, any>) => {
if (order < f.order) {
order = f.order
}
return {
...o,
[f.fk_column_id]: f,
}),
{} as Record<string, FormColumnType>,
)
let order = 1
}
}, {} as Record<string, FormColumnType>)
formViewData.value = view

Loading…
Cancel
Save