Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort by division for MSD/CFD personal #503

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/reviewer_api/resources/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ def get(requestid):
timeout=float(requestapitimeout)
)
response.raise_for_status()
bcgovcode = response.json()['bcgovcode']
result = documentservice().getdocuments(requestid,bcgovcode)
return json.dumps(result), 200

jsonobj = response.json()
requestinfo = {
"requeststatusid": jsonobj["requeststatusid"],
"bcgovcode": jsonobj["bcgovcode"],
"currentstate": jsonobj["currentState"],
"requesttype": jsonobj["requestType"]
}
result = documentservice().getdocuments(requestid,requestinfo["bcgovcode"])
return json.dumps({"requestinfo": requestinfo, "documents": result}), 200
except KeyError as err:
return {'status': False, 'message':err.messages}, 400
except BusinessException as exception:
Expand Down
2 changes: 1 addition & 1 deletion api/reviewer_api/services/documentservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def updatedocumentattributes(self, payload, userid):
def getdocuments(self, requestid,bcgovcode):
divisions_data = requests.request(
method='GET',
url=requestapiurl + "/api/foiflow/divisions/{0}".format(bcgovcode),
url=requestapiurl + "/api/foiflow/divisions/{0}".format(bcgovcode) + "/all",
headers={'Authorization': AuthHelper.getauthtoken(), 'Content-Type': 'application/json'}
).json()
divisions = {div['divisionid']: div for div in divisions_data['divisions']}
Expand Down
3 changes: 2 additions & 1 deletion web/src/actions/actionConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const ACTION_CONSTANTS = {
SET_SECTIONS:"SET_SECTIONS",
SET_PAGE_FLAGS: "SET_PAGE_FLAGS",
SET_DOCUMENT_LIST: "SET_DOCUMENT_LIST",
SET_KEYWORDS: "SET_KEYWORDS"
SET_KEYWORDS: "SET_KEYWORDS",
SET_REQUEST_INFO: "SET_REQUEST_INFO"
};

export default ACTION_CONSTANTS;
9 changes: 8 additions & 1 deletion web/src/actions/documentActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ export const setKeywords = (data: any) => (dispatch:any) =>{
type:ACTION_CONSTANTS.SET_KEYWORDS,
payload:data
})
}
}

export const setRequestInfo = (data: any) => (dispatch:any) =>{
dispatch({
type:ACTION_CONSTANTS.SET_REQUEST_INFO,
payload:data
})
}
7 changes: 4 additions & 3 deletions web/src/apiManager/services/docReviewerService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { httpGETRequest, httpPOSTRequest, httpDELETERequest } from "../httpRequestHandler";
import API from "../endpoints";
import UserService from "../../services/UserService";
import { setRedactionInfo, setIsPageLeftOff, setSections, setPageFlags, setDocumentList } from "../../actions/documentActions";
import { setRedactionInfo, setIsPageLeftOff, setSections, setPageFlags, setDocumentList, setRequestInfo } from "../../actions/documentActions";
import { store } from "../../services/StoreService";


Expand All @@ -16,8 +16,9 @@ export const fetchDocuments = (
httpGETRequest(apiUrlGet, {}, UserService.getToken())
.then((res:any) => {
if (res.data) {
store.dispatch(setDocumentList(res.data) as any);
callback(res.data);
store.dispatch(setDocumentList(res.data.documents) as any);
store.dispatch(setRequestInfo(res.data.requestinfo) as any);
callback(res.data.documents);
} else {
throw new Error();
}
Expand Down
9 changes: 8 additions & 1 deletion web/src/components/FOI/Home/DocumentSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DocumentSelector = ({
setIndividualDoc,
pageMappedDocs
}: any) => {

const requestInfo = useAppSelector((state: any) => state.documents?.requestinfo);
const pageFlags = useAppSelector((state: any) => state.documents?.pageFlags);
const [files, setFiles] = useState(documents);
const [openContextPopup, setOpenContextPopup] = useState(false);
Expand Down Expand Up @@ -73,6 +73,13 @@ const DocumentSelector = ({
);
}, []);

useEffect(() => {
console.log("requestInfo", requestInfo);
if(requestInfo.requesttype == "personal" && ["MSD", "MCF"].includes(requestInfo.bcgovcode)) {
setOrganizeBy("division");
}
}, [requestInfo]);

useEffect(() => {
setPageFlagChanged(false);
fetchPageFlagsMasterData(
Expand Down
2 changes: 2 additions & 0 deletions web/src/modules/documentReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const documents = (state = initialState, action:any)=> {
return {...state, documentList: action.payload};
case ACTION_CONSTANTS.SET_KEYWORDS:
return {...state, keywords: action.payload};
case ACTION_CONSTANTS.SET_REQUEST_INFO:
return {...state, requestinfo: action.payload};
default:
return state;
}
Expand Down