Browse Source

fix: hide CreatedBy & LastModifiedBy system fields from dropdowns

pull/7373/head
mertmit 9 months ago
parent
commit
ca57d58ba9
  1. 14
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue
  2. 17
      packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue

14
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -5,6 +5,7 @@ import jsep from 'jsep'
import {
FormulaError,
UITypes,
isCreatedOrLastModifiedByCol,
jsepCurlyHook,
substituteColumnIdWithAliasInFormula,
validateFormulaAndExtractTreeWithType,
@ -51,7 +52,18 @@ const { predictFunction: _predictFunction } = useNocoEe()
const meta = inject(MetaInj, ref())
const supportedColumns = computed(
() => meta?.value?.columns?.filter((col) => !uiTypesNotSupportedInFormulas.includes(col.uidt as UITypes)) || [],
() =>
meta?.value?.columns?.filter((col) => {
if (uiTypesNotSupportedInFormulas.includes(col.uidt as UITypes)) {
return false
}
if (isCreatedOrLastModifiedByCol(col) && col.system) {
return false
}
return true
}) || [],
)
const { getMeta } = useMetas()

17
packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import type { SelectProps } from 'ant-design-vue'
import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes, isLinksOrLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import { RelationTypes, UITypes, isCreatedOrLastModifiedByCol, isLinksOrLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import { MetaInj, computed, inject, ref, resolveComponent, useViewColumnsOrThrow } from '#imports'
const { modelValue, isSort, allowEmpty, ...restProps } = defineProps<{
@ -26,12 +26,25 @@ const { showSystemFields, metaColumnById } = useViewColumnsOrThrow()
const options = computed<SelectProps['options']>(() =>
(
customColumns.value ||
customColumns.value?.filter((c: ColumnType) => {
if (isSystemColumn(metaColumnById?.value?.[c.id!])) {
if (isCreatedOrLastModifiedByCol(c)) {
/** ignore created by and last modified by system field */
return false
}
}
return true
}) ||
meta.value?.columns?.filter((c: ColumnType) => {
if (c.uidt === UITypes.Links) {
return true
}
if (isSystemColumn(metaColumnById?.value?.[c.id!])) {
if (isCreatedOrLastModifiedByCol(c)) {
/** ignore created by and last modified by system field */
return false
}
return (
/** if the field is used in filter, then show it anyway */
localValue.value === c.id ||

Loading…
Cancel
Save