Browse Source

fix(nc-gui): editor role form fields hide-show and reorder permission

pull/7717/head
Ramesh Mane 9 months ago
parent
commit
c1d8e6ad14
  1. 44
      packages/nc-gui/components/smartsheet/Form.vue

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

@ -4,7 +4,7 @@ import Draggable from 'vuedraggable'
import tinycolor from 'tinycolor2' import tinycolor from 'tinycolor2'
import { Pane, Splitpanes } from 'splitpanes' import { Pane, Splitpanes } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css' import 'splitpanes/dist/splitpanes.css'
import { RelationTypes, UITypes, ViewTypes, getSystemColumns, isLinksOrLTAR, isVirtualCol, ProjectRoles } from 'nocodb-sdk' import { ProjectRoles, RelationTypes, UITypes, ViewTypes, getSystemColumns, isLinksOrLTAR, isVirtualCol } from 'nocodb-sdk'
import type { Permission } from '#imports' import type { Permission } from '#imports'
import { import {
ActiveViewInj, ActiveViewInj,
@ -26,6 +26,7 @@ import {
ref, ref,
useDebounceFn, useDebounceFn,
useEventListener, useEventListener,
useFileDialog,
useGlobal, useGlobal,
useI18n, useI18n,
useNuxtApp, useNuxtApp,
@ -33,7 +34,6 @@ import {
useViewColumnsOrThrow, useViewColumnsOrThrow,
useViewData, useViewData,
watch, watch,
useFileDialog,
} from '#imports' } from '#imports'
provide(IsFormInj, ref(true)) provide(IsFormInj, ref(true))
@ -90,7 +90,7 @@ reloadEventHook.on(async () => {
setFormData() setFormData()
}) })
const { fields, showAll, hideAll, saveOrUpdate } = useViewColumnsOrThrow() const { fields, showAll, hideAll } = useViewColumnsOrThrow()
const { state, row } = useProvideSmartsheetRowStore( const { state, row } = useProvideSmartsheetRowStore(
meta, meta,
@ -247,7 +247,7 @@ function onMoveCallback(event: any) {
} }
} }
function onMove(event: any, isVisibleFormFields = false) { async function onMove(event: any, isVisibleFormFields = false) {
if (isLocked.value || !isEditable) return if (isLocked.value || !isEditable) return
const { oldIndex } = event.moved const { oldIndex } = event.moved
@ -255,7 +255,7 @@ function onMove(event: any, isVisibleFormFields = false) {
const fieldIndex = fields.value?.findIndex((f) => f?.fk_column_id === element.fk_column_id) const fieldIndex = fields.value?.findIndex((f) => f?.fk_column_id === element.fk_column_id)
if (fieldIndex === -1 || fieldIndex === undefined) return if (fieldIndex === -1 || fieldIndex === undefined || !fields.value?.[fieldIndex]) return
if (isVisibleFormFields) { if (isVisibleFormFields) {
element = localColumns.value[localColumns.value?.findIndex((c) => c.fk_column_id === element.fk_column_id)] element = localColumns.value[localColumns.value?.findIndex((c) => c.fk_column_id === element.fk_column_id)]
@ -276,7 +276,11 @@ function onMove(event: any, isVisibleFormFields = false) {
element.order = ((localColumns.value[newIndex - 1]?.order || 0) + (localColumns.value[newIndex + 1].order || 0)) / 2 element.order = ((localColumns.value[newIndex - 1]?.order || 0) + (localColumns.value[newIndex + 1].order || 0)) / 2
} }
saveOrUpdate(element, fieldIndex) await $api.dbView.formColumnUpdate(element.id, element)
fields.value[fieldIndex] = element as any
// saveOrUpdate(element, fieldIndex)
$e('a:form-view:reorder') $e('a:form-view:reorder')
} }
@ -289,17 +293,21 @@ async function showOrHideColumn(column: Record<string, any>, show: boolean, isSi
!isSidePannel && message.info(t('msg.info.requriedFieldsCantBeMoved')) !isSidePannel && message.info(t('msg.info.requriedFieldsCantBeMoved'))
return return
} }
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 && fields.value?.[fieldIndex]) {
await saveOrUpdate( console.log('column', column)
{ column.show = show
...column, await $api.dbView.formColumnUpdate(column.id, column)
show,
}, fields.value[fieldIndex] = column as any
fieldIndex, // await saveOrUpdate(
) // {
// ...column,
// show,
// },
// fieldIndex,
// )
reloadEventHook.trigger() reloadEventHook.trigger()
@ -657,9 +665,9 @@ useEventListener(
<div class="min-w-[616px] overflow-x-auto nc-form-scrollbar"> <div class="min-w-[616px] overflow-x-auto nc-form-scrollbar">
<GeneralImageCropper <GeneralImageCropper
v-model:show-cropper="showCropper" v-model:show-cropper="showCropper"
:imageConfig="imageCropperData.imageConfig" :image-config="imageCropperData.imageConfig"
:cropperConfig="imageCropperData.cropperConfig" :cropper-config="imageCropperData.cropperConfig"
:uploadConfig="imageCropperData.uploadConfig" :upload-config="imageCropperData.uploadConfig"
@submit="handleOnUploadImage" @submit="handleOnUploadImage"
></GeneralImageCropper> ></GeneralImageCropper>
<!-- for future implementation of cover image --> <!-- for future implementation of cover image -->

Loading…
Cancel
Save