From da6ae8dd0729b511a1de87a39fab0ad14037cb32 Mon Sep 17 00:00:00 2001 From: nzambello Date: Tue, 16 Mar 2021 11:21:16 +0100 Subject: [PATCH] feat: add static fields rendering --- src/components/Field.jsx | 9 +++++++++ src/components/FormView.jsx | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/Field.jsx b/src/components/Field.jsx index 838a47a..cba319e 100644 --- a/src/components/Field.jsx +++ b/src/components/Field.jsx @@ -36,6 +36,7 @@ const Field = ({ onChange, isOnEdit, valid, + disabled = false, }) => { const intl = useIntl(); @@ -54,6 +55,7 @@ const Field = ({ required={required} onChange={onChange} value={value} + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> @@ -68,6 +70,7 @@ const Field = ({ onChange={onChange} value={value} rows={10} + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> @@ -86,6 +89,7 @@ const Field = ({ placeholder={intl.formatMessage(messages.select_a_value)} aria-label={intl.formatMessage(messages.select_a_value)} classNamePrefix="react-select" + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> @@ -101,6 +105,7 @@ const Field = ({ ...(input_values?.map((v) => ({ value: v, label: v })) ?? []), ]} value={value} + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> @@ -113,6 +118,7 @@ const Field = ({ description={description} required={required} onChange={onChange} + isDisabled={disabled} invalid={isInvalid().toString()} value={value} {...(isInvalid() ? { className: 'is-invalid' } : {})} @@ -129,6 +135,7 @@ const Field = ({ resettable={false} onChange={onChange} value={value} + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> @@ -142,6 +149,7 @@ const Field = ({ type="file" required={required} invalid={isInvalid().toString()} + isDisabled={disabled} onChange={onChange} value={value} /> @@ -155,6 +163,7 @@ const Field = ({ required={required} onChange={onChange} value={value} + isDisabled={disabled} invalid={isInvalid().toString()} {...(isInvalid() ? { className: 'is-invalid' } : {})} /> diff --git a/src/components/FormView.jsx b/src/components/FormView.jsx index 2a1fdaf..6002dae 100644 --- a/src/components/FormView.jsx +++ b/src/components/FormView.jsx @@ -78,14 +78,23 @@ const FormView = ({

{formState.result}

) : ( -
+ - {data.subblocks.map((subblock, index) => { + {data.static_fields?.map((field) => ( + + + {}} + disabled + valid + /> + + + ))} + {data.subblocks?.map((subblock, index) => { let name = getFieldName(subblock.label); return (