From 659e87e56ee6f78d5bb65b69b0dd89cd0fad3831 Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:23:44 -0700 Subject: [PATCH] fix recursive formatting & fix search bug --- backend/src/report/report.service.ts | 8 ++++ .../content/pages/ManageProvisionsPage.tsx | 41 +++++++++++++++---- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/backend/src/report/report.service.ts b/backend/src/report/report.service.ts index 317c60f6..f8047708 100644 --- a/backend/src/report/report.service.ts +++ b/backend/src/report/report.service.ts @@ -153,6 +153,14 @@ export class ReportService { }); } + // individual Signing block takes 2 cdogs requests to be fully filled in, so this regex + // makes sure that the db_name_tenant variable is formatted correctly + if (free_text.toLowerCase().includes('db_name_tenant}')) { + free_text = free_text.replace(/db_name_tenant}/gi, 'DB_NAME_TENANT:convCRLF()}'); + } else if (free_text.toLowerCase().includes('db_name_tenant:convcrlf()}')) { + free_text = free_text.replace(/db_name_tenant:convcrlf\(\)}/gi, 'DB_NAME_TENANT:convCRLF()}'); + } + const key = `SECTION_${provision_group}`; if (!provisions[key]) { provisions[key] = []; diff --git a/frontend/src/app/content/pages/ManageProvisionsPage.tsx b/frontend/src/app/content/pages/ManageProvisionsPage.tsx index 2e6277bb..7a2dabfe 100644 --- a/frontend/src/app/content/pages/ManageProvisionsPage.tsx +++ b/frontend/src/app/content/pages/ManageProvisionsPage.tsx @@ -12,7 +12,6 @@ import { removeProvision, updateProvision, } from '../../common/manage-provisions'; -import SimpleSearch from '../../components/common/SimpleSearch'; interface ManageProvisionsPageProps {} @@ -27,6 +26,7 @@ const ManageProvisionsPage: FC = () => { const [showRemoveProvisionModal, setShowRemoveProvisionModal] = useState(false); const [refreshTrigger, setRefreshTrigger] = useState(0); const [filteredProvisions, setFilteredProvisions] = useState([]); + const [filterText, setFilterText] = useState(''); useEffect(() => { const getData = async () => { @@ -46,7 +46,11 @@ const ManageProvisionsPage: FC = () => { useEffect(() => { if (data.allProvisions) { - setFilteredProvisions(data.allProvisions); + if (!filterText || filterText === '') { + setFilteredProvisions(data.allProvisions); + } else { + handleFilterProvisions(filterText); + } } }, [data.allProvisions]); @@ -76,8 +80,22 @@ const ManageProvisionsPage: FC = () => { refreshTables(); }; - const handleSearch = (filteredProvisions: Provision[]) => { - setFilteredProvisions(filteredProvisions); + const handleSearch = (event: React.ChangeEvent) => { + const text: string = event.target.value; + handleFilterProvisions(text); + }; + + const handleFilterProvisions = (searchTerm: string) => { + const searchKeys: string[] = ['provision_name', 'category']; + setFilterText(searchTerm); + + const fp: Provision[] = data.allProvisions + ? data.allProvisions.filter((item) => + searchKeys.some((key) => (item as any)[key]?.toString().toLowerCase().includes(searchTerm.toLowerCase())) + ) + : []; + + setFilteredProvisions(fp); }; const currentVariables = data.allVariables?.filter((v) => v.provision_id === currentProvision?.id) || []; @@ -86,11 +104,16 @@ const ManageProvisionsPage: FC = () => { <>

Manage Provisions


- +
+ +