diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue index 1876242da9..f66e894553 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue @@ -100,11 +100,6 @@ watch( }, ) -const getApplicableFilters = (id?: string) => { - const colType = (meta.value?.columnsById as Record)?.[id ?? '']?.uidt - return comparisonOpList.filter((op) => !op.types || op.types.includes(colType)) -} - const applyChanges = async (hookId?: string, _nested = false) => { await sync(hookId, _nested) @@ -218,18 +213,15 @@ defineExpose({ dropdown-class-name="nc-dropdown-filter-comp-op" @change="filterUpdateCondition(filter, i)" > - + diff --git a/packages/nc-gui/utils/filterUtils.ts b/packages/nc-gui/utils/filterUtils.ts index 249a26664e..867b0cb5a4 100644 --- a/packages/nc-gui/utils/filterUtils.ts +++ b/packages/nc-gui/utils/filterUtils.ts @@ -1,4 +1,11 @@ -export const comparisonOpList = [ +import { UITypes } from 'nocodb-sdk' + +export const comparisonOpList: { + text: string + value: string + ignoreVal?: boolean + allowedTypes?: string[] +}[] = [ { text: 'is equal', value: 'eq', @@ -35,6 +42,18 @@ export const comparisonOpList = [ value: 'notnull', ignoreVal: true, }, + { + text: 'is checked', + value: 'checked', + ignoreVal: true, + allowedTypes: ['boolean'], + }, + { + text: 'is not checked', + value: 'notchecked', + ignoreVal: true, + allowedTypes: ['boolean'], + }, { text: 'contains all of', value: 'allof', diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index 6363e79f3a..8c44151310 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -9,7 +9,6 @@ import RollupColumn from '../../../../models/RollupColumn'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import FormulaColumn from '../../../../models/FormulaColumn'; import { RelationTypes, UITypes } from 'nocodb-sdk'; -// import LookupColumn from '../../../models/LookupColumn'; import { sanitize } from './helpers/sanitize'; export default async function conditionV2( @@ -368,6 +367,10 @@ const parseConditionV2 = async ( qb = qb.where(customWhereClause || field, ''); else if (filter.value === 'notempty') qb = qb.whereNot(customWhereClause || field, ''); + else if (filter.value === 'true') + qb = qb.where(customWhereClause || field, true); + else if (filter.value === 'false') + qb = qb.where(customWhereClause || field, false); break; case 'isnot': if (filter.value === 'null') @@ -378,6 +381,10 @@ const parseConditionV2 = async ( qb = qb.whereNot(customWhereClause || field, ''); else if (filter.value === 'notempty') qb = qb.where(customWhereClause || field, ''); + else if (filter.value === 'true') + qb = qb.whereNot(customWhereClause || field, true); + else if (filter.value === 'false') + qb = qb.whereNot(customWhereClause || field, false); break; case 'lt': qb = qb.where(field, customWhereClause ? '>' : '<', val); @@ -405,6 +412,16 @@ const parseConditionV2 = async ( case 'notnull': qb = qb.whereNotNull(customWhereClause || field); break; + case 'checked': + qb = qb.where(customWhereClause || field, true); + break; + case 'notchecked': + qb = qb.where((grpdQb) => { + grpdQb + .whereNull(customWhereClause || field) + .orWhere(customWhereClause || field, false); + }); + break; case 'btw': qb = qb.whereBetween(field, val.split(',')); break; diff --git a/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts b/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts index a2849e6a51..c41997e5c3 100644 --- a/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts +++ b/packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts @@ -66,6 +66,12 @@ export async function validateCondition(filters: Filter[], data: any) { data[field] === undefined ); break; + case 'checked': + res = !!data[field]; + break; + case 'notchecked': + res = !data[field]; + break; case 'null': res = res = data[field] === null; break; diff --git a/packages/nocodb/src/lib/models/Filter.ts b/packages/nocodb/src/lib/models/Filter.ts index ea82c0fb42..d6683d82f1 100644 --- a/packages/nocodb/src/lib/models/Filter.ts +++ b/packages/nocodb/src/lib/models/Filter.ts @@ -32,6 +32,8 @@ export default class Filter { | 'notempty' | 'null' | 'notnull' + | 'checked' + | 'notchecked' | 'allof' | 'anyof' | 'nallof' diff --git a/packages/nocodb/src/lib/utils/projectAcl.ts b/packages/nocodb/src/lib/utils/projectAcl.ts index b9c1317313..2ca914d7d6 100644 --- a/packages/nocodb/src/lib/utils/projectAcl.ts +++ b/packages/nocodb/src/lib/utils/projectAcl.ts @@ -17,6 +17,7 @@ export default { pluginRead: true, pluginUpdate: true, isPluginActive: true, + projectDelete: true, }, }, guest: {},