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
}
function onMoveCallback(event: any) {
if (shouldSkipColumn(event.draggedContext.element)) {
return false
}
}
function onMove(event: any) {
const { newIndex, element, oldIndex } = event.added || event.moved || event.removed
console.log(event)
if (shouldSkipColumn(element)) {
console.log('SKIPPED')
return
}
if (event.added) {
element.show = true
@ -171,7 +182,7 @@ function onMove(event: any) {
}
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")
return
}
@ -189,7 +200,7 @@ function hideColumn(idx: number) {
}
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)) {
col.show = true
}
@ -198,17 +209,18 @@ async function addAllColumns() {
$e('a:form-view:add-all')
}
function shouldSkipColumn(col: Record<string, any>) {
return isDbRequired(col) || !!col.required || !!col.rqd
}
async function removeAllColumns() {
for (const col of (formColumnData as Record<string, any>)?.value) {
if (isDbRequired(col) || !!col.required) {
continue
}
col.show = false
for (const col of (localColumns as Record<string, any>)?.value) {
if (!shouldSkipColumn(col)) col.show = false
}
await hideAll(
(localColumns as Record<string, any>)?.value
.filter((f: Record<string, any>) => isDbRequired(f) || !!f.required)
.map((f: Record<string, any>) => f.fk_column_id),
.filter((col: Record<string, any>) => shouldSkipColumn(col))
.map((col: Record<string, any>) => col.fk_column_id),
)
$e('a:form-view:remove-all')
}
@ -251,7 +263,12 @@ function setFormData() {
localColumns.value = col
.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)
.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)
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 -->
</div>
<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="{
maxWidth: '700px',
margin: '0 auto',
@ -496,6 +519,7 @@ onMounted(async () => {
draggable=".item"
group="form-inputs"
class="h-100"
:move="onMoveCallback"
@change="onMove($event)"
@start="drag = true"
@end="drag = false"

Loading…
Cancel
Save