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. 15
      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 hasvisibilityError = computed(() => Object.keys(visibilityError.value).length)
const visibilityFilters = computed(() => { const visibilityFilters = computed(() => {
if (!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] = [] 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(() => { const isFirstField = computed(() => {
@ -29,7 +29,7 @@ const isFirstField = computed(() => {
const filterOption = (column: ColumnType) => { const filterOption = (column: ColumnType) => {
// hide active field from filter option // 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 // show only form view visible columns and order is less than active field
const orderIsLessThanActiveField = const orderIsLessThanActiveField =

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

@ -204,16 +204,19 @@ const [useProvideFormViewStore, useFormViewStore] = useInjectionState(
const loadAllviewFilters = async () => { const loadAllviewFilters = async () => {
if (!viewMeta.value?.id) return if (!viewMeta.value?.id) return
try {
const formViewFilters = (await $api.dbTableFilter.read(viewMeta.value.id, { includeAllFilters: true })).list || []
const formViewFilters = (await $api.dbTableFilter.read(viewMeta.value.id, { includeAllFilters: true })).list || [] if (!formViewFilters.length) return
if (!formViewFilters.length) return
const formFilter = new FormFilters({ data: formViewFilters }) const formFilter = new FormFilters({ data: formViewFilters })
const allFilters = formFilter.getNestedGroupedFilters() const allFilters = formFilter.getNestedGroupedFilters()
allViewFilters.value = { ...allFilters } allViewFilters.value = { ...allFilters }
} catch (e: any) {
console.error('Error loading view filters:', e)
}
} }
async function checkFieldVisibility() { 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 // Method to group filters by fk_parent_column_id
getNestedGroupedFilters() { getNestedGroupedFilters() {
const groupedFiltes = this.allViewFilters.reduce((acc, filter) => { const groupedFilters = this.allViewFilters.reduce((acc, filter) => {
const groupingKey = filter.fk_parent_column_id || 'ungrouped' const groupingKey = filter.fk_parent_column_id || 'ungrouped'
if (!acc[groupingKey]) { if (!acc[groupingKey]) {
@ -96,7 +96,7 @@ export class FormFilters {
return acc return acc
}, {} as typeof this.groupedFilters) }, {} as typeof this.groupedFilters)
this.groupedFilters = groupedFiltes this.groupedFilters = groupedFilters
const nestedGroupedFilters = this.loadFilters() const nestedGroupedFilters = this.loadFilters()
@ -313,7 +313,7 @@ export class FormFilters {
val = !!this.formState[field] val = !!this.formState[field]
break break
case 'number': 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 break
} }
@ -340,10 +340,10 @@ export class FormFilters {
res = val != filter.value res = val != filter.value
break break
case 'like': case 'like':
res = this.toString(val).toLowerCase()?.indexOf(filter.value?.toLowerCase()) > -1 res = this.toString(val).toLowerCase()?.includes(filter.value?.toLowerCase())
break break
case 'nlike': case 'nlike':
res = this.toString(val).toLowerCase()?.indexOf(filter.value?.toLowerCase()) === -1 res = !this.toString(val).toLowerCase()?.includes(filter.value?.toLowerCase())
break break
case 'empty': case 'empty':
case 'blank': case 'blank':
@ -360,7 +360,7 @@ export class FormFilters {
res = !val res = !val
break break
case 'null': case 'null':
res = res = val === null res = val === null
break break
case 'notnull': case 'notnull':
res = val !== null res = val !== null

Loading…
Cancel
Save