some base work to try to get display names searchable for process models w/ burnettk
This commit is contained in:
parent
3800389e4c
commit
6231ccab6c
|
@ -285,6 +285,12 @@ paths:
|
||||||
description: Get only the process models that the user can run
|
description: Get only the process models that the user can run
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
- name: include_parent_groups
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: Get the display names for the parent groups as well
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
- name: page
|
- name: page
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -388,6 +388,7 @@ def process_model_list(
|
||||||
process_group_identifier: Optional[str] = None,
|
process_group_identifier: Optional[str] = None,
|
||||||
recursive: Optional[bool] = False,
|
recursive: Optional[bool] = False,
|
||||||
filter_runnable_by_user: Optional[bool] = False,
|
filter_runnable_by_user: Optional[bool] = False,
|
||||||
|
include_parent_groups: Optional[bool] = False,
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
per_page: int = 100,
|
per_page: int = 100,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
|
@ -397,22 +398,29 @@ def process_model_list(
|
||||||
recursive=recursive,
|
recursive=recursive,
|
||||||
filter_runnable_by_user=filter_runnable_by_user,
|
filter_runnable_by_user=filter_runnable_by_user,
|
||||||
)
|
)
|
||||||
batch = ProcessModelService().get_batch(
|
process_models_to_return = ProcessModelService().get_batch(
|
||||||
process_models, page=page, per_page=per_page
|
process_models, page=page, per_page=per_page
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if include_parent_groups:
|
||||||
|
for process_model in process_models_to_return:
|
||||||
|
process_model.parent_groups = ProcessModelService.get_parent_group_array(
|
||||||
|
process_model.id
|
||||||
|
)
|
||||||
|
|
||||||
pages = len(process_models) // per_page
|
pages = len(process_models) // per_page
|
||||||
remainder = len(process_models) % per_page
|
remainder = len(process_models) % per_page
|
||||||
if remainder > 0:
|
if remainder > 0:
|
||||||
pages += 1
|
pages += 1
|
||||||
response_json = {
|
response_json = {
|
||||||
"results": ProcessModelInfoSchema(many=True).dump(batch),
|
"results": process_models_to_return,
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"count": len(batch),
|
"count": len(process_models_to_return),
|
||||||
"total": len(process_models),
|
"total": len(process_models),
|
||||||
"pages": pages,
|
"pages": pages,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return Response(json.dumps(response_json), status=200, mimetype="application/json")
|
return make_response(jsonify(response_json), 200)
|
||||||
|
|
||||||
|
|
||||||
def process_list() -> Any:
|
def process_list() -> Any:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
} from '@carbon/react';
|
} from '@carbon/react';
|
||||||
import { truncateString } from '../helpers';
|
import { truncateString } from '../helpers';
|
||||||
import { ProcessModel } from '../interfaces';
|
import { ProcessGroupLite, ProcessModel } from '../interfaces';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
onChange: (..._args: any[]) => any;
|
onChange: (..._args: any[]) => any;
|
||||||
|
@ -18,12 +18,23 @@ export default function ProcessModelSearch({
|
||||||
onChange,
|
onChange,
|
||||||
titleText = 'Process model',
|
titleText = 'Process model',
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
|
const getParentGroupsDisplayName = (processModel: ProcessModel) => {
|
||||||
|
if (processModel.parent_groups) {
|
||||||
|
return processModel.parent_groups
|
||||||
|
.map((parentGroup: ProcessGroupLite) => {
|
||||||
|
return parentGroup.display_name;
|
||||||
|
})
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
const shouldFilterProcessModel = (options: any) => {
|
const shouldFilterProcessModel = (options: any) => {
|
||||||
const processModel: ProcessModel = options.item;
|
const processModel: ProcessModel = options.item;
|
||||||
const { inputValue } = options;
|
const { inputValue } = options;
|
||||||
return `${processModel.id} (${processModel.display_name})`.includes(
|
return `${processModel.id} (${getParentGroupsDisplayName(processModel)} ${
|
||||||
inputValue
|
processModel.display_name
|
||||||
);
|
})`.includes(inputValue);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<ComboBox
|
<ComboBox
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default function ProcessGroupList() {
|
||||||
};
|
};
|
||||||
// for search box
|
// for search box
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/process-models?per_page=1000&recursive=true`,
|
path: `/process-models?per_page=1000&recursive=true&include_parent_groups=true`,
|
||||||
successCallback: processResultForProcessModels,
|
successCallback: processResultForProcessModels,
|
||||||
});
|
});
|
||||||
}, [searchParams]);
|
}, [searchParams]);
|
||||||
|
|
Loading…
Reference in New Issue