diff --git a/forms-flow-web/src/components/FOI/Dashboard/IAO/AdvancedSearch/SearchComponent.js b/forms-flow-web/src/components/FOI/Dashboard/IAO/AdvancedSearch/SearchComponent.js index 56c04bd31..5983654d2 100644 --- a/forms-flow-web/src/components/FOI/Dashboard/IAO/AdvancedSearch/SearchComponent.js +++ b/forms-flow-web/src/components/FOI/Dashboard/IAO/AdvancedSearch/SearchComponent.js @@ -100,12 +100,12 @@ const AdvancedSearch = ({ userDetail }) => { const tooltipContentRight = { "title": "Advanced Search", - "content": "To conduct an Advanced Search using one of the six filter buttons, you must also enter one or more key words." + "content": "To conduct an Advanced Search using one of the seven filter buttons, you must also enter one or more key words." }; const tooltipContentLeft = { "title": "Advanced Search", - "content": "Use one or more fields from the following sections on their own or to narrow your search: Request State/Status/Type, Date Range, or Public Body." + "content": "Use one or more fields from the following sections on their own or to narrow your search: Request State/Status/Type/Flags, Date Range, or Public Body." }; @@ -181,6 +181,23 @@ const AdvancedSearch = ({ userDetail }) => { } }); + const initialRequestFlags = { + restricted: false, + oipc: false, + phased: false + }; + const [requestFlags, setRequestFlags] = useState(() => { + if (Object.keys(advancedSearchParams).length > 0 && advancedSearchParams.requestFlags.length > 0) { + let savedRequestFlags = {...initialRequestFlags} + advancedSearchParams.requestFlags.forEach(type => { + savedRequestFlags[type] = true; + }); + return savedRequestFlags; + } else { + return initialRequestFlags; + } + }); + const [selectedDateRangeType, setSelectedDateRangeType] = useState(advancedSearchParams?.dateRangeType || ""); const [fromDate, setFromDate] = useState(advancedSearchParams?.fromDate || ""); const [toDate, setToDate] = useState(advancedSearchParams?.toDate || ""); @@ -233,6 +250,7 @@ const AdvancedSearch = ({ userDetail }) => { keywords: keywordsMode ? keywords : [searchText.trim()], requestState: getTrueKeysFromCheckboxObject(requestState), requestType: getTrueKeysFromCheckboxObject(requestTypes), + requestFlags: getTrueKeysFromCheckboxObject(requestFlags), requestStatus: getTrueKeysFromCheckboxObject(requestStatus), dateRangeType: selectedDateRangeType || null, fromDate: fromDate || null, @@ -258,6 +276,7 @@ const AdvancedSearch = ({ userDetail }) => { const noSearchCriteria = () => { let selectedRequestStates = getTrueKeysFromCheckboxObject(requestState); let selectedRequestTypes = getTrueKeysFromCheckboxObject(requestTypes); + let selectedRequestFlags = getTrueKeysFromCheckboxObject(requestFlags); let selectedRequestStatus = getTrueKeysFromCheckboxObject(requestStatus); return ((keywords.length===0 && keywordsMode) || (!searchText && !keywordsMode)) && !fromDate @@ -265,6 +284,7 @@ const AdvancedSearch = ({ userDetail }) => { && selectedPublicBodies.length===0 && selectedRequestStates.length===0 && selectedRequestTypes.length===0 + && selectedRequestFlags.length===0 && selectedRequestStatus.length===0; }; @@ -275,6 +295,7 @@ const AdvancedSearch = ({ userDetail }) => { setSearchFilterSelected(); setRequestState(intitialRequestState); setRequestTypes(initialRequestTypes); + setRequestFlags(initialRequestFlags); setRequestStatus(intitialRequestStatus); setFromDate(""); setToDate(""); @@ -323,6 +344,13 @@ const AdvancedSearch = ({ userDetail }) => { }); }; + const handleRequestFlagsChange = (event) => { + setRequestFlags({ + ...requestFlags, + [event.target.name]: event.target.checked, + }); + }; + const handleSelectedDateRangeTypeChange = (event) => { const type = event.target.value; setSelectedDateRangeType(type); @@ -491,73 +519,84 @@ const AdvancedSearch = ({ userDetail }) => { Filter by + + + + clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION) + } + clicked={ + searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION + } + /> + - - - clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION) - } - clicked={ - searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION - } - /> - + + clickSearchFilter(SearchFilter.ID_NUM)} + clicked={searchFilterSelected === SearchFilter.ID_NUM} + /> + - - clickSearchFilter(SearchFilter.ID_NUM)} - clicked={searchFilterSelected === SearchFilter.ID_NUM} - /> - + + + clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM) + } + clicked={ + searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM + } + /> + - - - clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM) - } - clicked={ - searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM - } - /> - + + clickSearchFilter(SearchFilter.APPLICANT_NAME)} + clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME} + /> + - - clickSearchFilter(SearchFilter.APPLICANT_NAME)} - clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME} - /> - + + clickSearchFilter(SearchFilter.ASSIGNEE_NAME)} + clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME} + /> + - - clickSearchFilter(SearchFilter.ASSIGNEE_NAME)} - clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME} - /> - + + clickSearchFilter(SearchFilter.SUBJECT_CODE)} + clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE} + /> + - - clickSearchFilter(SearchFilter.SUBJECT_CODE)} - clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE} - /> + + clickSearchFilter(SearchFilter.OIPC_NUMBER)} + clicked={searchFilterSelected === SearchFilter.OIPC_NUMBER} + /> + @@ -731,6 +770,61 @@ const AdvancedSearch = ({ userDetail }) => { /> + + + + Request Flags + + + + + + + } + label="Restricted" + /> + + } + label="OIPC" + /> + + } + label="Phased" + /> + + diff --git a/forms-flow-web/src/components/FOI/Dashboard/Ministry/AdvancedSearch/SearchComponent.js b/forms-flow-web/src/components/FOI/Dashboard/Ministry/AdvancedSearch/SearchComponent.js index 68f82525b..19ea4c5b6 100644 --- a/forms-flow-web/src/components/FOI/Dashboard/Ministry/AdvancedSearch/SearchComponent.js +++ b/forms-flow-web/src/components/FOI/Dashboard/Ministry/AdvancedSearch/SearchComponent.js @@ -100,12 +100,12 @@ const AdvancedSearch = ({ userDetail }) => { const tooltipContentRight = { "title": "Advanced Search", - "content": "To conduct an Advanced Search using one of the six filter buttons, you must also enter one or more key words." + "content": "To conduct an Advanced Search using one of the seven filter buttons, you must also enter one or more key words." }; const tooltipContentLeft = { "title": "Advanced Search", - "content": "Use one or more fields from the following sections on their own or to narrow your search: Request State/Status/Type, Date Range, or Public Body." + "content": "Use one or more fields from the following sections on their own or to narrow your search: Request State/Status/Type/Flags, Date Range, or Public Body." }; const [searchFilterSelected, setSearchFilterSelected] = useState(advancedSearchParams?.search || null); @@ -183,6 +183,23 @@ const AdvancedSearch = ({ userDetail }) => { return initialRequestTypes; } }); + + const initialRequestFlags = { + restricted: false, + oipc: false, + phased: false + }; + const [requestFlags, setRequestFlags] = useState(() => { + if (Object.keys(advancedSearchParams).length > 0 && advancedSearchParams.requestFlags.length > 0) { + let savedRequestFlags = {...initialRequestFlags} + advancedSearchParams.requestFlags.forEach(type => { + savedRequestFlags[type] = true; + }); + return savedRequestFlags; + } else { + return initialRequestFlags; + } + }); const [selectedDateRangeType, setSelectedDateRangeType] = useState(advancedSearchParams?.dateRangeType || ""); const [fromDate, setFromDate] = useState(advancedSearchParams?.fromDate || ""); const [toDate, setToDate] = useState(advancedSearchParams?.toDate || ""); @@ -234,6 +251,7 @@ const AdvancedSearch = ({ userDetail }) => { keywords: keywordsMode ? keywords : [searchText.trim()], requestState: getTrueKeysFromCheckboxObject(requestState), requestType: getTrueKeysFromCheckboxObject(requestTypes), + requestFlags: getTrueKeysFromCheckboxObject(requestFlags), requestStatus: getTrueKeysFromCheckboxObject(requestStatus), dateRangeType: selectedDateRangeType || null, fromDate: fromDate || null, @@ -259,6 +277,7 @@ const AdvancedSearch = ({ userDetail }) => { const noSearchCriteria = () => { let selectedRequestStates = getTrueKeysFromCheckboxObject(requestState); let selectedRequestTypes = getTrueKeysFromCheckboxObject(requestTypes); + let selectedRequestFlags = getTrueKeysFromCheckboxObject(requestFlags); let selectedRequestStatus = getTrueKeysFromCheckboxObject(requestStatus); return ((keywords.length===0 && keywordsMode) || (!searchText && !keywordsMode)) && !fromDate @@ -266,6 +285,7 @@ const AdvancedSearch = ({ userDetail }) => { && selectedPublicBodies.length===0 && selectedRequestStates.length===0 && selectedRequestTypes.length===0 + && selectedRequestFlags.length===0 && selectedRequestStatus.length===0; }; @@ -276,6 +296,7 @@ const AdvancedSearch = ({ userDetail }) => { setSearchFilterSelected(); setRequestState(intitialRequestState); setRequestTypes(initialRequestTypes); + setRequestFlags(initialRequestFlags); setRequestStatus(intitialRequestStatus); setFromDate(""); setToDate(""); @@ -336,6 +357,13 @@ const AdvancedSearch = ({ userDetail }) => { }); }; + const handleRequestFlagsChange = (event) => { + setRequestFlags({ + ...requestFlags, + [event.target.name]: event.target.checked, + }); + }; + const handleSelectedDateRangeTypeChange = (event) => { const type = event.target.value; setSelectedDateRangeType(type); @@ -504,73 +532,84 @@ const AdvancedSearch = ({ userDetail }) => { Filter by + + + + clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION) + } + clicked={ + searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION + } + /> + - - - clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION) - } - clicked={ - searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION - } - /> - - - - clickSearchFilter(SearchFilter.ID_NUM)} - clicked={searchFilterSelected === SearchFilter.ID_NUM} - /> - + + clickSearchFilter(SearchFilter.ID_NUM)} + clicked={searchFilterSelected === SearchFilter.ID_NUM} + /> + - - - clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM) - } - clicked={ - searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM - } - /> - + + + clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM) + } + clicked={ + searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM + } + /> + - - clickSearchFilter(SearchFilter.APPLICANT_NAME)} - clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME} - /> - + + clickSearchFilter(SearchFilter.APPLICANT_NAME)} + clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME} + /> + - - clickSearchFilter(SearchFilter.ASSIGNEE_NAME)} - clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME} - /> - + + clickSearchFilter(SearchFilter.ASSIGNEE_NAME)} + clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME} + /> + - - clickSearchFilter(SearchFilter.SUBJECT_CODE)} - clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE} - /> + + clickSearchFilter(SearchFilter.SUBJECT_CODE)} + clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE} + /> + + + + clickSearchFilter(SearchFilter.OIPC_NUMBER)} + clicked={searchFilterSelected === SearchFilter.OIPC_NUMBER} + /> + @@ -733,6 +772,61 @@ const AdvancedSearch = ({ userDetail }) => { /> + + + + Request Flags + + + + + + + } + label="Restricted" + /> + + } + label="OIPC" + /> + + } + label="Phased" + /> + +