[WEB-4885] feat: new filters architecture and UI components (#7802)
* feat: add rich filters types * feat: add rich filters constants * feat: add rich filters utils * feat: add rich filters store in shared state package * feat: add rich filters UI components * fix: make setLoading optional in loadOptions function for improved flexibility * chore: minor improvements to rich filters * fix: formatting
This commit is contained in:
parent
00e070b509
commit
d521eab22f
83 changed files with 4345 additions and 117 deletions
1
packages/shared-state/src/utils/index.ts
Normal file
1
packages/shared-state/src/utils/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./rich-filter.helper";
|
||||
47
packages/shared-state/src/utils/rich-filter.helper.ts
Normal file
47
packages/shared-state/src/utils/rich-filter.helper.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// plane imports
|
||||
import {
|
||||
LOGICAL_OPERATOR,
|
||||
TBuildFilterExpressionParams,
|
||||
TExternalFilter,
|
||||
TFilterProperty,
|
||||
TFilterValue,
|
||||
} from "@plane/types";
|
||||
import { getOperatorForPayload } from "@plane/utils";
|
||||
// local imports
|
||||
import { FilterInstance } from "../store/rich-filters/filter";
|
||||
|
||||
/**
|
||||
* Builds a temporary filter expression from conditions.
|
||||
* @param params.conditions - The conditions for building the filter expression.
|
||||
* @param params.adapter - The adapter for building the filter expression.
|
||||
* @returns The temporary filter expression.
|
||||
*/
|
||||
export const buildTempFilterExpressionFromConditions = <
|
||||
P extends TFilterProperty,
|
||||
V extends TFilterValue,
|
||||
E extends TExternalFilter,
|
||||
>(
|
||||
params: TBuildFilterExpressionParams<P, V, E>
|
||||
): E | undefined => {
|
||||
const { conditions, adapter } = params;
|
||||
let tempExpression: E | undefined = undefined;
|
||||
const tempFilterInstance = new FilterInstance<P, E>({
|
||||
adapter,
|
||||
onExpressionChange: (expression) => {
|
||||
tempExpression = expression;
|
||||
},
|
||||
});
|
||||
for (const condition of conditions) {
|
||||
const { operator, isNegation } = getOperatorForPayload(condition.operator);
|
||||
tempFilterInstance.addCondition(
|
||||
LOGICAL_OPERATOR.AND,
|
||||
{
|
||||
property: condition.property,
|
||||
operator,
|
||||
value: condition.value,
|
||||
},
|
||||
isNegation
|
||||
);
|
||||
}
|
||||
return tempExpression;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue