Browse Source

fix(nc-gui): ai review changes

pull/9609/head
Ramesh Mane 2 months ago
parent
commit
02a546b22b
  1. 8
      packages/nc-gui/components/smartsheet/form/field-settings/visibility.vue
  2. 5
      packages/nc-gui/composables/useFormViewStore.ts
  3. 12
      packages/nc-gui/lib/form.ts

8
packages/nc-gui/components/smartsheet/form/field-settings/visibility.vue

@ -16,11 +16,11 @@ const visibilityError = computed(() => {
const hasvisibilityError = computed(() => Object.keys(visibilityError.value).length)
const visibilityFilters = computed(() => {
if (!allViewFilters.value[activeField.value?.fk_column_id]) {
allViewFilters.value[activeField.value!.fk_column_id] = []
if (activeField.value?.fk_column_id && !allViewFilters.value[activeField.value.fk_column_id]) {
allViewFilters.value[activeField.value.fk_column_id] = []
}
return allViewFilters.value[activeField.value!.fk_column_id]
return allViewFilters.value[`${activeField.value?.fk_column_id}`]
})
const isFirstField = computed(() => {
@ -29,7 +29,7 @@ const isFirstField = computed(() => {
const filterOption = (column: ColumnType) => {
// hide active field from filter option
const isNotActiveField = column.id !== activeField.value!.fk_column_id
const isNotActiveField = column.id !== activeField.value?.fk_column_id
// show only form view visible columns and order is less than active field
const orderIsLessThanActiveField =

5
packages/nc-gui/composables/useFormViewStore.ts

@ -204,7 +204,7 @@ const [useProvideFormViewStore, useFormViewStore] = useInjectionState(
const loadAllviewFilters = async () => {
if (!viewMeta.value?.id) return
try {
const formViewFilters = (await $api.dbTableFilter.read(viewMeta.value.id, { includeAllFilters: true })).list || []
if (!formViewFilters.length) return
@ -214,6 +214,9 @@ const [useProvideFormViewStore, useFormViewStore] = useInjectionState(
const allFilters = formFilter.getNestedGroupedFilters()
allViewFilters.value = { ...allFilters }
} catch (e: any) {
console.error('Error loading view filters:', e)
}
}
async function checkFieldVisibility() {

12
packages/nc-gui/lib/form.ts

@ -84,7 +84,7 @@ export class FormFilters {
// Method to group filters by fk_parent_column_id
getNestedGroupedFilters() {
const groupedFiltes = this.allViewFilters.reduce((acc, filter) => {
const groupedFilters = this.allViewFilters.reduce((acc, filter) => {
const groupingKey = filter.fk_parent_column_id || 'ungrouped'
if (!acc[groupingKey]) {
@ -96,7 +96,7 @@ export class FormFilters {
return acc
}, {} as typeof this.groupedFilters)
this.groupedFilters = groupedFiltes
this.groupedFilters = groupedFilters
const nestedGroupedFilters = this.loadFilters()
@ -313,7 +313,7 @@ export class FormFilters {
val = !!this.formState[field]
break
case 'number':
val = isNaN(parseFloat(this.formState[field])) ? this.formState[field] : +this.formState[field]
val = Number.isNaN(parseFloat(this.formState[field])) ? this.formState[field] : +this.formState[field]
break
}
@ -340,10 +340,10 @@ export class FormFilters {
res = val != filter.value
break
case 'like':
res = this.toString(val).toLowerCase()?.indexOf(filter.value?.toLowerCase()) > -1
res = this.toString(val).toLowerCase()?.includes(filter.value?.toLowerCase())
break
case 'nlike':
res = this.toString(val).toLowerCase()?.indexOf(filter.value?.toLowerCase()) === -1
res = !this.toString(val).toLowerCase()?.includes(filter.value?.toLowerCase())
break
case 'empty':
case 'blank':
@ -360,7 +360,7 @@ export class FormFilters {
res = !val
break
case 'null':
res = res = val === null
res = val === null
break
case 'notnull':
res = val !== null

Loading…
Cancel
Save