Skip to content

Commit

Permalink
Merge pull request #4846 from bcgov/dev-rook-MD-4783
Browse files Browse the repository at this point in the history
4783 - Advanced search for OIPC
  • Loading branch information
sumathi-thirumani authored Dec 7, 2023
2 parents 0c5e061 + c8a7c5b commit 4d500b4
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const fetchAdvancedSearchData = ({
requestState = [],
requestStatus = [],
requestType = [],
requestFlags = [],
dateRangeType = null,
fromDate = null,
toDate = null,
Expand Down Expand Up @@ -41,6 +42,7 @@ export const fetchAdvancedSearchData = ({
requestState: requestState,
requestStatus: requestStatus,
requestType: requestType,
requestFlags: requestFlags,
dateRangeType: dateRangeType,
fromDate: fromDate,
toDate: toDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
};


Expand Down Expand Up @@ -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 || "");
Expand Down Expand Up @@ -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,
Expand All @@ -258,13 +276,15 @@ 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
&& !toDate
&& selectedPublicBodies.length===0
&& selectedRequestStates.length===0
&& selectedRequestTypes.length===0
&& selectedRequestFlags.length===0
&& selectedRequestStatus.length===0;
};

Expand All @@ -275,6 +295,7 @@ const AdvancedSearch = ({ userDetail }) => {
setSearchFilterSelected();
setRequestState(intitialRequestState);
setRequestTypes(initialRequestTypes);
setRequestFlags(initialRequestFlags);
setRequestStatus(intitialRequestStatus);
setFromDate("");
setToDate("");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -491,73 +519,84 @@ const AdvancedSearch = ({ userDetail }) => {
Filter by
</Typography>
</Grid>
<Grid container xs={12}>
<Grid item xs>
<ClickableChip
key={`filter-request-description`}
label={"REQUEST DESCRIPTION"}
color="primary"
onClick={() =>
clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION)
}
clicked={
searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION
}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-request-description`}
label={"REQUEST DESCRIPTION"}
color="primary"
onClick={() =>
clickSearchFilter(SearchFilter.REQUEST_DESCRIPTION)
}
clicked={
searchFilterSelected === SearchFilter.REQUEST_DESCRIPTION
}
/>
</Grid>
<Grid item xs>
<ClickableChip
key={`filter-raw-request`}
label={"ID NUMBER"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.ID_NUM)}
clicked={searchFilterSelected === SearchFilter.ID_NUM}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-raw-request`}
label={"ID NUMBER"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.ID_NUM)}
clicked={searchFilterSelected === SearchFilter.ID_NUM}
/>
</Grid>
<Grid item xs>
<ClickableChip
key={`filter-axis-request`}
label={"AXIS REQUEST #"}
color="primary"
onClick={() =>
clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM)
}
clicked={
searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM
}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-axis-request`}
label={"AXIS REQUEST #"}
color="primary"
onClick={() =>
clickSearchFilter(SearchFilter.AXIS_REQUEST_NUM)
}
clicked={
searchFilterSelected === SearchFilter.AXIS_REQUEST_NUM
}
/>
</Grid>
<Grid item xs>
<ClickableChip
key={`filter-applicant-name`}
label={"APPLICANT NAME"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.APPLICANT_NAME)}
clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-applicant-name`}
label={"APPLICANT NAME"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.APPLICANT_NAME)}
clicked={searchFilterSelected === SearchFilter.APPLICANT_NAME}
/>
</Grid>
<Grid item xs>
<ClickableChip
key={`filter-assignee-name`}
label={"ASSIGNEE NAME"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.ASSIGNEE_NAME)}
clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-assignee-name`}
label={"ASSIGNEE NAME"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.ASSIGNEE_NAME)}
clicked={searchFilterSelected === SearchFilter.ASSIGNEE_NAME}
/>
</Grid>
<Grid item xs>
<ClickableChip
key={`filter-search-filter`}
label={"SUBJECT CODE"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.SUBJECT_CODE)}
clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE}
/>
</Grid>

<Grid item xs={2}>
<ClickableChip
key={`filter-search-filter`}
label={"SUBJECT CODE"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.SUBJECT_CODE)}
clicked={searchFilterSelected === SearchFilter.SUBJECT_CODE}
/>
<Grid item xs>
<ClickableChip
key={`filter-oipc-number`}
label={"OIPC NUMBER"}
color="primary"
onClick={() => clickSearchFilter(SearchFilter.OIPC_NUMBER)}
clicked={searchFilterSelected === SearchFilter.OIPC_NUMBER}
/>
</Grid>
</Grid>

<Grid item xs={2} container direction="row" rowSpacing={2}>
Expand Down Expand Up @@ -731,6 +770,61 @@ const AdvancedSearch = ({ userDetail }) => {
/>
</FormGroup>
</Grid>

<Grid item xs={12}>
<Typography
sx={{
fontWeight: "bold",
}}
variant="h6"
>
Request Flags
</Typography>
</Grid>

<Grid item xs={12}>
<FormGroup>
<FormControlLabel
className={classes.checkboxLabel}
control={
<Checkbox
size="small"
name="restricted"
onChange={handleRequestFlagsChange}
checked={requestFlags.restricted}
color="success"
/>
}
label="Restricted"
/>
<FormControlLabel
className={classes.checkboxLabel}
control={
<Checkbox
size="small"
name="oipc"
onChange={handleRequestFlagsChange}
checked={requestFlags.oipc}
color="success"
/>
}
label="OIPC"
/>
<FormControlLabel
className={classes.checkboxLabel}
control={
<Checkbox
size="small"
name="phased"
onChange={handleRequestFlagsChange}
checked={requestFlags.phased}
color="success"
/>
}
label="Phased"
/>
</FormGroup>
</Grid>
</Grid>

<Grid item xs={6} container direction="row" spacing={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const SearchFilter = Object.freeze({
APPLICANT_NAME: "applicantname",
ASSIGNEE_NAME: "assigneename",
SUBJECT_CODE: "subjectcode",
OIPC_NUMBER: "oipc_number"
});

const DateRangeTypes = Object.freeze([
Expand Down
Loading

0 comments on commit 4d500b4

Please sign in to comment.