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
+97 -95
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";
@@ -132,12 +132,12 @@ const RenderCaseStatusList = ({
: _.isEmpty(optionsObj[key].value)
? ""
: router.locale == "cy"
? jsonpath.query(
optionsObj,
? jsonpath(
'$..[?(@.statuscode=="' +
optionsObj[key]
.statuscode +
'")].value_cy'
'")].value_cy',
optionsObj
)
: optionsObj[key].value ||
t(
@@ -245,12 +245,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(
@@ -275,96 +275,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);
+13 -13
View File
@@ -2,7 +2,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { connect } from "react-redux";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import _ from "lodash";
import transLookup from "../../data/lookuptranslations.json";
import PaginationControl from "./pagination";
@@ -174,9 +174,9 @@ const DNSSearchResults = (props) => {
};
const isWatchedCase = (whichIncident) => {
let isWatched = jsonpath.query(
watchedCases,
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]"
let isWatched = jsonpath(
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]",
watchedCases
);
return isWatched;
@@ -330,11 +330,11 @@ const DNSSearchResults = (props) => {
</div>
) : (
resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
searchDetailsObj,
let detailsObj = jsonpath(
'$..value[?(@.pinswg_name=="' +
item.title +
'")]'
'")]',
searchDetailsObj
);
detailsObj = detailsObj[0];
@@ -487,13 +487,13 @@ const DNSSearchResults = (props) => {
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
detailsObj[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: detailsObj[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -509,13 +509,13 @@ const DNSSearchResults = (props) => {
</span>
{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"
+16 -16
View File
@@ -7,7 +7,7 @@ import {
setCurrentPage,
} from "../../store/currentView/action";
import { connect } from "react-redux";
import jsonpath from "jsonpath";
import { JSONPath as jsonpath } from "jsonpath-plus";
import _ from "lodash";
import transLookup from "../../data/lookuptranslations.json";
import {
@@ -108,9 +108,9 @@ const SearchResults = (props) => {
};
const isWatchedCase = (whichIncident) => {
let isWatched = jsonpath.query(
watchedCases,
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]"
let isWatched = jsonpath(
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]",
watchedCases
);
return isWatched;
@@ -275,11 +275,11 @@ const SearchResults = (props) => {
</div>
) : (
resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
searchDetailsObj,
let detailsObj = jsonpath(
'$..value[?(@.pinswg_name=="' +
item.title +
'")]'
'")]',
searchDetailsObj
);
detailsObj = detailsObj[0];
return (
@@ -437,13 +437,13 @@ const SearchResults = (props) => {
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
? jsonpath(
'$..[?(@.value=="' +
item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
'")].value_cy',
transLookup
)
: item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -458,13 +458,13 @@ const SearchResults = (props) => {
:
</span>
{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"
@@ -479,13 +479,13 @@ const SearchResults = (props) => {
</span>
{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"