logic for has or cas
This commit is contained in:
+128
-35
@@ -621,6 +621,7 @@ const RenderYesNo = ({
|
||||
|
||||
export function YesNofield(props) {
|
||||
const router = useRouter();
|
||||
let { t } = useTranslation();
|
||||
|
||||
const { name, label, inline, validation } = props;
|
||||
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
|
||||
@@ -773,6 +774,7 @@ export function Radiofield(props) {
|
||||
const router = useRouter();
|
||||
const required = (value) => (value ? undefined : "Required");
|
||||
// console.log(props.options);
|
||||
let { t } = useTranslation();
|
||||
|
||||
const fieldOptions = props.options
|
||||
.slice(1, props.options.length - 1)
|
||||
@@ -996,51 +998,142 @@ export function PickList(props) {
|
||||
}
|
||||
|
||||
export function NumericField(props) {
|
||||
const { name, label, validation } = props;
|
||||
const {
|
||||
name,
|
||||
label,
|
||||
validation,
|
||||
form,
|
||||
formProps,
|
||||
parentFieldShowOnValue,
|
||||
parentField,
|
||||
} = props;
|
||||
const required = (value) => (value ? undefined : "Required");
|
||||
|
||||
//parentFieldShowOnValue
|
||||
var showIfHasParentShowValue =
|
||||
parentField != false &&
|
||||
!_.isEmpty(formProps[form]) &&
|
||||
_.has(formProps[form].values, parentField) &&
|
||||
parentFieldShowOnValue.indexOf(
|
||||
formProps[form].values[parentField].toString()
|
||||
) > -1;
|
||||
|
||||
(showIfHasParentShowValue == parentField) != false &&
|
||||
showIfHasParentShowValue;
|
||||
|
||||
console.log("parentField:", parentField, showIfHasParentShowValue);
|
||||
|
||||
return (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={label}
|
||||
/>
|
||||
</div>
|
||||
<>
|
||||
{parentField != false ? (
|
||||
showIfHasParentShowValue && (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={label}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={label}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function DecimalField(props) {
|
||||
const { name, label, validation } = props;
|
||||
const {
|
||||
name,
|
||||
label,
|
||||
validation,
|
||||
form,
|
||||
formProps,
|
||||
parentFieldShowOnValue,
|
||||
parentField,
|
||||
} = props;
|
||||
const required = (value) => (value ? undefined : "Required");
|
||||
|
||||
//parentFieldShowOnValue
|
||||
var showIfHasParentShowValue =
|
||||
parentField != false &&
|
||||
!_.isEmpty(formProps[form]) &&
|
||||
_.has(formProps[form].values, parentField) &&
|
||||
parentFieldShowOnValue.indexOf(
|
||||
formProps[form].values[parentField].toString()
|
||||
) > -1;
|
||||
|
||||
(showIfHasParentShowValue == parentField) != false &&
|
||||
showIfHasParentShowValue;
|
||||
|
||||
console.log("parentField:", parentField, showIfHasParentShowValue);
|
||||
|
||||
return (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
// component="input"
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={props.label}
|
||||
/>
|
||||
</div>
|
||||
<>
|
||||
{parentField != false ? (
|
||||
showIfHasParentShowValue && (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
// component="input"
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={props.label}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<div className="govuk-form-group">
|
||||
<Field
|
||||
name={props.name}
|
||||
id={props.name}
|
||||
// component="input"
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
spellCheck="false"
|
||||
aria-describedby={name}
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
validate={eval(validation)}
|
||||
component={RenderTextfield}
|
||||
label={props.label}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,11 @@ export default function BuildField(props) {
|
||||
<NumericField
|
||||
name={props.datafieldname}
|
||||
label={props.label}
|
||||
form={props.props.props.form}
|
||||
formProps={props.props.props.props.form}
|
||||
validation={props.validation}
|
||||
parentField={props.parentField}
|
||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
@@ -158,7 +162,11 @@ export default function BuildField(props) {
|
||||
<DecimalField
|
||||
name={props.datafieldname}
|
||||
label={props.label}
|
||||
form={props.props.props.form}
|
||||
formProps={props.props.props.props.form}
|
||||
validation={props.validation}
|
||||
parentField={props.parentField}
|
||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -448,6 +448,8 @@ let CreateCase = (props) => {
|
||||
|
||||
delete values.confirmHASCAS;
|
||||
|
||||
console.log(appTypeCollection);
|
||||
|
||||
createNewCase(
|
||||
appTypeCollection.appealTypeID,
|
||||
values.lpaTypes,
|
||||
|
||||
Reference in New Issue
Block a user