Type ahead cleanup (#253)
This commit is contained in:
parent
024a99c448
commit
4bff2bca95
|
@ -41,8 +41,8 @@ SPIFFWORKFLOW_BACKEND_URL = environ.get("SPIFFWORKFLOW_BACKEND_URL", default="ht
|
|||
SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL", default="http://localhost:7004"
|
||||
)
|
||||
SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPE_AHEAD_URL = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPE_AHEAD_URL",
|
||||
SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPEAHEAD_URL = environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPEAHEAD_URL",
|
||||
default="https://emehvlxpwodjawtgi7ctkbvpse0vmaow.lambda-url.us-east-1.on.aws",
|
||||
)
|
||||
|
||||
|
|
|
@ -8,18 +8,14 @@ from flask.wrappers import Response
|
|||
|
||||
def connector_proxy_typeahead_url() -> Any:
|
||||
"""Returns the connector proxy type ahead url."""
|
||||
return current_app.config["SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPE_AHEAD_URL"]
|
||||
return current_app.config["SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_TYPEAHEAD_URL"]
|
||||
|
||||
|
||||
def typeahead(category: str, prefix: str, limit: int) -> flask.wrappers.Response:
|
||||
url = f"{connector_proxy_typeahead_url()}/v1/type-ahead/{category}?prefix={prefix}&limit={limit}"
|
||||
url = f"{connector_proxy_typeahead_url()}/v1/typeahead/{category}?prefix={prefix}&limit={limit}"
|
||||
|
||||
proxy_response = requests.get(url)
|
||||
status = proxy_response.status_code
|
||||
if status // 100 == 2:
|
||||
response = proxy_response.text
|
||||
else:
|
||||
# supress pop up errors on the client
|
||||
status = 200
|
||||
response = "[]"
|
||||
response = proxy_response.text
|
||||
|
||||
return Response(response, status=status, mimetype="application/json")
|
||||
|
|
|
@ -23,7 +23,7 @@ import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
|||
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
||||
|
||||
// TODO: move this somewhere else
|
||||
function TypeAheadWidget({
|
||||
function TypeaheadWidget({
|
||||
id,
|
||||
onChange,
|
||||
options: { category, itemFormat },
|
||||
|
@ -60,7 +60,7 @@ function TypeAheadWidget({
|
|||
}
|
||||
};
|
||||
|
||||
const typeAheadSearch = (inputText: string) => {
|
||||
const typeaheadSearch = (inputText: string) => {
|
||||
if (inputText) {
|
||||
lastSearchTerm.current = inputText;
|
||||
// TODO: check cache of prefixes -> results
|
||||
|
@ -74,7 +74,7 @@ function TypeAheadWidget({
|
|||
|
||||
return (
|
||||
<ComboBox
|
||||
onInputChange={typeAheadSearch}
|
||||
onInputChange={typeaheadSearch}
|
||||
onChange={(event: any) => {
|
||||
setSelectedItem(event.selectedItem);
|
||||
onChange(itemToString(event.selectedItem));
|
||||
|
@ -83,7 +83,6 @@ function TypeAheadWidget({
|
|||
items={items}
|
||||
itemToString={itemToString}
|
||||
placeholder={`Start typing to search for ${category}...`}
|
||||
titleText={`Type ahead search for ${category}`}
|
||||
selectedItem={selectedItem}
|
||||
/>
|
||||
);
|
||||
|
@ -394,7 +393,7 @@ export default function TaskShow() {
|
|||
return getFieldsWithDateValidations(jsonSchema, formData, errors);
|
||||
};
|
||||
|
||||
const widgets = { typeAhead: TypeAheadWidget };
|
||||
const widgets = { typeahead: TypeaheadWidget };
|
||||
|
||||
return (
|
||||
<Grid fullWidth condensed>
|
||||
|
|
Loading…
Reference in New Issue