update jsonpath library

This commit is contained in:
2024-02-08 14:28:40 +00:00
parent f034f4be3d
commit 2af463fbe9
67 changed files with 961 additions and 966 deletions
+94 -92
View File
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { reduxForm, formValueSelector, Field } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import data from "../../data/collections.json";
import transLookup from "../../data/lookuptranslations.json";
@@ -149,12 +149,12 @@ let AdvancedSearch = (props) => {
{/* {optionsObj[key].name} */}
{router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
optionsObj[key]
.name +
'")].value_cy'
'")].value_cy',
transLookup
)
: optionsObj[key].name ||
t(
@@ -179,96 +179,98 @@ let AdvancedSearch = (props) => {
label,
errormsg,
}) => {
return <>
<div
className={
touched && error
? "govuk-form-group govuk-form-group--error"
: "govuk-form-group "
}
>
<label className="govuk-label" htmlFor={id}>
{label}
{name}
</label>
{touched && error && (
<span
id="passport-issued-error"
className="govuk-error-message"
>
<span className="govuk-visually-hidden">
Error:
</span>{" "}
{errormsg}
</span>
)}
<div>
<select
{...input}
className="govuk-select"
id={id}
name={name}
//onChange={(e) => props.onChangeSelectAppealType(e)}
>
<option value="" disabled defaultValue>
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
: Object.keys(optionsObj).map((key, index) => {
return (
<option
key={key}
value={
_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key]
)
? ""
: _.isEmpty(
optionsObj[key]
.value
)
? ""
: optionsObj[key]
.attributevalue +
"," +
optionsObj[key].value
.replace(
/(\band|[\s\-\+\(\)\,\&])/g,
""
return (
<>
<div
className={
touched && error
? "govuk-form-group govuk-form-group--error"
: "govuk-form-group "
}
>
<label className="govuk-label" htmlFor={id}>
{label}
{name}
</label>
{touched && error && (
<span
id="passport-issued-error"
className="govuk-error-message"
>
<span className="govuk-visually-hidden">
Error:
</span>{" "}
{errormsg}
</span>
)}
<div>
<select
{...input}
className="govuk-select"
id={id}
name={name}
//onChange={(e) => props.onChangeSelectAppealType(e)}
>
<option value="" disabled defaultValue>
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
: Object.keys(optionsObj).map((key, index) => {
return (
<option
key={key}
value={
_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key]
)
.toLowerCase()
}
>
{_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key].value
)
? ""
: router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
optionsObj[key]
.value +
'")].value_cy'
)
: optionsObj[key].value ||
t(
"case:summary-no-date-entered-label"
)}
</option>
);
})}
</select>
? ""
: _.isEmpty(
optionsObj[key]
.value
)
? ""
: optionsObj[key]
.attributevalue +
"," +
optionsObj[key].value
.replace(
/(\band|[\s\-\+\(\)\,\&])/g,
""
)
.toLowerCase()
}
>
{_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key].value
)
? ""
: router.locale == "cy"
? jsonpath(
'$..[?(@.value=="' +
optionsObj[key]
.value +
'")].value_cy',
transLookup
)
: optionsObj[key].value ||
t(
"case:summary-no-date-entered-label"
)}
</option>
);
})}
</select>
</div>
</div>
</div>
</>;
</>
);
};
// const [showSpinnerState, setShowSpinnerState] = useState(false);
@@ -7,7 +7,7 @@ import {
setCurrentView,
setCurrentReference,
} from "../../store/currentView/action";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import transLookup from "../../data/lookuptranslations.json";
import {
deleteAwaitingSubmissionsFromBlob,
@@ -168,11 +168,11 @@ const AwaitingSubmissionFromBlob = (props) => {
</div>
)}
{router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
showTopThreeArrDets[key]["pinswg_lpaname"] +
'")].value_cy'
'")].value_cy',
transLookup
)
: showTopThreeArrDets[key]["pinswg_lpaname"] || ""}
</div>
+4 -4
View File
@@ -12,7 +12,7 @@ import {
deleteAwaitingSubmissions,
getAwaitingSubmissionProxy,
} from "../../actions";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import transLookup from "../../data/lookuptranslations.json";
import {
setWatchedCases,
@@ -283,13 +283,13 @@ const TopThree = (props) => {
)}
{router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
showTopThreeArr[key][
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: showTopThreeArr[key][
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
+4 -4
View File
@@ -20,7 +20,7 @@ import {
setWatchedCasesDetails,
} from "../../store/watchedCases/action";
import { getFormCollectionByID } from "../utils";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import transLookup from "../../data/lookuptranslations.json";
const TopThree = (props) => {
@@ -204,13 +204,13 @@ const TopThree = (props) => {
{" "}
{router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
showTopThreeArr[key][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: showTopThreeArr[key][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
+40 -40
View File
@@ -3,7 +3,7 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { setCurrentReference } from "../../store/currentView/action";
import { connect } from "react-redux";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import transLookup from "../../data/lookuptranslations.json";
import { getFormCollectionByID } from "../../components/utils";
@@ -47,9 +47,9 @@ const ViewAllResults = (props) => {
let resultsRowArr = [];
resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
searchDetailsObj,
'$..value[?(@.pinswg_name=="' + item.pinswg_title + '")]'
let detailsObj = jsonpath(
'$..value[?(@.pinswg_name=="' + item.pinswg_title + '")]',
searchDetailsObj
);
detailsObj = detailsObj[0];
@@ -297,11 +297,11 @@ const ViewAllResults = (props) => {
{currentView.viewKey == "awaitingSubmissionDetails" &&
_.has(resultsArr[key], "pinswg_lpaname")
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
resultsArr[key].pinswg_lpaname +
'")].value_cy'
'")].value_cy',
transLookup
)
: resultsArr[key].pinswg_lpaname || "N/A"
: ""}
@@ -309,13 +309,13 @@ const ViewAllResults = (props) => {
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
resultsArr[key][
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: resultsArr[key][
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -325,13 +325,13 @@ const ViewAllResults = (props) => {
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
searchDetailsObj[key].value[0][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValuee"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: currentView.viewKey == "myRepresentations"
? searchDetailsObj[key].value
@@ -343,13 +343,13 @@ const ViewAllResults = (props) => {
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
resultsArr[key][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValuee"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: resultsArr[key][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
@@ -359,13 +359,13 @@ const ViewAllResults = (props) => {
: "N/A")
: currentView.viewKey == "myRepresentations" &&
router.locale == "cy" &&
jsonpath.query(
transLookup,
jsonpath(
'$..[?(@.value=="' +
searchDetailsObj[key][
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
@@ -375,24 +375,24 @@ const ViewAllResults = (props) => {
{currentView.viewKey == "awaitingSubmissionDetails"
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
getFormCollectionByID(
item.pinswg_appealcasetype
).value +
'")].value_cy'
'")].value_cy',
transLookup
)
: getFormCollectionByID(item.pinswg_appealcasetype)
.value || "N/A"
: router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
@@ -403,13 +403,13 @@ const ViewAllResults = (props) => {
{currentView.viewKey == "myRepresentations" &&
(router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
getFormCollectionByID(
searchDetailsObj[key].appealType
).value +
'")].value_cy'
'")].value_cy',
transLookup
)[0]
: getFormCollectionByID(
searchDetailsObj[key].appealType
@@ -429,39 +429,39 @@ const ViewAllResults = (props) => {
{currentView.viewKey == "awaitingSubmissionDetails"
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.statuscode=="' +
item.statuscode +
'")].value_cy'
'")].value_cy',
transLookup
)
: jsonpath.query(
transLookup,
: jsonpath(
'$..[?(@.statuscode=="' +
item.statuscode +
'")].value'
'")].value',
transLookup
) || "N/A"
: currentView.viewKey == "myRepresentations"
? repRaisedDate(item.createdDate) // ? router.locale == "cy"
: // ? jsonpath.query(
// transLookup,
: // ? jsonpath(
//
// '$..[?(@.value=="' +
// searchDetailsObj[key].value[0][
// "statuscode@OData.Community.Display.V1.FormattedValue"
// ] +
// '")].value_cy'
// '")].value_cy',transLookup,
// )
// : searchDetailsObj[key].value[0][
// "statuscode@OData.Community.Display.V1.FormattedValue"
// ] || "N/A"
// : router.locale == "cy"
// ? jsonpath.query(
// transLookup,
// ? jsonpath(
//
// '$..[?(@.value=="' +
// item[
// "statuscode@OData.Community.Display.V1.FormattedValue"
// ] +
// '")].value_cy'
// '")].value_cy',transLookup,
// )
item[
"statuscode@OData.Community.Display.V1.FormattedValue"