chore(refactor): commit current refactor branch updates and slice1 xml/form derivation extraction
This commit is contained in:
@@ -2,20 +2,28 @@ import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import xpath from "xpath";
|
||||
import {
|
||||
getPickListLabel,
|
||||
getRadioLabel,
|
||||
bytesToSize,
|
||||
getDocumentTypeFromFilename,
|
||||
getThumbnailIconByExtension,
|
||||
getThumbnailIconByExtension
|
||||
} from "../../components/utils";
|
||||
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
|
||||
|
||||
import {
|
||||
setCurrentSection,
|
||||
setFormComplete,
|
||||
setFormComplete
|
||||
} from "../../store/appealType/action";
|
||||
import {
|
||||
parseRowOuterHTML,
|
||||
parseXml,
|
||||
selectCurrentSectionRows,
|
||||
selectRowDataFieldName,
|
||||
selectRowDocumentTypeCode,
|
||||
selectRowFieldType,
|
||||
selectRowLabelDescriptions
|
||||
} from "../../lib/newappeal/formDerivation";
|
||||
|
||||
let BuildCheckRow = (props) => {
|
||||
let { t } = useTranslation();
|
||||
@@ -30,18 +38,12 @@ let BuildCheckRow = (props) => {
|
||||
onSubmit,
|
||||
updateCurrentSection,
|
||||
setCurrentSection,
|
||||
mandatoryFieldsData,
|
||||
mandatoryFieldsData
|
||||
} = props;
|
||||
|
||||
const parser = new DOMParser();
|
||||
var doc = parser.parseFromString(props.formXML, "text/xml");
|
||||
var doc = parseXml(props.formXML);
|
||||
|
||||
var rowXML = xpath.select(
|
||||
"/form/tabs/tab[" +
|
||||
whichSection +
|
||||
"]/columns//sections/section/rows/row",
|
||||
doc
|
||||
);
|
||||
var rowXML = selectCurrentSectionRows(doc, whichSection);
|
||||
|
||||
function formatDate(dateObj) {
|
||||
var m = new Date(dateObj);
|
||||
@@ -66,7 +68,7 @@ let BuildCheckRow = (props) => {
|
||||
let formObj = jsonpath({
|
||||
path: "$['" + appealtypes + "']",
|
||||
json: fieldLookup,
|
||||
eval: true,
|
||||
eval: true
|
||||
});
|
||||
|
||||
let labelTrans =
|
||||
@@ -74,7 +76,7 @@ let BuildCheckRow = (props) => {
|
||||
? jsonpath({
|
||||
path: '$..[?(@ && @.value=="' + label + '")].value_cy',
|
||||
json: formObj,
|
||||
eval: true,
|
||||
eval: true
|
||||
})
|
||||
: label;
|
||||
return labelTrans;
|
||||
@@ -91,29 +93,23 @@ let BuildCheckRow = (props) => {
|
||||
return (
|
||||
<>
|
||||
{Object.keys(rowXML).map((key, index) => {
|
||||
var doc = parser.parseFromString(
|
||||
rowXML[key].outerHTML,
|
||||
"text/xml"
|
||||
);
|
||||
var doc = parseRowOuterHTML(rowXML[key].outerHTML);
|
||||
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);
|
||||
var rows = selectRowLabelDescriptions(doc);
|
||||
var fieldtype = selectRowFieldType(doc);
|
||||
var datafieldname = selectRowDataFieldName(doc);
|
||||
const isRequiredField = jsonpath({
|
||||
path:
|
||||
"$..value[?(@ && @.LogicalName=='" +
|
||||
datafieldname[0].value +
|
||||
"')]",
|
||||
json: mandatoryFieldsData,
|
||||
eval: true,
|
||||
eval: true
|
||||
});
|
||||
|
||||
var documentTypeCode = xpath.select(
|
||||
"//@ishareDocumentCode",
|
||||
doc
|
||||
);
|
||||
var documentTypeCode = selectRowDocumentTypeCode(doc);
|
||||
|
||||
// if (datafieldname[0].value.indexOf("fileUpload") > 0) {
|
||||
// isRequiredField.push({
|
||||
@@ -155,7 +151,7 @@ let BuildCheckRow = (props) => {
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: props.props.form[
|
||||
"appealForm"
|
||||
].values[datafieldname[0].value],
|
||||
].values[datafieldname[0].value]
|
||||
}}
|
||||
/>
|
||||
) : fieldtype[0].value ==
|
||||
@@ -212,14 +208,14 @@ let BuildCheckRow = (props) => {
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems:
|
||||
"flex-start",
|
||||
"flex-start"
|
||||
}}
|
||||
className="govuk-!-margin-bottom-2"
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
minWidth: "50",
|
||||
width: "50",
|
||||
width: "50"
|
||||
}}
|
||||
src={getThumbnailIconByExtension(
|
||||
blob.name
|
||||
@@ -229,7 +225,7 @@ let BuildCheckRow = (props) => {
|
||||
/>
|
||||
<span
|
||||
style={{
|
||||
maxWidth: "85%",
|
||||
maxWidth: "85%"
|
||||
}}
|
||||
className="govuk-body govuk-!-font-size-14 govuk-!-margin-left-2"
|
||||
>
|
||||
@@ -266,7 +262,7 @@ let BuildCheckRow = (props) => {
|
||||
display:
|
||||
"flex",
|
||||
alignItems:
|
||||
"flex-start",
|
||||
"flex-start"
|
||||
}}
|
||||
className="govuk-!-margin-bottom-2"
|
||||
>
|
||||
@@ -274,7 +270,7 @@ let BuildCheckRow = (props) => {
|
||||
style={{
|
||||
minWidth:
|
||||
"50",
|
||||
width: "50",
|
||||
width: "50"
|
||||
}}
|
||||
src={getThumbnailIconByExtension(
|
||||
blob.name
|
||||
@@ -287,7 +283,7 @@ let BuildCheckRow = (props) => {
|
||||
<span
|
||||
style={{
|
||||
maxWidth:
|
||||
"85%",
|
||||
"85%"
|
||||
}}
|
||||
className="govuk-body govuk-!-font-size-14 govuk-!-margin-left-2"
|
||||
>
|
||||
@@ -326,7 +322,7 @@ let BuildCheckRow = (props) => {
|
||||
<div
|
||||
key={index}
|
||||
style={{
|
||||
display: "flex",
|
||||
display: "flex"
|
||||
}}
|
||||
>
|
||||
<div className="govuk-!-width-one-half">
|
||||
@@ -397,12 +393,12 @@ const mapDispatchToProps = (dispatch) => {
|
||||
updateCurrentSection: (whichSection) => {
|
||||
dispatch(setCurrentSection(whichSection));
|
||||
dispatch(setFormComplete("true"));
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
count: state.count,
|
||||
count: state.count
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(BuildCheckRow);
|
||||
|
||||
Reference in New Issue
Block a user