Skip to content

Commit

Permalink
filter based on value (#2108)
Browse files Browse the repository at this point in the history
* added change for param search

* upgrade the migration file
  • Loading branch information
abilpraju-aot authored Jun 18, 2024
1 parent a0c29f7 commit 3e8874d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 21 deletions.
33 changes: 33 additions & 0 deletions forms-flow-api/migrations/versions/c8e7baa093ba_filter_updation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""empty message
Revision ID: c8e7baa093ba
Revises: 77d8b68e6c1f
Create Date: 2024-06-12 15:16:54.882030
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c8e7baa093ba'
down_revision = '77d8b68e6c1f'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
conn = op.get_bind()
conn.execute(sa.text('''
UPDATE public."filter" f SET criteria = (f.criteria::jsonb - 'processDefinitionNameLike') ||
jsonb_build_object('processDefinitionKey', fpm.process_key) FROM public.form_process_mapper fpm
WHERE f.criteria IS NOT NULL AND f.criteria::jsonb->>'processDefinitionNameLike' LIKE '%' || SPLIT_PART(fpm.process_name, ' (', 1) || '%';
'''))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const searchData = [
},
{
label: <Translation>{(t) => t("Process Definition Name")}</Translation>,
compares: ["like", "="],
values: ["processDefinitionNameLike", "processDefinitionName"],
compares: ["="],
values: ["processDefinitionKey", "processDefinitionName"],
},
{
label: <Translation>{(t) => t("Assignee")}</Translation>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function CreateNewFilterDrawer({
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const process = useSelector((state) => state.process?.processList);
const processList = useMemo(() => listProcess(process, true), [process]);

const userGroups = useSelector(
(state) => state.userAuthorization?.userGroups
);
Expand Down Expand Up @@ -140,20 +141,20 @@ export default function CreateNewFilterDrawer({
dispatch(setFilterListParams(cloneDeep(selectedBPMFilterParams)));
};

const customTrim = (inputString) => {
// Remove '%' symbol from the start
const startIndex = inputString?.indexOf("%");
if (startIndex === 0) {
inputString = inputString?.substring(1);
}

// Remove '%' symbol from the end
const endIndex = inputString?.lastIndexOf("%");
if (endIndex === inputString?.length - 1) {
inputString = inputString?.substring(0, endIndex);
}
return inputString;
};
// const customTrim = (inputString) => {
// // Remove '%' symbol from the start
// const startIndex = inputString?.indexOf("%");
// if (startIndex === 0) {
// inputString = inputString?.substring(1);
// }

// // Remove '%' symbol from the end
// const endIndex = inputString?.lastIndexOf("%");
// if (endIndex === inputString?.length - 1) {
// inputString = inputString?.substring(0, endIndex);
// }
// return inputString;
// };

const handleFetchTaskVariables = (formId) => {
setProcessLoading(true);
Expand Down Expand Up @@ -183,8 +184,8 @@ export default function CreateNewFilterDrawer({
if (selectedFilterData) {
setFilterName(selectedFilterData?.name);
let processDefinitionName =
selectedFilterData?.criteria?.processDefinitionNameLike;
setDefinitionKeyId(customTrim(processDefinitionName));
selectedFilterData?.criteria?.processDefinitionKey;
setDefinitionKeyId(processDefinitionName);
let candidateGroupName = selectedFilterData?.criteria?.candidateGroup;
if (
MULTITENANCY_ENABLED &&
Expand Down Expand Up @@ -394,7 +395,7 @@ export default function CreateNewFilterDrawer({
const data = {
name: filterName,
criteria: {
processDefinitionNameLike: definitionKeyId && `%${definitionKeyId}%`,
processDefinitionKey : definitionKeyId ,
candidateGroup:
MULTITENANCY_ENABLED && candidateGroup
? tenantKey + "-" + candidateGroup
Expand Down Expand Up @@ -725,9 +726,9 @@ export default function CreateNewFilterDrawer({
options={processList}
placeholder={t("Select Workflow")}
isClearable
value={processList?.find((list) => list.label === definitionKeyId)}
value={processList?.find((list) => list.value === definitionKeyId)}
onChange={(selectedOption) => {
setDefinitionKeyId(selectedOption?.label);
setDefinitionKeyId(selectedOption?.value);
}}
filterOption={filterSelectOptionByLabel}
inputId="select-workflow"
Expand Down

0 comments on commit 3e8874d

Please sign in to comment.