added tmp link to homepage table w/ burnettk

This commit is contained in:
jasquat 2023-04-28 14:29:56 -04:00
parent b179b66e26
commit b01b398287
4 changed files with 53 additions and 16 deletions

View File

@ -231,6 +231,7 @@ def process_instance_list_for_me(
page: int = 1, page: int = 1,
per_page: int = 100, per_page: int = 100,
) -> flask.wrappers.Response: ) -> flask.wrappers.Response:
ProcessInstanceReportService.add_or_update_filter(body['report_metadata']['filter_by'], {"field_name": 'with_relation_to_me', "field_value": True})
return process_instance_list( return process_instance_list(
process_model_identifier=process_model_identifier, process_model_identifier=process_model_identifier,
page=page, page=page,

View File

@ -330,6 +330,17 @@ class ProcessInstanceReportService:
if value is not None: if value is not None:
yield value yield value
@classmethod
def add_or_update_filter(cls, filters: list[FilterValue], new_filter: FilterValue) -> None:
filter_found = False
for filter in filters:
if filter["field_name"] == new_filter['field_name']:
filter['field_value'] = new_filter['field_value']
filter_found = True
if filter_found is False:
filters.append(new_filter)
@classmethod @classmethod
def run_process_instance_report( def run_process_instance_report(
cls, cls,
@ -374,7 +385,8 @@ class ProcessInstanceReportService:
for value in cls.check_filter_value(filters, "initiated_by_me"): for value in cls.check_filter_value(filters, "initiated_by_me"):
if value is True: if value is True:
process_instance_query = process_instance_query.filter_by(process_initiator=user) # process_instance_query = process_instance_query.filter_by(process_initiator=user)
cls.add_or_update_filter(filters, {'field_name': 'process_initiator_username', 'field_value': user.username})
for value in cls.check_filter_value(filters, "has_terminal_status"): for value in cls.check_filter_value(filters, "has_terminal_status"):
if value is True: if value is True:
@ -385,11 +397,12 @@ class ProcessInstanceReportService:
process_instance_query = process_instance_query.filter( process_instance_query = process_instance_query.filter(
ProcessInstanceModel.status.not_in(ProcessInstanceModel.terminal_statuses()) # type: ignore ProcessInstanceModel.status.not_in(ProcessInstanceModel.terminal_statuses()) # type: ignore
) )
for value in cls.check_filter_value(filters, "has_active_status"):
if value is True: has_active_status = cls.get_filter_value(filters, "has_active_status")
process_instance_query = process_instance_query.filter( if has_active_status:
ProcessInstanceModel.status.in_(ProcessInstanceModel.active_statuses()) # type: ignore process_instance_query = process_instance_query.filter(
) ProcessInstanceModel.status.in_(ProcessInstanceModel.active_statuses()) # type: ignore
)
for value in cls.check_filter_value(filters, "process_initiator_username"): for value in cls.check_filter_value(filters, "process_initiator_username"):
initiator = UserModel.query.filter_by(username=value).first() initiator = UserModel.query.filter_by(username=value).first()
@ -402,8 +415,6 @@ class ProcessInstanceReportService:
with_tasks_assigned_to_my_group = cls.get_filter_value(filters, "with_tasks_assigned_to_my_group") with_tasks_assigned_to_my_group = cls.get_filter_value(filters, "with_tasks_assigned_to_my_group")
with_tasks_i_can_complete = cls.get_filter_value(filters, "with_tasks_i_can_complete") with_tasks_i_can_complete = cls.get_filter_value(filters, "with_tasks_i_can_complete")
with_relation_to_me = cls.get_filter_value(filters, "with_relation_to_me") with_relation_to_me = cls.get_filter_value(filters, "with_relation_to_me")
has_active_status = cls.get_filter_value(filters, "has_active_status")
user_group_identifier = cls.get_filter_value(filters, "user_group_identifier")
if ( if (
not with_tasks_completed_by_me not with_tasks_completed_by_me
and not with_tasks_assigned_to_my_group and not with_tasks_assigned_to_my_group
@ -436,6 +447,8 @@ class ProcessInstanceReportService:
), ),
) )
# this excludes some tasks you can complete, because that's the way the requirements were described.
# if it's assigned to one of your groups, it does not get returned by this query.
if with_tasks_i_can_complete is True: if with_tasks_i_can_complete is True:
process_instance_query = process_instance_query.filter( process_instance_query = process_instance_query.filter(
ProcessInstanceModel.process_initiator_id != user.id ProcessInstanceModel.process_initiator_id != user.id
@ -445,17 +458,15 @@ class ProcessInstanceReportService:
and_( and_(
HumanTaskModel.process_instance_id == ProcessInstanceModel.id, HumanTaskModel.process_instance_id == ProcessInstanceModel.id,
HumanTaskModel.lane_assignment_id.is_(None), # type: ignore HumanTaskModel.lane_assignment_id.is_(None), # type: ignore
HumanTaskModel.completed.is_(False) # type: ignore
), ),
).join( ).join(
HumanTaskUserModel, HumanTaskUserModel,
and_(HumanTaskUserModel.human_task_id == HumanTaskModel.id, HumanTaskUserModel.user_id == user.id), and_(HumanTaskUserModel.human_task_id == HumanTaskModel.id, HumanTaskUserModel.user_id == user.id),
) )
if has_active_status:
process_instance_query = process_instance_query.filter(
HumanTaskModel.completed.is_(False) # type: ignore
)
if with_tasks_assigned_to_my_group is True: if with_tasks_assigned_to_my_group is True:
user_group_identifier = cls.get_filter_value(filters, "user_group_identifier")
group_model_join_conditions = [GroupModel.id == HumanTaskModel.lane_assignment_id] group_model_join_conditions = [GroupModel.id == HumanTaskModel.lane_assignment_id]
if user_group_identifier: if user_group_identifier:
group_model_join_conditions.append(GroupModel.identifier == user_group_identifier) group_model_join_conditions.append(GroupModel.identifier == user_group_identifier)
@ -528,10 +539,10 @@ class ProcessInstanceReportService:
for value in cls.check_filter_value(filters, "oldest_open_human_task_fields"): for value in cls.check_filter_value(filters, "oldest_open_human_task_fields"):
results = cls.add_human_task_fields(results, value.split(",")) results = cls.add_human_task_fields(results, value.split(","))
report_metadata['filter_by'] = filters
response_json = { response_json = {
"report_metadata": report_metadata, "report_metadata": report_metadata,
"results": results, "results": results,
"filters": filters,
"pagination": { "pagination": {
"count": len(results), "count": len(results),
"total": process_instances.total, "total": process_instances.total,

View File

@ -1,5 +1,10 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; import {
Link,
useNavigate,
useParams,
useSearchParams,
} from 'react-router-dom';
// @ts-ignore // @ts-ignore
import { Close, AddAlt } from '@carbon/icons-react'; import { Close, AddAlt } from '@carbon/icons-react';
@ -91,6 +96,7 @@ type OwnProps = {
variant?: string; variant?: string;
canCompleteAllTasks?: boolean; canCompleteAllTasks?: boolean;
showActionsColumn?: boolean; showActionsColumn?: boolean;
showLinkToReport?: boolean;
}; };
interface dateParameters { interface dateParameters {
@ -111,6 +117,7 @@ export default function ProcessInstanceListTable({
variant = 'for-me', variant = 'for-me',
canCompleteAllTasks = false, canCompleteAllTasks = false,
showActionsColumn = false, showActionsColumn = false,
showLinkToReport = false,
}: OwnProps) { }: OwnProps) {
let processInstanceApiSearchPath = '/process-instances/for-me'; let processInstanceApiSearchPath = '/process-instances/for-me';
if (variant === 'all') { if (variant === 'all') {
@ -200,6 +207,8 @@ export default function ProcessInstanceListTable({
string | null string | null
>(null); >(null);
const [reportHash, setReportHash] = useState<string | null>(null);
const [ const [
processInitiatorNotFoundErrorText, processInitiatorNotFoundErrorText,
setProcessInitiatorNotFoundErrorText, setProcessInitiatorNotFoundErrorText,
@ -280,6 +289,9 @@ export default function ProcessInstanceListTable({
setPagination(result.pagination); setPagination(result.pagination);
setReportMetadata(result.report_metadata); setReportMetadata(result.report_metadata);
if (result.report_hash) {
setReportHash(result.report_hash);
}
}, []); }, []);
const setProcessInstancesFromApplyFilter = (result: any) => { const setProcessInstancesFromApplyFilter = (result: any) => {
@ -1550,6 +1562,15 @@ export default function ProcessInstanceListTable({
return null; return null;
}; };
const linkToReport = () => {
if (!showLinkToReport) {
return null;
}
return (
<Link to={`/admin/process-instances?report_hash=${reportHash}`}>Hey</Link>
);
};
let resultsTable = null; let resultsTable = null;
if (pagination && (!textToShowIfEmpty || pagination.total > 0)) { if (pagination && (!textToShowIfEmpty || pagination.total > 0)) {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
@ -1598,6 +1619,7 @@ export default function ProcessInstanceListTable({
<> <>
{reportColumnForm()} {reportColumnForm()}
{processInstanceReportSaveTag()} {processInstanceReportSaveTag()}
{linkToReport()}
<Filters <Filters
filterOptions={filterOptions} filterOptions={filterOptions}
showFilterOptions={showFilterOptions} showFilterOptions={showFilterOptions}

View File

@ -40,7 +40,7 @@ export default function InProgressInstances() {
]} ]}
canCompleteAllTasks canCompleteAllTasks
showActionsColumn showActionsColumn
autoReload autoReload={false}
/> />
</> </>
); );
@ -67,9 +67,11 @@ export default function InProgressInstances() {
showReports={false} showReports={false}
textToShowIfEmpty="There are no open instances you started at this time." textToShowIfEmpty="There are no open instances you started at this time."
paginationClassName="with-large-bottom-margin" paginationClassName="with-large-bottom-margin"
showLinkToReport
showActionsColumn showActionsColumn
autoReload autoReload={false}
/> />
{/*
<h2 <h2
title={waitingForMeTitleText} title={waitingForMeTitleText}
className="process-instance-table-header" className="process-instance-table-header"
@ -89,6 +91,7 @@ export default function InProgressInstances() {
autoReload autoReload
/> />
{groupTableComponents()} {groupTableComponents()}
*/}
</> </>
); );
} }