Skip to content

Commit

Permalink
feat!: add checkbox field, rename old checkbox and radio
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Aug 7, 2021
1 parent 77215bf commit 669e88b
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 61 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ For each field, you can select the field type from:
- Text
- Textarea
- Select
- Radio buttons
- Checkbox buttons
- Single choice (radio buttons)
- Multiple choice (checkbox buttons)
- Checkbox
- Date picker
- File upload with DnD
- E-mail
Expand Down
6 changes: 5 additions & 1 deletion locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
10 changes: 7 additions & 3 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ msgstr "Attachment"

#: components/Sidebar
msgid "form_field_type_checkbox"
msgstr "Multiple choice"
msgstr "Checkbox"

#: components/Sidebar
msgid "form_field_type_date"
Expand All @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr "E-mail"

#: components/Sidebar
msgid "form_field_type_radio"
msgstr "Single choice"
msgid "form_field_type_multiple_choice"
msgstr "Multiple choice"

#: components/Sidebar
msgid "form_field_type_select"
msgstr "List"

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr "Single choice"

#: components/Sidebar
msgid "form_field_type_text"
msgstr "Text"
Expand Down
6 changes: 5 additions & 1 deletion locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
8 changes: 6 additions & 2 deletions locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr "E-mail"

#: components/Sidebar
msgid "form_field_type_radio"
msgstr "Choix unique"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr "Lister"

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr "Texte"
Expand Down
10 changes: 7 additions & 3 deletions locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ msgstr "Allegato"

#: components/Sidebar
msgid "form_field_type_checkbox"
msgstr "Scelta multpla"
msgstr "Checkbox"

#: components/Sidebar
msgid "form_field_type_date"
Expand All @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr "E-mail"

#: components/Sidebar
msgid "form_field_type_radio"
msgstr "Scelta singola"
msgid "form_field_type_multiple_choice"
msgstr "Scelta multipla"

#: components/Sidebar
msgid "form_field_type_select"
msgstr "Lista"

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr "Scelta singola"

#: components/Sidebar
msgid "form_field_type_text"
msgstr "Testo"
Expand Down
6 changes: 5 additions & 1 deletion locales/ja/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion locales/nl/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion locales/pt/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
8 changes: 6 additions & 2 deletions locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ msgid "form_field_type_from"
msgstr "E-mail"

#: components/Sidebar
msgid "form_field_type_radio"
msgstr "Escolha única"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr "Opções"

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr "Texto"
Expand Down
6 changes: 5 additions & 1 deletion locales/ro/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
msgid "form_field_type_radio"
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
msgid "form_field_type_text"
msgstr ""
Expand Down
13 changes: 9 additions & 4 deletions locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2021-08-03T07:34:46.833Z\n"
"POT-Creation-Date: 2021-08-07T16:04:30.439Z\n"
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -140,7 +140,7 @@ msgid "form_field_type_attachment"
msgstr ""

#: components/Sidebar
# defaultMessage: Multiple choice
# defaultMessage: Checkbox
msgid "form_field_type_checkbox"
msgstr ""

Expand All @@ -155,15 +155,20 @@ msgid "form_field_type_from"
msgstr ""

#: components/Sidebar
# defaultMessage: Single choice
msgid "form_field_type_radio"
# defaultMessage: Multiple choice
msgid "form_field_type_multiple_choice"
msgstr ""

#: components/Sidebar
# defaultMessage: List
msgid "form_field_type_select"
msgstr ""

#: components/Sidebar
# defaultMessage: Single choice
msgid "form_field_type_single_choice"
msgstr ""

#: components/Sidebar
# defaultMessage: Text
msgid "form_field_type_text"
Expand Down
27 changes: 21 additions & 6 deletions src/components/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import TextareaWidget from '@plone/volto/components/manage/Widgets/TextareaWidge
import SelectWidget from '@plone/volto/components/manage/Widgets/SelectWidget';
import EmailWidget from '@plone/volto/components/manage/Widgets/EmailWidget';
import FileWidget from '@plone/volto/components/manage/Widgets/FileWidget';
import CheckboxWidget from '@plone/volto/components/manage/Widgets/CheckboxWidget';
import { DatetimeWidget } from '@plone/volto/components';

import CheckboxWidget from './Widget/CheckboxWidget';
import CheckboxListWidget from './Widget/CheckboxListWidget';
import RadioWidget from './Widget/RadioWidget';

import './Field.css';
Expand Down Expand Up @@ -84,8 +85,8 @@ const Field = ({
name={name}
title={label}
description={description}
getVocabulary={() => {}}
getVocabularyTokenTitle={() => {}}
getVocabulary={() => { }}
getVocabularyTokenTitle={() => { }}
choices={[...(input_values?.map((v) => [v, v]) ?? [])]}
value={value}
onChange={onChange}
Expand All @@ -97,7 +98,7 @@ const Field = ({
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
{field_type === 'radio' && (
{field_type === 'single_choice' && (
<RadioWidget
id={name}
title={label}
Expand All @@ -113,8 +114,8 @@ const Field = ({
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
{field_type === 'checkbox' && (
<CheckboxWidget
{field_type === 'multiple_choice' && (
<CheckboxListWidget
id={name}
name={name}
title={label}
Expand All @@ -130,6 +131,20 @@ const Field = ({
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
{field_type === 'checkbox' && (
<CheckboxWidget
id={name}
name={name}
title={label}
description={description}
required={required}
onChange={onChange}
value={!!value}
isDisabled={disabled}
invalid={isInvalid().toString()}
{...(isInvalid() ? { className: 'is-invalid' } : {})}
/>
)}
{field_type === 'date' && (
<DatetimeWidget
id={name}
Expand Down
Loading

0 comments on commit 669e88b

Please sign in to comment.