Browse Source

feat(nc-gui): add isComparisonSubOpAllowed

pull/5185/head
Wing-Kam Wong 2 years ago
parent
commit
ea4888150f
  1. 20
      packages/nc-gui/composables/useViewFilters.ts

20
packages/nc-gui/composables/useViewFilters.ts

@ -140,6 +140,25 @@ export function useViewFilters(
return isNullOrEmptyOp ? projectMeta.value.showNullAndEmptyInFilter : true return isNullOrEmptyOp ? projectMeta.value.showNullAndEmptyInFilter : true
} }
const isComparisonSubOpAllowed = (
filter: FilterType,
compOp: {
text: string
value: string
ignoreVal?: boolean
includedTypes?: UITypes[]
excludedTypes?: UITypes[]
},
) => {
if (compOp.includedTypes) {
// include allowed values only if selected column type matches
return filter.fk_column_id && compOp.includedTypes.includes(types.value[filter.fk_column_id])
} else if (compOp.excludedTypes) {
// include not allowed values only if selected column type not matches
return filter.fk_column_id && !compOp.excludedTypes.includes(types.value[filter.fk_column_id])
}
}
const placeholderFilter = (): Filter => { const placeholderFilter = (): Filter => {
return { return {
comparison_op: comparisonOpList(options.value?.[0].uidt as UITypes).filter((compOp) => comparison_op: comparisonOpList(options.value?.[0].uidt as UITypes).filter((compOp) =>
@ -327,5 +346,6 @@ export function useViewFilters(
addFilterGroup, addFilterGroup,
saveOrUpdateDebounced, saveOrUpdateDebounced,
isComparisonOpAllowed, isComparisonOpAllowed,
isComparisonSubOpAllowed,
} }
} }

Loading…
Cancel
Save