From 11334e23663bdc2922e85d5af42fcfc8f3240adf Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 4 Mar 2022 10:31:03 +0000 Subject: [PATCH] removed references to doc history --- actions/index.js | 30 ---- components/case.js | 2 - components/case/documents.js | 276 +++++++++++---------------------- pages/case/index.js | 3 - pages/dns/[developmentName].js | 3 - pages/myportal/case.js | 3 - store/searchOutput/reducer.js | 7 +- 7 files changed, 90 insertions(+), 234 deletions(-) diff --git a/actions/index.js b/actions/index.js index f158154c..98a9e518 100644 --- a/actions/index.js +++ b/actions/index.js @@ -365,36 +365,6 @@ export const getSearchDocumentDetailsPaged = ( }); }; -export const getSearchDocumentHistory = (documentID) => { - return axios - .get( - "/api/endpoint/getsearchdocumenthistory_api?documentid=" + - documentID - ) - .then((res) => { - return res.data; - }) - .catch((error) => { - console.log("API call error", error); - }); -}; - -export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => { - return axios - .get( - "/api/endpoint/getsearchdocumenthistorypaged_api?documentid=" + - documentID + - "&pageNumber=" + - pageNumber - ) - .then((res) => { - return res.data; - }) - .catch((error) => { - console.log("API call error", error); - }); -}; - export const getLinkedCases = (parentIncidentid) => { return axios .get( diff --git a/components/case.js b/components/case.js index 08973ff5..f6c2ab0a 100644 --- a/components/case.js +++ b/components/case.js @@ -42,7 +42,6 @@ const Case = (props) => { searchResultsObj={props.searchResultsObj} searchDetailsObj={props.searchDetailsObj} documentDetailsObj={props.documentDetailsObj} - documentHistoryObj={props.documentHistoryObj} /> {showRepresentations == "true" && ( { caseReference={props.caseReference} representationsObj={props.representationsObj} documentDetailsObj={props.documentDetailsObj} - documentHistoryObj={props.documentHistoryObj} /> )} diff --git a/components/case/documents.js b/components/case/documents.js index f1473080..c799df67 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -14,8 +14,6 @@ import { getBasicSearch, getBasicSearchDetails, getSearchDocumentDetails, - getSearchDocumentHistory, - getSearchDocumentHistoryPaged, getSearchDocumentDetailsPaged, } from "../../actions"; @@ -23,7 +21,6 @@ import { setSearchResults, setSearchDetails, setDocumentDetails, - setDocumentHistory, getSearchResultsObj, } from "../../store/searchOutput/action"; @@ -36,9 +33,7 @@ const DocumentDetails = (props) => { searchResultsObj, searchDetailsObj, documentDetailsObj, - documentHistoryObj, setDocumentDetails, - setDocumentHistory, setCurrentPage, } = props; @@ -150,7 +145,7 @@ const DocumentDetails = (props) => { ) : ( - documentDetailsArr.map((item) => { + documentDetailsArr.map((item, key) => { let detailsObj = jsonpath.query( item, "$..[?(@._pinswg_documentids_value=='" + @@ -158,30 +153,15 @@ const DocumentDetails = (props) => { "')]" ); detailsObj = item; - - if (typeof detailsObj != "undefined") { - var documentHistoryArr = - documentHistoryObj || []; - return documentHistoryArr.map( - (historyItem, key) => { - let historyObj = jsonpath.query( - documentHistoryObj[key], - "$..value[?(@._pinswg_documentid_value=='" + - detailsObj.pinswg_documentid + - "')]" - ); - - historyObj = historyObj[0]; - return !_.isEmpty(historyObj) ? ( -
-
- {showDownloadingState === - key && ( -
- {/* +
+ {showDownloadingState === key && ( +
+ {/* { { : "Fetching data" } /> */} -
+
+ )} + + + { + toggleDownLoadLink(key); + }} + > + + {t( + "case:documents-name-label" )} + : + + {_.has( + detailsObj, + "pinswg_name" + ) + ? detailsObj.pinswg_name + : ""} + + + +
+ + {t("case:documents-doc-type-label")} + : + - - { - toggleDownLoadLink( - key - ); - }} - > - - {t( - "case:documents-name-label" - )} - : - - {_.has(historyObj, [ - "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", - ]) - ? historyObj[ - "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue" - ] - : ""} - - -
-
- - {t( - "case:documents-doc-type-label" - )} - : - + {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-date-entered-label" + )} +
+
+ + {t( + "case:documents-date-published-label" + )} + : + - {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
- - {t( - "case:documents-date-published-label" - )} - : - - - {_.has(historyObj, [ - "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue", - ]) - ? formatDates( - historyObj.pinswg_publisheddate - ) - : ""} -
- {/*
+ {_.has( + detailsObj, + "pinswg_latestpublisheddate" + ) + ? formatDates( + detailsObj.pinswg_latestpublisheddate + ) + : ""} +
+ {/*
{t("case:documents-size-label")}: 92
*/} - - ) : ( - "" - ); - } - ); - } + + ); }) )} @@ -300,50 +269,22 @@ const DocumentDetails = (props) => { } const docDetailsObj = async () => { - let docObj = await getSearchDocumentDetails(incidentid) - .then((data) => { + let docObj = await getSearchDocumentDetails(incidentid).then( + (data) => { //console.log(data); setDocumentDetails(data); - return data; - }) - .then((data) => { - let historyObj = getDocumentHistory(data.value).then( - (result) => { - setDocumentHistory(result); - setDocumentSearchState(true); - return result; - } - ); + setDocumentSearchState(true); return data; - }); + } + ); return docObj; }; - const getDocumentHistory = async (searchDocumentDetailsObj) => { - let historyArr = []; - searchDocumentDetailsObj = searchDocumentDetailsObj || []; - - const detailsObj = searchDocumentDetailsObj.map( - (historyDetail, index) => { - if (historyDetail.pinswg_publishtoweb != true) { - console.log(historyDetail.pinswg_documentid); - } else { - historyArr.push( - getSearchDocumentHistory( - historyDetail.pinswg_documentid - ) - ); - } - } - ); - return Promise.all(historyArr); - }; const searchDocumentResultsObj = docDetailsObj(); }, [ incidentid, - setDocumentHistory, setDocumentDetails, selectedOption, fieldSortState, @@ -362,10 +303,7 @@ const DocumentDetails = (props) => { .then((data) => { //console.log("getting details", data); setDocumentDetails(data); - return getDocumentHistory(data.value).then((data) => { - setDocumentHistory(data); - setShowSpinnerState(false); - }); + setShowSpinnerState(false); }); }; @@ -375,48 +313,15 @@ const DocumentDetails = (props) => { pageNumber, orderBy, fieldSort - ) - .then((data) => { - //console.log(data); - setDocumentDetails(data); - return data; - }) - .then((data) => { - let historyObj = getDocumentHistory( - data.value, - pageNumber - ).then((result) => { - setDocumentHistory(result); - return result; - }); - - return data; - }); + ).then((data) => { + //console.log(data); + setDocumentDetails(data); + return data; + }); return docObj; }; - const getDocumentHistory = async (searchDocumentDetailsObj, pageNumber) => { - let historyArr = []; - searchDocumentDetailsObj = searchDocumentDetailsObj || []; - - const detailsObj = searchDocumentDetailsObj.map( - (historyDetail, index) => { - if (historyDetail.pinswg_publishtoweb != true) { - console.log(historyDetail.pinswg_documentid); - } else { - historyArr.push( - getSearchDocumentHistoryPaged( - historyDetail.pinswg_documentid, - pageNumber - ) - ); - } - } - ); - return Promise.all(historyArr); - }; - function formatDates(dateObj) { var dateObj = new Date(dateObj); var dd = String(dateObj.getDate()).padStart(2, "0"); @@ -498,7 +403,7 @@ const DocumentDetails = (props) => {

{t("case:documents-heading-label")}

- {_.isEmpty(documentHistoryObj) ? ( + {_.isEmpty(documentDetailsObj) ? (

@@ -536,9 +441,6 @@ const mapDispatchToProps = (dispatch) => { setDocumentDetails: (detailsObj) => { dispatch(setDocumentDetails(detailsObj)); }, - setDocumentHistory: (historyObj) => { - dispatch(setDocumentHistory(historyObj)); - }, setCurrentPage: (currentPage) => { dispatch(setCurrentPage(currentPage)); }, diff --git a/pages/case/index.js b/pages/case/index.js index 1fa8e41c..ab348b69 100644 --- a/pages/case/index.js +++ b/pages/case/index.js @@ -43,9 +43,6 @@ const Home = (props) => { documentDetailsObj={ props.searchResultsObj.documentDetailsObj } - documentHistoryObj={ - props.searchResultsObj.documentHistoryObj - } myRepresentations={ props.myRepresentations.myRepresentations } diff --git a/pages/dns/[developmentName].js b/pages/dns/[developmentName].js index 22870c81..8522b2ce 100644 --- a/pages/dns/[developmentName].js +++ b/pages/dns/[developmentName].js @@ -53,9 +53,6 @@ const CaseHome = (props) => { documentDetailsObj={ props.searchResultsObj.documentDetailsObj } - documentHistoryObj={ - props.searchResultsObj.documentHistoryObj - } myRepresentations={ props.myRepresentations.myRepresentations } diff --git a/pages/myportal/case.js b/pages/myportal/case.js index b06ef117..9e92d811 100644 --- a/pages/myportal/case.js +++ b/pages/myportal/case.js @@ -44,9 +44,6 @@ const Home = (props) => { documentDetailsObj={ props.searchResultsObj.documentDetailsObj } - documentHistoryObj={ - props.searchResultsObj.documentHistoryObj - } myRepresentations={ props.myRepresentations.myRepresentations } diff --git a/store/searchOutput/reducer.js b/store/searchOutput/reducer.js index e1b69a6d..06217d2b 100644 --- a/store/searchOutput/reducer.js +++ b/store/searchOutput/reducer.js @@ -4,7 +4,6 @@ const searchResultsInitialState = { searchResultsObj: {}, searchDetailsObj: {}, documentDetailsObj: {}, - documentHistoryObj: {}, representationsObj: {}, }; @@ -25,11 +24,7 @@ export default function reducer(state = searchResultsInitialState, action) { ...state, documentDetailsObj: action.documentDetailsObj, }; - case searchResultsActionTypes.SETDOCUMENTHISTORY: - return { - ...state, - documentHistoryObj: action.documentHistoryObj, - }; + case searchResultsActionTypes.SETREPRESENTATIONS: return { ...state,