-
- {t("case:documents-name-label")}
+
-
{/* {t("case:documents-doc-type-label")} */}
@@ -263,11 +326,22 @@ const DocumentDetails = (props) => {
};
useEffect(() => {
+ getDocumentTypes();
if (selectedOption) {
setShowSpinnerState(true);
getDocumentResults(1, orderByState, fieldSortState);
}
+ if (selectedDocumentType) {
+ setShowSpinnerState(true);
+ getDocumentResults(
+ 1,
+ orderByState,
+ fieldSortState,
+ selectedDocumentType
+ );
+ }
+
const docDetailsObj = async () => {
let docObj = await getSearchDocumentDetails(incidentid).then(
(data) => {
@@ -287,11 +361,18 @@ const DocumentDetails = (props) => {
incidentid,
setDocumentDetails,
selectedOption,
+ selectedDocumentType,
fieldSortState,
orderByState,
getDocumentResults,
]);
+ const getDocumentTypes = useCallback(() => {
+ getSearchDocumentTypes(props.incidentid).then((data) => {
+ setDocumentTypes(data);
+ });
+ });
+
const getDocumentResults = useCallback(
(pageNumber, orderBy, fieldSort) => {
getSearchDocumentDetailsPaged(
@@ -299,7 +380,8 @@ const DocumentDetails = (props) => {
pageNumber,
orderBy,
fieldSort,
- selectedOption
+ selectedOption,
+ selectedDocumentType
)
.then((data) => data)
.then((data) => {
@@ -308,7 +390,7 @@ const DocumentDetails = (props) => {
setShowSpinnerState(false);
});
},
- [props.incidentid, selectedOption, setDocumentDetails]
+ [props.incidentid, selectedOption, selectedDocumentType]
);
const getDocumentDetails = async () => {
diff --git a/pages/api/endpoint/getsearchdocumentTypes_api.js b/pages/api/endpoint/getsearchdocumentTypes_api.js
new file mode 100644
index 00000000..a4ca5c6c
--- /dev/null
+++ b/pages/api/endpoint/getsearchdocumentTypes_api.js
@@ -0,0 +1,80 @@
+import axios from "axios";
+import CryptoJS from "crypto-js";
+import _ from "lodash";
+import { getToken, azureHeaders } from "../../../actions";
+
+const WORDKEY = process.env.HASHKEY;
+
+const WEBAPI_URL =
+ process.env.RELAY_ROOT ||
+ "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
+
+const hashAPIPath = (queryPath) => {
+ var hashlink = CryptoJS.HmacSHA256(
+ queryPath,
+ CryptoJS.enc.Hex.parse(WORDKEY)
+ );
+ hashlink = hashlink.toString(CryptoJS.enc.Hex);
+
+ //return "&hash=" + hashlink;
+
+ return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
+};
+
+const groupArray = (arr = []) => {
+ // create map
+ let map = new Map();
+ for (let i = 0; i < arr.length; i++) {
+ const s = JSON.stringify(arr[i]);
+ if (!map.has(s)) {
+ map.set(s, {
+ pinswg_isharedocumentlocations:
+ arr[i].pinswg_isharedocumentlocations,
+ pinswg_isharedocumentlocationsLabel:
+ arr[i][
+ "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
+ ],
+ // count: 1,
+ });
+ } else {
+ //map.get(s).count++;
+ }
+ }
+ const res = Array.from(map.values());
+ return res;
+};
+
+export default async function ApiProxy(req, res) {
+ var incidentID = req.query.incidentid;
+ var token = await getToken();
+
+ var queryUrl =
+ "pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
+ incidentID +
+ " and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations";
+
+ //console.log("docu: ", WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
+
+ return axios
+ .get(
+ WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
+ azureHeaders(token.access_token)
+ )
+ .then(({ data }) => {
+ //delete data["pinswg_documentid"];
+ data.value.forEach(function (element) {
+ delete element["pinswg_documentid"];
+ });
+
+ var dataArr = groupArray(data.value);
+
+ // var dataStr;
+ // _.has(data, "@odata.nextLink") == true &&
+ // ((dataStr = JSON.stringify(data["@odata.nextLink"])),
+ // (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
+ res.status(200).json(dataArr);
+ })
+ .catch(({ err }) => {
+ res.status(400).json(err);
+ });
+}
diff --git a/pages/api/endpoint/getsearchdocumentdetails_api.js b/pages/api/endpoint/getsearchdocumentdetails_api.js
index 6db8b45b..a5b8a19c 100644
--- a/pages/api/endpoint/getsearchdocumentdetails_api.js
+++ b/pages/api/endpoint/getsearchdocumentdetails_api.js
@@ -43,7 +43,7 @@ export default async function ApiProxy(req, res) {
incidentID +
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate";
- console.log("docu: ", WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
+ //console.log("docu: ", WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
return axios
.get(
diff --git a/pages/api/endpoint/getsearchdocumentdetailspaged_api.js b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js
index 953107c7..7a9c7c5b 100644
--- a/pages/api/endpoint/getsearchdocumentdetailspaged_api.js
+++ b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js
@@ -42,11 +42,19 @@ export default async function ApiProxy(req, res) {
var orderby = req.query.orderby;
var fieldSort = req.query.fieldSort;
var showNumberOfRecords = req.query.showNumberOfRecords;
+ var documentType = req.query.documentType || "all";
+
+ console.log("has this passed docuemntType:", documentType);
+ //(documentType !="all" && " pinswg_pinswg_isharedocumentlocations eq " + )
var queryUrl =
"pinswg_documents?$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
- " and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate&$orderby=" +
+ " and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null" +
+ (documentType != "all"
+ ? " and pinswg_isharedocumentlocations eq " + documentType
+ : "") +
+ "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate&$orderby=" +
orderby +
" " +
fieldSort +
diff --git a/store/store.js b/store/store.js
index 922b0ba7..5cefff1c 100644
--- a/store/store.js
+++ b/store/store.js
@@ -122,7 +122,7 @@ const makeStore = ({ isServer }) => {
"govGateway",
"form",
],
- version: 1.1,
+ version: 1.2,
storage: storage,
stateReconciler: autoMergeLevel2, // if needed, use a safer storage
migrate: (state) => {
diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss
index dde24ffa..8dc8b58e 100644
--- a/styles/sass/welshgov/_application.scss
+++ b/styles/sass/welshgov/_application.scss
@@ -806,7 +806,6 @@ textarea,
.govuk-summary-list__key,
.govuk-summary-list__value,
.govuk-summary-list__actions {
- border-bottom: 1px solid $lightgrey_semi;
padding: 15px 10px 15px 0;
a,
a:active,
@@ -823,6 +822,10 @@ textarea,
border: $yellow solid 3px;
outline: 3px solid transparent;
}
+ @media screen and (min-width: 768px) {
+ border-bottom: 1px solid $lightgrey_semi;
+ }
+
}
.documentList {
@@ -1938,6 +1941,27 @@ fade {
// record selection
+.documentFilters{
+ @media screen and (min-width: 768px) {
+ display:flex;
+ justify-content: space-between;
+ }
+
+}
+
+#recordDocumentTypeSelect{
+ text-align: left;
+
+ @media screen and (min-width: 768px) {
+ text-align: right;
+ }
+ select {
+ margin-right: 10px;
+ margin-left: 10px;
+ background-position: 98% 15px;
+ }
+}
+
#recordCountSelect {
text-align: left;