Browse Source

Merge pull request #3224 from nocodb/fix/gui-v2-form

fix(gui-v2): disable lookup in form
pull/3228/head
Raju Udava 2 years ago committed by GitHub
parent
commit
2e4f09ddf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      packages/nc-gui-v2/components/smartsheet/Form.vue

48
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -144,8 +144,19 @@ function isDbRequired(column: Record<string, any>) {
return isRequired return isRequired
} }
function onMoveCallback(event: any) {
if (shouldSkipColumn(event.draggedContext.element)) {
return false
}
}
function onMove(event: any) { function onMove(event: any) {
const { newIndex, element, oldIndex } = event.added || event.moved || event.removed const { newIndex, element, oldIndex } = event.added || event.moved || event.removed
console.log(event)
if (shouldSkipColumn(element)) {
console.log('SKIPPED')
return
}
if (event.added) { if (event.added) {
element.show = true element.show = true
@ -171,7 +182,7 @@ function onMove(event: any) {
} }
function hideColumn(idx: number) { function hideColumn(idx: number) {
if (isDbRequired(localColumns.value[idx]) || localColumns.value[idx].required) { if (shouldSkipColumn(localColumns.value[idx])) {
message.info("Required field can't be moved") message.info("Required field can't be moved")
return return
} }
@ -189,7 +200,7 @@ function hideColumn(idx: number) {
} }
async function addAllColumns() { async function addAllColumns() {
for (const col of (formColumnData as Record<string, any>)?.value) { for (const col of (localColumns as Record<string, any>)?.value) {
if (!systemFieldsIds.value.includes(col.fk_column_id)) { if (!systemFieldsIds.value.includes(col.fk_column_id)) {
col.show = true col.show = true
} }
@ -198,17 +209,18 @@ async function addAllColumns() {
$e('a:form-view:add-all') $e('a:form-view:add-all')
} }
async function removeAllColumns() { function shouldSkipColumn(col: Record<string, any>) {
for (const col of (formColumnData as Record<string, any>)?.value) { return isDbRequired(col) || !!col.required || !!col.rqd
if (isDbRequired(col) || !!col.required) {
continue
} }
col.show = false
async function removeAllColumns() {
for (const col of (localColumns as Record<string, any>)?.value) {
if (!shouldSkipColumn(col)) col.show = false
} }
await hideAll( await hideAll(
(localColumns as Record<string, any>)?.value (localColumns as Record<string, any>)?.value
.filter((f: Record<string, any>) => isDbRequired(f) || !!f.required) .filter((col: Record<string, any>) => shouldSkipColumn(col))
.map((f: Record<string, any>) => f.fk_column_id), .map((col: Record<string, any>) => col.fk_column_id),
) )
$e('a:form-view:remove-all') $e('a:form-view:remove-all')
} }
@ -251,7 +263,12 @@ function setFormData() {
localColumns.value = col localColumns.value = col
.filter( .filter(
(f: Record<string, any>) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup && f.uidt !== UITypes.Formula, (f: Record<string, any>) =>
f.show &&
f.uidt !== UITypes.Rollup &&
f.uidt !== UITypes.Lookup &&
f.uidt !== UITypes.Formula &&
f.uidt !== UITypes.SpecificDBType,
) )
.sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order) .sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order)
.map((c: Record<string, any>) => ({ ...c, required: !!(c.required || 0) })) .map((c: Record<string, any>) => ({ ...c, required: !!(c.required || 0) }))
@ -259,7 +276,13 @@ function setFormData() {
systemFieldsIds.value = getSystemColumns(col).map((c: Record<string, any>) => c.fk_column_id) systemFieldsIds.value = getSystemColumns(col).map((c: Record<string, any>) => c.fk_column_id)
hiddenColumns.value = col.filter( hiddenColumns.value = col.filter(
(f: Record<string, any>) => !f.show && !systemFieldsIds.value.includes(f.fk_column_id) && f.uidt !== UITypes.Formula, (f: Record<string, any>) =>
!f.show &&
!systemFieldsIds.value.includes(f.fk_column_id) &&
f.uidt !== UITypes.Rollup &&
f.uidt !== UITypes.Lookup &&
f.uidt !== UITypes.Formula &&
f.uidt !== UITypes.SpecificDBType,
) )
} }
@ -447,7 +470,7 @@ onMounted(async () => {
<!-- for future implementation of cover image --> <!-- for future implementation of cover image -->
</div> </div>
<a-card <a-card
class="h-full ma-0 rounded-b-0 pa-4" class="h-full ma-0 rounded-b-0 pa-4 border-none"
:body-style="{ :body-style="{
maxWidth: '700px', maxWidth: '700px',
margin: '0 auto', margin: '0 auto',
@ -496,6 +519,7 @@ onMounted(async () => {
draggable=".item" draggable=".item"
group="form-inputs" group="form-inputs"
class="h-100" class="h-100"
:move="onMoveCallback"
@change="onMove($event)" @change="onMove($event)"
@start="drag = true" @start="drag = true"
@end="drag = false" @end="drag = false"

Loading…
Cancel
Save