Merge from git

This commit is contained in:
2021-11-01 11:21:39 +00:00
parent adcff32d73
commit d94b3b3e5a
210 changed files with 69742 additions and 3359 deletions
+73 -37
View File
@@ -2,8 +2,11 @@ import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
import jsonpath from "jsonpath";
import BuildCheckField from "./buildCheckfield";
import { useSelector, shallowEqual, connect } from "react-redux";
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
import {
setCaseReference,
setCurrentSection,
@@ -22,6 +25,7 @@ let BuildCheckRow = (props) => {
sectionCount,
onSubmit,
updateCurrentSection,
mandatoryFieldsData,
} = props;
const parser = new DOMParser();
@@ -49,6 +53,23 @@ let BuildCheckRow = (props) => {
return dateString;
}
const FieldsTranslations = (label) => {
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
let formObj = jsonpath.query(fieldLookup, "$['" + appealtypes + "']");
let labelTrans =
router.locale == "cy"
? jsonpath.query(
formObj,
"$..[?(@.value=='" + label + "')].value_cy"
)
: label;
return labelTrans;
};
return (
<>
{Object.keys(rowXML).map((key, index) => {
@@ -56,44 +77,59 @@ let BuildCheckRow = (props) => {
rowXML[key].outerHTML,
"text/xml"
);
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
if (_.isEmpty(rowXML[key].innerHTML)) {
("");
} else {
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
const isRequiredField = jsonpath.query(
mandatoryFieldsData,
"$..value[?(@.LogicalName=='" +
datafieldname[0].value +
"')]"
);
return (
<div className="govuk-summary-list__row" key={key}>
<dt className="govuk-summary-list__key">
{rows[0].value}
</dt>
<dd className="govuk-summary-list__value">
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.form["appealForm"].values[
datafieldname[0].value
]
)
: props.props.form["appealForm"].values[
datafieldname[0].value
]}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
updateCurrentSection(whichSection);
}}
>
Change
<span className="govuk-visually-hidden">
{" "}
name
</span>
</a>
</dd>
</div>
);
if (isRequiredField[0].RequiredLevel.Value != "None") {
return (
<div className="govuk-summary-list__row" key={key}>
<dt className="govuk-summary-list__key">
{FieldsTranslations(rows[0].value)}
</dt>
<dd className="govuk-summary-list__value">
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.form["appealForm"]
.values[
datafieldname[0].value
]
)
: props.props.form["appealForm"].values[
datafieldname[0].value
]}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
updateCurrentSection(whichSection);
}}
>
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{FieldsTranslations(rows[0].value)}
</span>
</a>
</dd>
</div>
);
} else {
return null;
}
}
})}
</>
);
+12 -15
View File
@@ -28,6 +28,7 @@ let BuildCheckSection = (props) => {
handleSubmit,
formTitle,
setCurrentSection,
mandatoryFieldsData,
} = props;
const parser = new DOMParser();
@@ -56,32 +57,29 @@ let BuildCheckSection = (props) => {
return (
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<div className="govuk-grid-column-full">
<div>
<h1 className="govuk-heading-m">
Are these answers correct?
</h1>
{Object.keys(titles).map((key) => (
<>
<h2 className="govuk-heading-m">
<dl className="govuk-summary-list ">
{Object.keys(titles).map((key) => (
<>
{/* <h2 className="govuk-heading-m">
{titles[key].value}
</h2>
</h2> */}
<dl
className="govuk-summary-list govuk-!-margin-bottom-9"
key={key}
>
<BuildCheckRow
formXML={formXML}
whichSection={parseInt(key) + 1}
sectionCount={key}
props={props}
key={key}
mandatoryFieldsData={mandatoryFieldsData}
/>
</dl>
</>
))}
</>
))}
</dl>
<dl className="govuk-summary-list govuk-!-margin-bottom-9 at-summary-list"></dl>
</div>
<div className="govuk-button-group">
@@ -90,11 +88,10 @@ let BuildCheckSection = (props) => {
data-module="govuk-button"
onClick={() => setCurrentSection(9999)}
>
Submit appeal
{t("newappeal:submit-appeal-button")}
</a>
</div>
</div>
<div className="govuk-grid-column-one-third"></div>
</div>
);
};
+22 -4
View File
@@ -2,6 +2,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
import {
Textfield,
DateField,
@@ -20,7 +21,7 @@ export default function BuildField(props) {
const router = useRouter();
const { locale } = router;
const { fieldType, label, datafieldname } = props;
const { fieldType, label, datafieldname, mandatoryFieldData } = props;
const parser = new DOMParser();
@@ -31,7 +32,15 @@ export default function BuildField(props) {
<ReadOnlyfield
name={props.datafieldname}
label={props.label}
value={props.props.props.appealType.caseReference}
value={
props.props.props.appealType.caseReference
.ticketnumber
}
props={props}
ticketnumber={
props.props.props.appealType.caseReference
.ticketnumber
}
/>
);
break;
@@ -41,6 +50,7 @@ export default function BuildField(props) {
name={props.datafieldname}
label={props.label}
datafieldname={props.datafieldname}
picklistData={props.picklistData}
/>
);
break;
@@ -52,9 +62,17 @@ export default function BuildField(props) {
/>
);
break;
case "{ 4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
return (
<Textfield name={props.datafieldname} label={props.label} />
<Textfield
name={props.datafieldname}
label={props.label}
props={props}
ticketnumber={
props.props.props.appealType.caseReference
.ticketnumber
}
/>
);
break;
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
+41 -13
View File
@@ -1,8 +1,10 @@
import Link from "next/link";
import _ from "lodash";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
import BuildField from "./buildfield";
import jsonpath from "jsonpath";
export default function BuildRow(props) {
let { t } = useTranslation();
@@ -10,7 +12,13 @@ export default function BuildRow(props) {
const router = useRouter();
const { locale } = router;
const { rowXML, whichSection, sectionCount, onSubmit } = props;
const {
rowXML,
whichSection,
sectionCount,
onSubmit,
mandatoryFieldsData,
} = props;
const parser = new DOMParser();
@@ -21,18 +29,38 @@ export default function BuildRow(props) {
rowXML[key].outerHTML,
"text/xml"
);
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
return (
<BuildField
fieldType={fieldtype[0].value}
label={rows[0].value}
datafieldname={datafieldname[0].value}
key={key}
props={props}
/>
);
if (_.isEmpty(rowXML[key].innerHTML)) {
("");
} else {
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
const isRequiredField = jsonpath.query(
mandatoryFieldsData,
"$..value[?(@.LogicalName=='" +
datafieldname[0].value +
"')]"
);
if (isRequiredField[0].RequiredLevel.Value != "None") {
return (
<BuildField
fieldType={fieldtype[0].value}
label={rows[0].value}
datafieldname={datafieldname[0].value}
key={key}
props={props}
picklistData={
props.props.props.formData.pickListData
}
mandatoryFieldsData={mandatoryFieldsData}
/>
);
} else {
return null;
}
}
})}
</div>
);
+25 -22
View File
@@ -32,19 +32,21 @@ let BuildSection = (props) => {
setCurrentSection,
refno,
gotoSection,
mandatoryFieldsData,
} = props;
const currentSection = props.appealType.currentSection;
const parser = new DOMParser();
var doc = parser.parseFromString(props.formXML, "text/xml");
var titles = xpath.select(
"//form/tabs/tab[" + currentSection + " ]/labels/label/@description",
doc
);
// var titles = xpath.select(
// "//form/tabs/tab[" + currentSection + " ]/labels/label/@description",
// doc
// );
var rowXML = xpath.select(
"/form/tabs/tab[" +
currentSection +
"]/columns//sections/section/rows/row",
// "/form/tabs/tab[" +
// currentSection +
// "]/columns//sections/section/rows/row",
"/form/tabs/tab/columns//sections/section/rows/row",
doc
);
@@ -129,7 +131,8 @@ let BuildSection = (props) => {
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h1 className="govuk-heading-m govuk-!-margin-top-5">
{titles[0].value}{" "}
{/* {titles[0].value}{" "} */}
Enter your appeal information
</h1>
<form onSubmit={handleSubmit(onHandleSubmit)}>
{hasErrors == true ? (
@@ -141,17 +144,17 @@ let BuildSection = (props) => {
) : (
""
)}
<BuildRow
rowXML={rowXML}
whichSection={props.whichSection}
sectionCount={props.sectionCount}
onSubmit={onSubmit}
mandatoryFieldsData={mandatoryFieldsData}
props={props}
/>
{}
<div className="govuk-button-group">
{props.sectionCount != currentSection ? (
{/* {props.sectionCount != currentSection ? (
<button
type="submit"
className="govuk-button"
@@ -163,15 +166,15 @@ let BuildSection = (props) => {
) : (
""
)}
{props.sectionCount == currentSection ? (
<button
type="submit"
className="govuk-button"
data-module="govuk-button"
>
Submit
</button>
) : (
{props.sectionCount == currentSection ? ( */}
<button
type="submit"
className="govuk-button"
data-module="govuk-button"
>
Submit
</button>
{/* ) : (
""
)}
{currentSection > 1 ? (
@@ -186,11 +189,11 @@ let BuildSection = (props) => {
</a>
) : (
""
)}
)} */}
</div>
</form>
</div>
<div className="govuk-grid-column-one-third">
{/* <div className="govuk-grid-column-one-third">
<nav
role="navigation"
aria-labelledby="progress-list"
@@ -239,7 +242,7 @@ let BuildSection = (props) => {
</ul>
</ol>
</nav>
</div>
</div> */}
</div>
);
};
+85 -4
View File
@@ -7,11 +7,87 @@ import BuildRow from "./buildrow";
import { reduxForm, formValueSelector } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setCurrentSection } from "../../store/appealType/action";
import { updateCase } from "../../actions";
import jsonpath from "jsonpath";
import data from "../../data/collections.json";
let CompleteAppeal = (props) => {
// useEffect(() => {
// window.scrollTo(0, 0);
// });
// un comment to update incident with an appealtype id
useEffect(() => {
let incidentId = props.appealType.caseReference.incidentid;
let updateBody = props.props.form.appealForm.values;
let updateBindAppealTypeToIncident =
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
].replace(/(\band|[\s\-\+\(\)\,\&])/g, "") +
"Ids";
Object.assign(updateBody, {
"pinswg_Appellant@odata.bind":
"/contacts(" + props.props.accountDetails.loggedinUserId + ")",
"pinswg_AssociatedLPA@odata.bind":
"/accounts(" + props.appealType.appealLPA + ")",
"pinswg_name": props.appealType.caseReference.ticketnumber,
[updateBindAppealTypeToIncident + "@odata.bind"]:
"/incidents(" + incidentId + ")",
});
updateBody = JSON.stringify(updateBody);
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
updateBody = updateBody.replace(/:"No"/gm, `:false`);
updateBody = JSON.parse(updateBody);
let updateFormCollection = getFormCollection(
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
);
let primaryAttribute = getPrimaryAttr(
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
);
updateCase(
incidentId,
updateBody,
updateFormCollection,
primaryAttribute,
props.appealType.caseReference.ticketnumber
);
}, [
props.appealType.caseReference,
props.props.form.appealForm.values,
props.appealType.appealLPA,
props.props.accountDetails.loggedinUserId,
]);
const getFormCollection = (formtype) => {
const collectionName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
);
//console.log(collectionName[0]);
return collectionName[0];
};
const getPrimaryAttr = (formtype) => {
const attrName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].PrimaryIdAttribute"
);
return attrName[0];
};
let { t } = useTranslation();
@@ -52,6 +128,9 @@ let CompleteAppeal = (props) => {
setCurrentSection(currentSection + 1);
};
// console.log(JSON.stringify(props.props.form.appealForm.values, null, 2));
//alert(JSON.stringify(props.props.form.appealForm.values, null, 2));
return (
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
@@ -60,7 +139,9 @@ let CompleteAppeal = (props) => {
<div className="govuk-panel__body">
Your reference number
<br />
<strong>{props.appealType.caseReference}</strong>
<strong>
{props.appealType.caseReference.ticketnumber}
</strong>
</div>
</div>
+83 -46
View File
@@ -7,6 +7,9 @@ import BuildRow from "./buildrow";
import { reduxForm, formValueSelector, Field } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import jsonpath from "jsonpath";
import transLookup from "../../data/lookuptranslations.json";
import data from "../../data/collections.json";
import {
setAppealType,
setAppealTypeTitle,
@@ -33,11 +36,9 @@ let CreateCase = (props) => {
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions)
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions.GlobalOptionSet)
: _.isEmpty(props.appealType.appealTypeOptions.value)
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions.GlobalOptionSet.Options)
? [{}]
: props.appealType.appealTypeOptions.GlobalOptionSet.Options;
: props.appealType.appealTypeOptions.value;
let lpaOptionsObj = _.isEmpty(props)
? [{}]
@@ -45,7 +46,9 @@ let CreateCase = (props) => {
? [{}]
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: jsonpath.query(props.LPAData.LPAData, "$..name");
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: props.LPAData.LPAData.value;
const RenderLPAList = ({
name,
@@ -88,7 +91,7 @@ let CreateCase = (props) => {
//onChange={(e) => props.onChangeSelectLPA(e)}
>
<option value="" disabled defaultValue>
Select...
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
@@ -96,9 +99,17 @@ let CreateCase = (props) => {
return (
<option
key={key}
value={optionsObj[key]}
value={optionsObj[key].accountid}
>
{optionsObj[key]}
{router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
optionsObj[key]
.name +
'")].value_cy'
)
: optionsObj[key].name}
</option>
);
})}
@@ -149,7 +160,7 @@ let CreateCase = (props) => {
//onChange={(e) => props.onChangeSelectAppealType(e)}
>
<option value="" disabled defaultValue>
Select...
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
@@ -158,51 +169,45 @@ let CreateCase = (props) => {
<option
key={key}
value={
_.isEmpty(
optionsObj[key].Label
)
_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key]
.Label
.LocalizedLabels
)
? ""
: _.isEmpty(
optionsObj[key]
.Label
.LocalizedLabels[0]
.Label
.value
)
? ""
: optionsObj[
key
].Label.LocalizedLabels[0].Label.replace(
/[\s\-\+\(\)\,]/g,
""
).toLowerCase()
: optionsObj[key]
.attributevalue +
"," +
optionsObj[key].value
.replace(
/(\band|[\s\-\+\(\)\,\&])/g,
""
)
.toLowerCase()
}
>
{_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key].Label
)
: _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key].Label
.LocalizedLabels
optionsObj[key].value
)
? ""
: _.isEmpty(
optionsObj[key].Label
.LocalizedLabels[0]
.Label
: router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
optionsObj[key]
.value +
'")].value_cy'
)
? ""
: optionsObj[key].Label
.LocalizedLabels[0]
.Label}
: optionsObj[key].value}
</option>
);
})}
@@ -215,11 +220,43 @@ let CreateCase = (props) => {
const required = (value) => (value ? undefined : "Required");
const getFormCollection = (formtype) => {
formtype =
"pinswg_" +
(formtype.length > 39 ? formtype.slice(0, 39) : formtype);
const collectionName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].UrlName"
);
//console.log(collectionName[0]);
return collectionName[0];
};
const onHandleSubmit = (values) => {
event.preventDefault();
router.replace("/newappeal/" + values.appealTypes, null, {
shallow: true,
});
var appTypeCollection = values.appealTypes.split(",")[1];
appTypeCollection = getFormCollection(
appTypeCollection.length > 39
? appTypeCollection.slice(0, 39)
: appTypeCollection
);
router.replace(
(router.locale = "cy" ? "/apelnewydd" : "/newappeal") +
"/" +
appTypeCollection +
"?lpa=" +
values.lpaTypes +
"&apt=" +
values.appealTypes.split(",")[0],
null,
{
shallow: true,
}
);
};
return (
@@ -229,8 +266,8 @@ let CreateCase = (props) => {
component={RenderLPAList}
optionsObj={lpaOptionsObj}
validate={[required]}
label="Select your local planning authority"
errorMsg="Local authority is required"
label={t("newappeal:select-lpa-label")}
errorMsg={t("newappeal:select-lpa-label-error-msg")}
/>
<Field
@@ -238,8 +275,8 @@ let CreateCase = (props) => {
component={RenderAppealTypeList}
optionsObj={appealOptionsObj}
validate={[required]}
label="Select an appeal type"
errorMsg="Appeal type is required"
label={t("newappeal:select-appeal-type-label")}
errorMsg={t("newappeal:select-appeal-type-label-error-msg")}
/>
<button
@@ -247,7 +284,7 @@ let CreateCase = (props) => {
className="govuk-button"
data-module="govuk-button"
>
Continue
{t("common:continue-button")}
</button>
</form>
);
@@ -273,8 +310,8 @@ const mapDispatchToProps = (dispatch) => {
);
dispatch(setAppealTypeID(event.target.value));
},
onChangeSelectLPA: (event) => {
dispatch(setAppealLPA(event.target.value));
onChangeSelectLPA: (lpaId) => {
dispatch(setAppealLPA(lpaId));
},
};
};