Skip to content

Commit dc6c34c

Browse files
authored
Merge pull request #7 from collective/feat_checkbox_field
[BREAKING] add checkbox field, rename old checkbox and radio
2 parents f9f4e25 + c791509 commit dc6c34c

File tree

18 files changed

+123
-44
lines changed

18 files changed

+123
-44
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ For each field, you can select the field type from:
2626
- Text
2727
- Textarea
2828
- Select
29-
- Radio buttons
30-
- Checkbox buttons
29+
- Single choice (radio buttons)
30+
- Multiple choice (checkbox buttons)
31+
- Checkbox
3132
- Date picker
3233
- File upload with DnD
3334
- E-mail

locales/de/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/en/LC_MESSAGES/volto.po

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ msgstr "Attachment"
114114

115115
#: components/Sidebar
116116
msgid "form_field_type_checkbox"
117-
msgstr "Multiple choice"
117+
msgstr "Checkbox"
118118

119119
#: components/Sidebar
120120
msgid "form_field_type_date"
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr "E-mail"
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
129-
msgstr "Single choice"
128+
msgid "form_field_type_multiple_choice"
129+
msgstr "Multiple choice"
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr "List"
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr "Single choice"
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr "Static text"

locales/es/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/eu/LC_MESSAGES/volto.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgstr ""
1111
"Content-Transfer-Encoding: \n"
1212
"Plural-Forms: \n"
1313

14-
#: components/Edit
14+
#: components/Edit
1515
msgid "Add field"
1616
msgstr ""
1717

@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/fr/LC_MESSAGES/volto.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr "E-mail"
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
129-
msgstr "Choix unique"
128+
msgid "form_field_type_multiple_choice"
129+
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr "Lister"
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/it/LC_MESSAGES/volto.po

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ msgstr "Allegato"
114114

115115
#: components/Sidebar
116116
msgid "form_field_type_checkbox"
117-
msgstr "Scelta multpla"
117+
msgstr "Checkbox"
118118

119119
#: components/Sidebar
120120
msgid "form_field_type_date"
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr "E-mail"
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
129-
msgstr "Scelta singola"
128+
msgid "form_field_type_multiple_choice"
129+
msgstr "Scelta multipla"
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr "Lista"
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr "Scelta singola"
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr "Testo statico"

locales/ja/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,19 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135135
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
136139
msgid "form_field_type_static_text"
140+
#: components/Sidebar
137141
msgstr ""
138142

139143
#: components/Sidebar

locales/nl/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/pt/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/pt_BR/LC_MESSAGES/volto.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ msgid "form_field_type_from"
131131
msgstr "E-mail"
132132

133133
#: components/Sidebar
134-
msgid "form_field_type_radio"
135-
msgstr "Escolha única"
134+
msgid "form_field_type_multiple_choice"
135+
msgstr ""
136136

137137
#: components/Sidebar
138138
msgid "form_field_type_select"
139139
msgstr "Opções"
140140

141+
#: components/Sidebar
142+
msgid "form_field_type_single_choice"
143+
msgstr ""
144+
141145
#: components/Sidebar
142146
msgid "form_field_type_static_text"
143147
msgstr ""

locales/ro/LC_MESSAGES/volto.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ msgid "form_field_type_from"
125125
msgstr ""
126126

127127
#: components/Sidebar
128-
msgid "form_field_type_radio"
128+
msgid "form_field_type_multiple_choice"
129129
msgstr ""
130130

131131
#: components/Sidebar
132132
msgid "form_field_type_select"
133133
msgstr ""
134134

135+
#: components/Sidebar
136+
msgid "form_field_type_single_choice"
137+
msgstr ""
138+
135139
#: components/Sidebar
136140
msgid "form_field_type_static_text"
137141
msgstr ""

locales/volto.pot

+8-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ msgid "form_field_type_attachment"
140140
msgstr ""
141141

142142
#: components/Sidebar
143-
# defaultMessage: Multiple choice
143+
# defaultMessage: Checkbox
144144
msgid "form_field_type_checkbox"
145145
msgstr ""
146146

@@ -155,15 +155,20 @@ msgid "form_field_type_from"
155155
msgstr ""
156156

157157
#: components/Sidebar
158-
# defaultMessage: Single choice
159-
msgid "form_field_type_radio"
158+
# defaultMessage: Multiple choice
159+
msgid "form_field_type_multiple_choice"
160160
msgstr ""
161161

162162
#: components/Sidebar
163163
# defaultMessage: List
164164
msgid "form_field_type_select"
165165
msgstr ""
166166

167+
#: components/Sidebar
168+
# defaultMessage: Single choice
169+
msgid "form_field_type_single_choice"
170+
msgstr ""
171+
167172
#: components/Sidebar
168173
# defaultMessage: Static text
169174
msgid "form_field_type_static_text"

src/components/Field.jsx

+19-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import TextareaWidget from '@plone/volto/components/manage/Widgets/TextareaWidge
77
import SelectWidget from '@plone/volto/components/manage/Widgets/SelectWidget';
88
import EmailWidget from '@plone/volto/components/manage/Widgets/EmailWidget';
99
import FileWidget from '@plone/volto/components/manage/Widgets/FileWidget';
10+
import CheckboxWidget from '@plone/volto/components/manage/Widgets/CheckboxWidget';
1011
import WysiwygWidget from '@plone/volto/components/manage/Widgets/WysiwygWidget';
1112
import { DatetimeWidget } from '@plone/volto/components';
1213

13-
import CheckboxWidget from './Widget/CheckboxWidget';
14+
import CheckboxListWidget from './Widget/CheckboxListWidget';
1415
import RadioWidget from './Widget/RadioWidget';
1516

1617
import './Field.css';
@@ -99,7 +100,7 @@ const Field = ({
99100
{...(isInvalid() ? { className: 'is-invalid' } : {})}
100101
/>
101102
)}
102-
{field_type === 'radio' && (
103+
{field_type === 'single_choice' && (
103104
<RadioWidget
104105
id={name}
105106
title={label}
@@ -115,8 +116,8 @@ const Field = ({
115116
{...(isInvalid() ? { className: 'is-invalid' } : {})}
116117
/>
117118
)}
118-
{field_type === 'checkbox' && (
119-
<CheckboxWidget
119+
{field_type === 'multiple_choice' && (
120+
<CheckboxListWidget
120121
id={name}
121122
name={name}
122123
title={label}
@@ -132,6 +133,20 @@ const Field = ({
132133
{...(isInvalid() ? { className: 'is-invalid' } : {})}
133134
/>
134135
)}
136+
{field_type === 'checkbox' && (
137+
<CheckboxWidget
138+
id={name}
139+
name={name}
140+
title={label}
141+
description={description}
142+
required={required}
143+
onChange={onChange}
144+
value={!!value}
145+
isDisabled={disabled}
146+
invalid={isInvalid().toString()}
147+
{...(isInvalid() ? { className: 'is-invalid' } : {})}
148+
/>
149+
)}
135150
{field_type === 'date' && (
136151
<DatetimeWidget
137152
id={name}

src/components/Sidebar.jsx

+21-7
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ const messages = defineMessages({
8686
id: 'form_field_type_select',
8787
defaultMessage: 'List',
8888
},
89-
field_type_radio: {
90-
id: 'form_field_type_radio',
89+
field_type_single_choice: {
90+
id: 'form_field_type_single_choice',
9191
defaultMessage: 'Single choice',
9292
},
93+
field_type_multiple_choice: {
94+
id: 'form_field_type_multiple_choice',
95+
defaultMessage: 'Multiple choice',
96+
},
9397
field_type_checkbox: {
9498
id: 'form_field_type_checkbox',
95-
defaultMessage: 'Multiple choice',
99+
defaultMessage: 'Checkbox',
96100
},
97101
field_type_date: {
98102
id: 'form_field_type_date',
@@ -438,7 +442,11 @@ const Sidebar = ({
438442
onChange={(name, value) => {
439443
var update_values = {};
440444
if (
441-
['select', 'radio', 'checkbox'].indexOf(value) < 0
445+
[
446+
'select',
447+
'single_choice',
448+
'multiple_choice',
449+
].indexOf(value) < 0
442450
) {
443451
update_values.input_values = null;
444452
}
@@ -459,8 +467,14 @@ const Sidebar = ({
459467
intl.formatMessage(messages.field_type_select),
460468
],
461469
[
462-
'radio',
463-
intl.formatMessage(messages.field_type_radio),
470+
'single_choice',
471+
intl.formatMessage(messages.field_type_single_choice),
472+
],
473+
[
474+
'multiple_choice',
475+
intl.formatMessage(
476+
messages.field_type_multiple_choice,
477+
),
464478
],
465479
[
466480
'checkbox',
@@ -492,7 +506,7 @@ const Sidebar = ({
492506
</FormFieldWrapper>
493507
)}
494508

495-
{['select', 'radio', 'checkbox'].indexOf(
509+
{['select', 'single_choice', 'multiple_choice'].indexOf(
496510
subblock.field_type,
497511
) >= 0 && (
498512
<ArrayWidget

0 commit comments

Comments
 (0)