Merged PR 1107: added tenant fieldarray and date ranges
added tenant fieldarray and date ranges Related work items: #10574
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Field, reduxForm } from "redux-form";
|
||||
import { Field, reduxForm, FieldArray } from "redux-form";
|
||||
import { useRouter } from "next/router";
|
||||
import DatePicker, { registerLocale, setDefaultLocale } from "react-datepicker";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -1736,3 +1736,94 @@ const RenderFileUpload = (field) => {
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const renderField = ({ input, label, type, meta: { touched, error } }) => (
|
||||
<div>
|
||||
<label>{label}</label>
|
||||
<div>
|
||||
<input {...input} type={type} placeholder={label} />
|
||||
{touched && error && <span>{error}</span>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderSubFields = ({ fields }) => (
|
||||
<ul>
|
||||
<div>
|
||||
{fields.map((member, index) => (
|
||||
<div key={index}>
|
||||
<h4>Tenant #{index + 1}</h4>
|
||||
<div className="fieldArrayContainer">
|
||||
<Field
|
||||
id={`${member}.${fields.name}`}
|
||||
name={`${member}.${fields.name}`}
|
||||
type="text"
|
||||
component={RenderTextfield}
|
||||
label="Tenant Name"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
/>
|
||||
<Field
|
||||
name={`${member}.dateserved`}
|
||||
type="text"
|
||||
component={RenderDatePicker}
|
||||
label="Date served notice"
|
||||
dateStart={"-6m"}
|
||||
dateEnd={"0"}
|
||||
className="govuk-input govuk-input--width-10"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
title="Remove tenant"
|
||||
onClick={() => fields.remove(index)}
|
||||
className="govuk-button fieldArrayDelete"
|
||||
>
|
||||
X
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="govuk-link fieldArrayLink"
|
||||
onClick={() => fields.push({})}
|
||||
>
|
||||
Add Tenant
|
||||
</button>
|
||||
</ul>
|
||||
);
|
||||
|
||||
export const FieldArrayForm = (props) => {
|
||||
const {
|
||||
name,
|
||||
label,
|
||||
validation,
|
||||
form,
|
||||
formProps,
|
||||
parentFieldShowOnValue,
|
||||
parentField,
|
||||
maxFieldLength,
|
||||
} = props;
|
||||
|
||||
var showIfHasParentShowValue =
|
||||
parentField != false &&
|
||||
!_.isEmpty(formProps[form]) &&
|
||||
_.has(formProps[form].values, parentField) &&
|
||||
parentFieldShowOnValue.indexOf(
|
||||
formProps[form].values[parentField].toString()
|
||||
) > -1;
|
||||
|
||||
(showIfHasParentShowValue == parentField) != false &&
|
||||
showIfHasParentShowValue;
|
||||
|
||||
parentFieldShowOnValue;
|
||||
const { handleSubmit, pristine, reset, submitting } = props;
|
||||
return (
|
||||
<>
|
||||
{" "}
|
||||
{showIfHasParentShowValue && (
|
||||
<FieldArray name={name} component={renderSubFields} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -42,6 +42,9 @@ export default function BuildField(props) {
|
||||
case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
||||
return <>{fieldValue}</>;
|
||||
break;
|
||||
case "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
||||
return <>{}</>;
|
||||
break;
|
||||
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getFormCollectionByID,
|
||||
getPickListLabel,
|
||||
getRadioLabel,
|
||||
getFieldArrayLabel,
|
||||
} from "../../components/utils";
|
||||
|
||||
import {
|
||||
@@ -169,6 +170,35 @@ let BuildCheckRow = (props) => {
|
||||
: fieldtype[0].value ==
|
||||
"{16D63FD6-119B-4353-BDCA-18358721C3FE}"
|
||||
? "ssss"
|
||||
: fieldtype[0].value ==
|
||||
"{0273EDBD-AC1D-40d3-9FB2-095C621B552D}"
|
||||
? props.props.form[
|
||||
"appealForm"
|
||||
].values[
|
||||
datafieldname[0].value
|
||||
].map((tenant, index) => {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
style={{
|
||||
display:
|
||||
"flex",
|
||||
}}
|
||||
>
|
||||
<div className="govuk-!-width-one-half">
|
||||
{
|
||||
tenant.pinswg_agriculturaltenantname
|
||||
}
|
||||
</div>
|
||||
<div className="govuk-!-width-one-half">
|
||||
Served:{" "}
|
||||
{formatDate(
|
||||
tenant.dateserved
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
: props.props.form["appealForm"]
|
||||
.values[
|
||||
datafieldname[0].value
|
||||
|
||||
@@ -72,7 +72,7 @@ let BuildCheckSection = (props) => {
|
||||
};
|
||||
|
||||
let buildAppealFilesArray = [];
|
||||
console.log("attached docs: - ", buildAppealFilesArray);
|
||||
//console.log("attached docs: - ", buildAppealFilesArray);
|
||||
|
||||
let filesUplaodObj = Object.keys(props.props.form.appealForm.values)
|
||||
.filter(function (k) {
|
||||
@@ -83,8 +83,6 @@ let BuildCheckSection = (props) => {
|
||||
return newData;
|
||||
}, {});
|
||||
|
||||
console.log(filesUplaodObj);
|
||||
|
||||
for (let key in filesUplaodObj) {
|
||||
for (let j in filesUplaodObj[key]) {
|
||||
typeof filesUplaodObj[key][j].name != "undefined" &&
|
||||
@@ -95,8 +93,6 @@ let BuildCheckSection = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(buildAppealFilesArray);
|
||||
|
||||
let pdfObj = props.props.form.appealForm.values;
|
||||
|
||||
Object.assign(pdfObj, {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
RichMultiLinefield,
|
||||
Textfield,
|
||||
YesNofield,
|
||||
FieldArrayForm,
|
||||
} from "../elements";
|
||||
|
||||
export default function BuildField(props) {
|
||||
@@ -217,6 +218,17 @@ export default function BuildField(props) {
|
||||
);
|
||||
break;
|
||||
|
||||
case "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
||||
return (
|
||||
<FieldArrayForm
|
||||
name={props.datafieldname}
|
||||
label={props.label}
|
||||
form={props.props.props.form}
|
||||
formProps={props.props.props.props.form}
|
||||
parentField={props.parentField}
|
||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
||||
/>
|
||||
);
|
||||
case "{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}":
|
||||
return (
|
||||
<CheckBoxfield
|
||||
|
||||
@@ -93,7 +93,19 @@ export const AppealRow_pdf = (props) => {
|
||||
backgroundColor: "white",
|
||||
padding: 5,
|
||||
},
|
||||
|
||||
questionAnswerRow: {
|
||||
width: "100%",
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
flexGrow: 1,
|
||||
},
|
||||
questionAnswerColLeft: {
|
||||
width: "40%",
|
||||
},
|
||||
questionAnswerColRight: {
|
||||
padding: 5,
|
||||
width: "40%",
|
||||
},
|
||||
sectionContainer: {
|
||||
backgroundColor: "#F8F8F8",
|
||||
padding: 10,
|
||||
@@ -248,6 +260,8 @@ export const AppealRow_pdf = (props) => {
|
||||
break;
|
||||
case "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
|
||||
var fieldCopy = datafieldcontent[0].value
|
||||
.replace("]", "")
|
||||
.replace("[", "")
|
||||
.split(",")
|
||||
.find((a) =>
|
||||
a.includes(
|
||||
@@ -416,6 +430,81 @@ export const AppealRow_pdf = (props) => {
|
||||
</View>
|
||||
);
|
||||
break;
|
||||
case "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
<View
|
||||
wrap={false}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
styles.questionTextMid
|
||||
}
|
||||
>
|
||||
{rows[0].value}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
style={
|
||||
styles.questionAnswerWide
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
{props.props[
|
||||
datafieldname[0].value
|
||||
].map((tenant) => {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flexDirection:
|
||||
"row",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
width: "50%",
|
||||
paddingRight:
|
||||
"20",
|
||||
}}
|
||||
>
|
||||
{
|
||||
tenant.pinswg_agriculturaltenantname
|
||||
}
|
||||
</Text>
|
||||
|
||||
<Text
|
||||
style={{
|
||||
width: "40%",
|
||||
}}
|
||||
>
|
||||
Notice
|
||||
served:{" "}
|
||||
{formatDate(
|
||||
tenant.dateserved
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<View
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<labels>
|
||||
<label description="What date was your application decided on by the LPA?" />
|
||||
</labels>
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_decisionordiscontinuanceappeal" parentFieldShowOnValue="846040000" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="0" dateEnd="+1y" disabled="false" />
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_decisionordiscontinuanceappeal" parentFieldShowOnValue="846040000" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="-6m" dateEnd="0" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<labels>
|
||||
<label description="What date was your application decided on by the LPA?" />
|
||||
</labels>
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="0" dateEnd="+1y" disabled="false" />
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="-6m" dateEnd="0" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
@@ -163,13 +163,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
<label description="Date started" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantdateserved" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_agriculturaltenantdateserved" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -755,13 +755,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
<label description="Date started" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantdateserved" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_agriculturaltenantdateserved" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
<labels>
|
||||
<label description="What date was your application decided on by the LPA?" />
|
||||
</labels>
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="0" dateEnd="+1y" disabled="false" />
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="-6m" dateEnd="0" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
@@ -148,13 +148,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
<label description="Date started" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantdateserved" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_agriculturaltenantdateserved" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<labels>
|
||||
<label description="What date was your application decided on by the LPA?" />
|
||||
</labels>
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="0" dateEnd="+1y" disabled="false" />
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="-6m" dateEnd="0" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<labels>
|
||||
<label description="What date was your application decided on by the LPA?" />
|
||||
</labels>
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="0" dateEnd="+1y" disabled="false" />
|
||||
<control id="pinswg_dateoflpadecision" parentField="pinswg_lpadecisiononapplicationmade" parentFieldShowOnValue="Yes" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_dateoflpadecision" dateStart="-6m" dateEnd="0" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
@@ -142,13 +142,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
<row>
|
||||
<labels>
|
||||
<label description="Date started" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantdateserved" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}" datafieldname="pinswg_agriculturaltenantdateserved" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -193,7 +193,7 @@ export default async function handler(req, res) {
|
||||
|
||||
return res.status(200).json({
|
||||
data: "success",
|
||||
path: `tmp/${blobProgress.pinswg_name}.pdf`,
|
||||
path: process.cwd() + `/tmp/${blobProgress.pinswg_name}.pdf`,
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
|
||||
@@ -1003,6 +1003,7 @@ textarea,
|
||||
.govuk-summary-list__value,
|
||||
.govuk-summary-list__actions {
|
||||
padding: 15px 10px 15px 0;
|
||||
width: 100%;
|
||||
|
||||
a,
|
||||
a:active,
|
||||
@@ -2418,4 +2419,33 @@ fade {
|
||||
text-decoration: none !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.fieldArrayLink {
|
||||
border: none;
|
||||
background: no-repeat;
|
||||
font-family: Arial, Helvetica, "Nimbus Sans L", sans-serif;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.fieldArrayContainer {
|
||||
display: flex;
|
||||
|
||||
.govuk-form-group {
|
||||
margin-right: 20px;
|
||||
margin-bottom: 0px;
|
||||
|
||||
legend {
|
||||
margin-bottom: 5px;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.fieldArrayDelete {
|
||||
border-radius: 10px;
|
||||
padding: 5px !important;
|
||||
height: 30px;
|
||||
margin-top: 32px;
|
||||
padding-top: 4px !important;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user