do not remove columns when clicking the filter button w/ burnettk

This commit is contained in:
jasquat 2023-03-08 16:57:12 -05:00
parent e6267ae75d
commit f79f0d6116
No known key found for this signature in database
5 changed files with 102 additions and 4 deletions

View File

@ -660,6 +660,18 @@ paths:
description: The username of the process initiator
schema:
type: string
- name: report_columns
in: query
required: false
description: Base64 encoded json of report columns.
schema:
type: string
- name: report_filter_by
in: query
required: false
description: Base64 encoded json of report filter by.
schema:
type: string
get:
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_list_for_me
summary: Returns a list of process instances that are associated with me.
@ -779,6 +791,18 @@ paths:
description: The username of the process initiator
schema:
type: string
- name: report_columns
in: query
required: false
description: Base64 encoded json of report columns.
schema:
type: string
- name: report_filter_by
in: query
required: false
description: Base64 encoded json of report filter by.
schema:
type: string
get:
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_list
summary: Returns a list of process instances.

View File

@ -1,4 +1,5 @@
"""APIs for dealing with process groups, process models, and process instances."""
import base64
import json
from typing import Any
from typing import Dict
@ -251,6 +252,8 @@ def process_instance_list_for_me(
report_id: Optional[int] = None,
user_group_identifier: Optional[str] = None,
process_initiator_username: Optional[str] = None,
report_columns: Optional[str] = None,
report_filter_by: Optional[str] = None,
) -> flask.wrappers.Response:
"""Process_instance_list_for_me."""
return process_instance_list(
@ -267,6 +270,8 @@ def process_instance_list_for_me(
report_id=report_id,
user_group_identifier=user_group_identifier,
with_relation_to_me=True,
report_columns=report_columns,
report_filter_by=report_filter_by,
)
@ -285,12 +290,21 @@ def process_instance_list(
report_id: Optional[int] = None,
user_group_identifier: Optional[str] = None,
process_initiator_username: Optional[str] = None,
report_columns: Optional[str] = None,
report_filter_by: Optional[str] = None,
) -> flask.wrappers.Response:
"""Process_instance_list."""
process_instance_report = ProcessInstanceReportService.report_with_identifier(
g.user, report_id, report_identifier
)
report_column_list = None
if report_columns:
report_column_list = json.loads(base64.b64decode(report_columns))
report_filter_by_list = None
if report_filter_by:
report_filter_by_list = json.loads(base64.b64decode(report_filter_by))
if user_filter:
report_filter = ProcessInstanceReportFilter(
process_model_identifier=process_model_identifier,
@ -302,6 +316,8 @@ def process_instance_list(
with_relation_to_me=with_relation_to_me,
process_status=process_status.split(",") if process_status else None,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
else:
report_filter = (
@ -316,6 +332,8 @@ def process_instance_list(
process_status=process_status,
with_relation_to_me=with_relation_to_me,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
)

View File

@ -50,6 +50,8 @@ class ProcessInstanceReportFilter:
with_tasks_assigned_to_my_group: Optional[bool] = None
with_relation_to_me: Optional[bool] = None
process_initiator_username: Optional[str] = None
report_column_list: Optional[list] = None
report_filter_by_list: Optional[list] = None
def to_dict(self) -> dict[str, str]:
"""To_dict."""
@ -85,6 +87,10 @@ class ProcessInstanceReportFilter:
d["with_relation_to_me"] = str(self.with_relation_to_me).lower()
if self.process_initiator_username is not None:
d["process_initiator_username"] = str(self.process_initiator_username)
if self.report_column_list is not None:
d["report_column_list"] = str(self.report_column_list)
if self.report_filter_by_list is not None:
d["report_filter_by_list"] = str(self.report_filter_by_list)
return d
@ -229,6 +235,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group = bool_value("with_tasks_assigned_to_my_group")
with_relation_to_me = bool_value("with_relation_to_me")
process_initiator_username = filters.get("process_initiator_username")
report_column_list = list_value("report_column_list")
report_filter_by_list = list_value("report_filter_by_list")
report_filter = ProcessInstanceReportFilter(
process_model_identifier=process_model_identifier,
@ -244,6 +252,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group=with_tasks_assigned_to_my_group,
with_relation_to_me=with_relation_to_me,
process_initiator_username=process_initiator_username,
report_column_list=report_column_list,
report_filter_by_list=report_filter_by_list,
)
return report_filter
@ -265,6 +275,8 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group: Optional[bool] = None,
with_relation_to_me: Optional[bool] = None,
process_initiator_username: Optional[str] = None,
report_column_list: Optional[list] = None,
report_filter_by_list: Optional[list] = None,
) -> ProcessInstanceReportFilter:
"""Filter_from_metadata_with_overrides."""
report_filter = cls.filter_from_metadata(process_instance_report)
@ -291,6 +303,10 @@ class ProcessInstanceReportService:
report_filter.with_tasks_completed_by_me = with_tasks_completed_by_me
if process_initiator_username is not None:
report_filter.process_initiator_username = process_initiator_username
if report_column_list is not None:
report_filter.report_column_list = report_column_list
if report_filter_by_list is not None:
report_filter.report_filter_by_list = report_filter_by_list
if with_tasks_assigned_to_my_group is not None:
report_filter.with_tasks_assigned_to_my_group = (
with_tasks_assigned_to_my_group
@ -483,6 +499,15 @@ class ProcessInstanceReportService:
stock_columns = ProcessInstanceReportService.get_column_names_for_model(
ProcessInstanceModel
)
if report_filter.report_column_list:
process_instance_report.report_metadata["columns"] = (
report_filter.report_column_list
)
if report_filter.report_filter_by_list:
process_instance_report.report_metadata["filter_by"] = (
report_filter.report_filter_by_list
)
for column in process_instance_report.report_metadata["columns"]:
if column["accessor"] in stock_columns:
continue

View File

@ -36,6 +36,7 @@ import {
convertSecondsToFormattedDateString,
convertSecondsToFormattedDateTime,
convertSecondsToFormattedTimeHoursMinutes,
encodeBase64,
getPageInfoFromSearchParams,
getProcessModelFullIdentifierFromSearchParams,
modifyProcessIdentifierForPathParam,
@ -268,6 +269,17 @@ export default function ProcessInstanceListTable({
queryParamString += `&report_identifier=${reportIdentifier}`;
}
if (searchParams.get('report_columns')) {
queryParamString += `&report_columns=${searchParams.get(
'report_columns'
)}`;
}
if (searchParams.get('report_filter_by')) {
queryParamString += `&report_filter_by=${searchParams.get(
'report_filter_by'
)}`;
}
Object.keys(dateParametersToAlwaysFilterBy).forEach(
(paramName: string) => {
const dateFunctionToCall =
@ -529,6 +541,14 @@ export default function ProcessInstanceListTable({
};
};
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const reportFilterBy = () => {
return (reportMetadata as any).filter_by;
};
const applyFilter = (event: any) => {
event.preventDefault();
const { page, perPage } = getPageInfoFromSearchParams(
@ -578,6 +598,11 @@ export default function ProcessInstanceListTable({
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
}
const reportColumnsBase64 = encodeBase64(JSON.stringify(reportColumns()));
queryParamString += `&report_columns=${reportColumnsBase64}`;
const reportFilterByBase64 = encodeBase64(JSON.stringify(reportFilterBy()));
queryParamString += `&report_filter_by=${reportFilterByBase64}`;
removeError();
setProcessInstanceReportJustSaved(null);
setProcessInstanceFilters({});
@ -683,10 +708,6 @@ export default function ProcessInstanceListTable({
navigate(`${processInstanceListPathPrefix}${queryParamString}`);
};
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const reportColumnAccessors = () => {
return reportColumns().map((reportColumn: ReportColumn) => {
return reportColumn.accessor;

View File

@ -1,4 +1,6 @@
import { format } from 'date-fns';
import { Buffer } from 'buffer';
import {
DATE_TIME_FORMAT,
DATE_FORMAT,
@ -260,3 +262,11 @@ export const getBpmnProcessIdentifiers = (rootBpmnElement: any) => {
export const isInteger = (str: string | number) => {
return /^\d+$/.test(str.toString());
};
export const encodeBase64 = (data: string) => {
return Buffer.from(data).toString('base64');
};
export const decodeBase64 = (data: string) => {
return Buffer.from(data, 'base64').toString('ascii');
};