@plone/volto 14.1.1 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/components/manage/Add/Add.jsx +1 -0
- package/src/components/manage/Edit/Edit.jsx +1 -0
- package/src/components/manage/Form/Form.jsx +21 -5
- package/src/components/manage/Multilingual/TranslationObject.jsx +1 -0
- package/src/components/manage/Widgets/ArrayWidget.jsx +19 -1
- package/src/components/manage/Widgets/ArrayWidget.stories.jsx +8 -0
- package/src/config/Blocks.jsx +8 -1
- package/src/config/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 14.2.0 (2022-01-04)
|
|
4
|
+
|
|
5
|
+
### Feature
|
|
6
|
+
|
|
7
|
+
- Allow `creatable` prop to be passed to `ArrayWidgets`, in case they don't have a vocabulary @giuliaghisini
|
|
8
|
+
- Added initialBlocksFocus to blocks config, to set default focus on non-first block. @giuliaghisini
|
|
9
|
+
|
|
3
10
|
## 14.1.1 (2022-01-03)
|
|
4
11
|
|
|
5
12
|
### Internal
|
package/package.json
CHANGED
|
@@ -172,15 +172,31 @@ class Form extends Component {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
let selectedBlock = null;
|
|
177
|
+
if (
|
|
178
|
+
formData.hasOwnProperty(blocksLayoutFieldname) &&
|
|
179
|
+
formData[blocksLayoutFieldname].items.length > 0
|
|
180
|
+
) {
|
|
181
|
+
selectedBlock = formData[blocksLayoutFieldname].items[0];
|
|
182
|
+
|
|
183
|
+
if (config.blocks?.initialBlocksFocus?.[this.props.type]) {
|
|
184
|
+
//Default selected is not the first block, but the one from config.
|
|
185
|
+
Object.keys(formData[blocksFieldname]).forEach((b_key) => {
|
|
186
|
+
if (
|
|
187
|
+
formData[blocksFieldname][b_key]['@type'] ===
|
|
188
|
+
config.blocks?.initialBlocksFocus?.[this.props.type]
|
|
189
|
+
) {
|
|
190
|
+
selectedBlock = b_key;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
175
195
|
this.state = {
|
|
176
196
|
formData,
|
|
177
197
|
initialFormData: cloneDeep(formData),
|
|
178
198
|
errors: {},
|
|
179
|
-
selected:
|
|
180
|
-
formData.hasOwnProperty(blocksLayoutFieldname) &&
|
|
181
|
-
formData[blocksLayoutFieldname].items.length > 0
|
|
182
|
-
? formData[blocksLayoutFieldname].items[0]
|
|
183
|
-
: null,
|
|
199
|
+
selected: selectedBlock,
|
|
184
200
|
multiSelected: [],
|
|
185
201
|
isClient: false,
|
|
186
202
|
};
|
|
@@ -157,6 +157,7 @@ class ArrayWidget extends Component {
|
|
|
157
157
|
),
|
|
158
158
|
onChange: PropTypes.func.isRequired,
|
|
159
159
|
wrapped: PropTypes.bool,
|
|
160
|
+
creatable: PropTypes.bool, //if widget has no vocab and you want to be creatable
|
|
160
161
|
};
|
|
161
162
|
|
|
162
163
|
/**
|
|
@@ -176,6 +177,7 @@ class ArrayWidget extends Component {
|
|
|
176
177
|
error: [],
|
|
177
178
|
choices: [],
|
|
178
179
|
value: null,
|
|
180
|
+
creatable: false,
|
|
179
181
|
};
|
|
180
182
|
|
|
181
183
|
/**
|
|
@@ -242,7 +244,23 @@ class ArrayWidget extends Component {
|
|
|
242
244
|
const { SortableContainer } = this.props.reactSortableHOC;
|
|
243
245
|
const Select = this.props.reactSelect.default;
|
|
244
246
|
const SortableSelect =
|
|
245
|
-
|
|
247
|
+
// It will be only createable if the named vocabulary is in the widget definition
|
|
248
|
+
// (hint) like:
|
|
249
|
+
// list_field_voc_unconstrained = schema.List(
|
|
250
|
+
// title=u"List field with values from vocabulary but not constrained to them.",
|
|
251
|
+
// description=u"zope.schema.List",
|
|
252
|
+
// value_type=schema.TextLine(),
|
|
253
|
+
// required=False,
|
|
254
|
+
// missing_value=[],
|
|
255
|
+
// )
|
|
256
|
+
// directives.widget(
|
|
257
|
+
// "list_field_voc_unconstrained",
|
|
258
|
+
// AjaxSelectFieldWidget,
|
|
259
|
+
// vocabulary="plone.app.vocabularies.PortalTypes",
|
|
260
|
+
// )
|
|
261
|
+
this.props?.choices &&
|
|
262
|
+
!getVocabFromHint(this.props) &&
|
|
263
|
+
!this.props.creatable
|
|
246
264
|
? SortableContainer(Select)
|
|
247
265
|
: SortableContainer(CreatableSelect);
|
|
248
266
|
|
|
@@ -119,6 +119,14 @@ Disabled.args = {
|
|
|
119
119
|
disabled: true,
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
+
export const Creatable = WidgetStory.bind({ widget: ArrayWidget });
|
|
123
|
+
Creatable.args = {
|
|
124
|
+
id: 'field-creatable',
|
|
125
|
+
title: 'Field with creatable',
|
|
126
|
+
description: 'Allows creation of new terms',
|
|
127
|
+
creatable: true,
|
|
128
|
+
};
|
|
129
|
+
|
|
122
130
|
const getOptionsGenerator = (count) => {
|
|
123
131
|
const options = [];
|
|
124
132
|
for (let i = 0; i < count; i = i + 1) {
|
package/src/config/Blocks.jsx
CHANGED
|
@@ -454,5 +454,12 @@ const blocksConfig = {
|
|
|
454
454
|
const requiredBlocks = ['title'];
|
|
455
455
|
|
|
456
456
|
const initialBlocks = {};
|
|
457
|
+
const initialBlocksFocus = {}; //{Document:'title'}
|
|
457
458
|
|
|
458
|
-
export {
|
|
459
|
+
export {
|
|
460
|
+
groupBlocksOrder,
|
|
461
|
+
requiredBlocks,
|
|
462
|
+
blocksConfig,
|
|
463
|
+
initialBlocks,
|
|
464
|
+
initialBlocksFocus,
|
|
465
|
+
};
|
package/src/config/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
requiredBlocks,
|
|
27
27
|
blocksConfig,
|
|
28
28
|
initialBlocks,
|
|
29
|
+
initialBlocksFocus,
|
|
29
30
|
} from './Blocks';
|
|
30
31
|
import { loadables } from './Loadables';
|
|
31
32
|
|
|
@@ -174,6 +175,7 @@ let config = {
|
|
|
174
175
|
blocksConfig,
|
|
175
176
|
groupBlocksOrder,
|
|
176
177
|
initialBlocks,
|
|
178
|
+
initialBlocksFocus,
|
|
177
179
|
showEditBlocksInBabelView: false,
|
|
178
180
|
},
|
|
179
181
|
addonRoutes: [],
|