Skip to content

Commit

Permalink
fix: form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Mar 12, 2021
1 parent 58fd2d0 commit e69764c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
16 changes: 11 additions & 5 deletions src/components/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Field = ({
description={description}
required={required}
onChange={onChange}
value={value}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
Expand All @@ -67,6 +68,7 @@ const Field = ({
description={description}
required={required}
onChange={onChange}
value={value}
rows={10}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
Expand All @@ -80,9 +82,8 @@ const Field = ({
description={description}
getVocabulary={() => {}}
getVocabularyTokenTitle={() => {}}
choices={[
...(input_values?.map((v) => ({ value: v, label: v })) ?? []),
]}
choices={[...(input_values?.map((v) => [v, v]) ?? [])]}
value={value}
onChange={onChange}
placeholder={intl.formatMessage(messages.select_a_value)}
aria-label={intl.formatMessage(messages.select_a_value)}
Expand All @@ -101,6 +102,7 @@ const Field = ({
valueList={[
...(input_values?.map((v) => ({ value: v, label: v })) ?? []),
]}
value={value}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
Expand All @@ -114,6 +116,7 @@ const Field = ({
required={required}
onChange={onChange}
invalid={isInvalid().toString()}
value={value}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
Expand All @@ -125,7 +128,9 @@ const Field = ({
description={description}
dateOnly={true}
noPastDates={false}
resettable={false}
onChange={onChange}
value={value}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
Expand All @@ -134,10 +139,10 @@ const Field = ({
<FileWidget
id={name}
name={name}
label={getLabel()}
title={getLabel()}
description={description}
type="file"
required={required}
infoText={description}
invalid={isInvalid().toString()}
onChange={onChange}
onEdit={isOnEdit}
Expand All @@ -152,6 +157,7 @@ const Field = ({
description={description}
required={required}
onChange={onChange}
value={value}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/FormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const FormView = ({
return (
<div className="block form">
<div className="public-ui">
<Segment>
<Segment style={{ margin: '2rem 0' }} padded>
{formState.error ? (
<Message error role="alert">
<Message.Header as="h4">
Expand Down Expand Up @@ -121,7 +121,7 @@ const FormView = ({
</Message>
)}

<Grid.Row centered>
<Grid.Row centered style={{ paddingTop: '3rem' }}>
<Grid.Column textAlign="center">
<Button
primary
Expand Down
8 changes: 2 additions & 6 deletions src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ const Sidebar = ({
value={subblock.field_type || ''}
onChange={(name, value) => {
var update_values = {};
if (
['select', 'radio', 'checkbox'].indexOf(value) < 0
) {
if (['select', 'radio'].indexOf(value) < 0) {
update_values.input_values = null;
}
onChangeSubBlock(index, {
Expand Down Expand Up @@ -299,9 +297,7 @@ const Sidebar = ({
]}
/>

{['select', 'radio', 'checkbox'].indexOf(
subblock.field_type,
) >= 0 && (
{['select', 'radio'].indexOf(subblock.field_type) >= 0 && (
<ArrayWidget
id="input_values"
title={intl.formatMessage(messages.field_input_values)}
Expand Down
12 changes: 6 additions & 6 deletions src/components/Widget/FileWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ const FileWidget = (props) => {
disabled={props.isDisabled}
{...getInputProps({
type: 'file',
style: { display: 'none' },
style: { display: 'block' },
})}
onChange={({ target }) => {
const file = target.files[0];
onUpload(file);
}}
/>
<div className="field-file-name">
{value && value.filename}
{value && (
{value && (
<div className="field-file-name">
{value.filename}
<Button
icon
basic
Expand All @@ -106,8 +106,8 @@ const FileWidget = (props) => {
>
<Icon name={deleteSVG} size="20px" />
</Button>
)}
</div>
</div>
)}
</div>
)}
</Dropzone>
Expand Down

0 comments on commit e69764c

Please sign in to comment.