From fa57943c08000f48f3d91ac7cb6d71ffd0307292 Mon Sep 17 00:00:00 2001 From: Daniel Spaude Date: Fri, 4 Nov 2022 16:52:12 +0400 Subject: [PATCH] qrcode: refactor filtering out of qr code in form builder --- .../nc-gui/components/smartsheet/Form.vue | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index b80e0d9753..49522dfd04 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -33,6 +33,8 @@ provide(IsGalleryInj, ref(false)) // todo: generate hideCols based on default values const hiddenCols = ['created_at', 'updated_at'] +const hiddenColTypes = [UITypes.Rollup, UITypes.Lookup, UITypes.Formula, UITypes.QrCode, UITypes.SpecificDBType] + const state = useGlobal() const formRef = ref() @@ -73,7 +75,8 @@ const { syncLTARRefs, row } = useProvideSmartsheetRowStore( }), ) -const columns = computed(() => meta?.value?.columns?.filter((col) => col.uidt !== UITypes.QrCode) || []) +// const columns = computed(() => meta?.value?.columns?.filter((col) => col.uidt !== UITypes.QrCode) || []) +const columns = computed(() => meta?.value?.columns || []) const localColumns = ref[]>([]) @@ -257,7 +260,8 @@ async function checkSMTPStatus() { } function setFormData() { - const col = formColumnData?.value?.filter((c: Record) => c.uidt !== UITypes.QrCode) || [] + // const col = formColumnData?.value?.filter((c) => c.uidt !== UITypes.QrCode) || [] + const col = formColumnData?.value || [] formViewData.value = { ...formViewData.value, @@ -274,27 +278,14 @@ function setFormData() { emailMe.value = data[state.user.value?.email as string] localColumns.value = col - .filter( - (f) => - f.show && - f.uidt !== UITypes.Rollup && - f.uidt !== UITypes.Lookup && - f.uidt !== UITypes.Formula && - f.uidt !== UITypes.SpecificDBType, - ) + .filter((f) => f.show && !hiddenColTypes.includes(f.uidt)) .sort((a, b) => a.order - b.order) .map((c) => ({ ...c, required: !!(c.required || 0) })) systemFieldsIds.value = getSystemColumns(col).map((c) => c.fk_column_id) hiddenColumns.value = col.filter( - (f) => - !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, + (f) => !f.show && !systemFieldsIds.value.includes(f.fk_column_id) && !hiddenColTypes.includes(f.uidt), ) }