@plone/volto 18.0.0-alpha.41 → 18.0.0-alpha.43
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 +114 -0
- package/finalreleasechangelog.py +48 -0
- package/locales/ca/LC_MESSAGES/volto.po +39 -13
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +40 -14
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +39 -13
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +40 -14
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +40 -14
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +40 -14
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +40 -14
- package/locales/fr.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +40 -14
- package/locales/hi.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +40 -14
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +39 -13
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +39 -13
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +39 -13
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +40 -14
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +39 -13
- package/locales/ro.json +1 -1
- package/locales/volto.pot +40 -14
- package/locales/zh_CN/LC_MESSAGES/volto.po +40 -14
- package/locales/zh_CN.json +1 -1
- package/package.json +5 -6
- package/razzle.config.js +3 -3
- package/src/components/index.js +0 -1
- package/src/components/manage/Actions/Actions.stories.jsx +138 -0
- package/src/components/manage/Add/Add.jsx +7 -4
- package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +5 -0
- package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
- package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
- package/src/components/manage/Blocks/Block/Order/Item.jsx +8 -2
- package/src/components/manage/Blocks/Block/Order/Order.jsx +2 -0
- package/src/components/manage/Blocks/Container/Data.jsx +10 -2
- package/src/components/manage/Blocks/Grid/View.jsx +3 -0
- package/src/components/manage/Blocks/Image/ImageSidebar.jsx +10 -2
- package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
- package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -2
- package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -0
- package/src/components/manage/Blocks/Search/SearchBlockView.jsx +18 -2
- package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +1 -1
- package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
- package/src/components/manage/Blocks/Teaser/Data.jsx +10 -2
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
- package/src/components/manage/Blocks/ToC/Edit.jsx +36 -28
- package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
- package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
- package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
- package/src/components/manage/Contents/Contents.jsx +4 -1
- package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
- package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
- package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
- package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
- package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
- package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
- package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
- package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -0
- package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
- package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
- package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
- package/src/components/manage/Controlpanels/UndoControlpanel.jsx +3 -3
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +28 -12
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +12 -4
- package/src/components/manage/Display/Display.jsx +92 -148
- package/src/components/manage/Display/Display.stories.jsx +46 -0
- package/src/components/manage/Edit/Edit.jsx +2 -4
- package/src/components/manage/Form/Form.jsx +85 -20
- package/src/components/manage/Form/InlineForm.jsx +2 -4
- package/src/components/manage/Form/ModalForm.jsx +1 -1
- package/src/components/manage/History/History.jsx +1 -1
- package/src/components/manage/Pluggable/Pluggable.test.js +1 -1
- package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
- package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
- package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
- package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
- package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
- package/src/components/manage/Toolbar/More.jsx +308 -399
- package/src/components/manage/Toolbar/Toolbar.jsx +1 -1
- package/src/components/manage/Widgets/ArrayWidget.jsx +2 -2
- package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
- package/src/components/manage/Widgets/ImageWidget.jsx +6 -5
- package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +80 -31
- package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
- package/src/components/theme/Register/Register.jsx +70 -142
- package/src/components/theme/Register/Register.stories.jsx +49 -0
- package/src/components/theme/Search/Search.jsx +13 -5
- package/src/components/theme/Tags/Tags.jsx +19 -10
- package/src/components/theme/Tags/Tags.test.jsx +9 -11
- package/src/components/theme/View/AlbumView.jsx +122 -167
- package/src/components/theme/View/LinkView.jsx +4 -0
- package/src/components/theme/View/LinkView.test.jsx +2 -0
- package/src/components/theme/View/View.jsx +0 -13
- package/src/components/theme/View/View.test.jsx +0 -3
- package/src/config/ControlPanels.js +49 -43
- package/src/config/Widgets.jsx +1 -1
- package/src/config/config.test.js +1 -0
- package/src/config/index.js +23 -2
- package/src/config/slots.js +12 -0
- package/src/config/validation.ts +155 -0
- package/src/helpers/Blocks/Blocks.js +12 -7
- package/src/helpers/Blocks/Blocks.test.js +15 -0
- package/src/helpers/Blocks/cloneBlocks.ts +1 -1
- package/src/helpers/Extensions/withBlockExtensions.jsx +1 -1
- package/src/helpers/FormValidation/FormValidation.jsx +128 -172
- package/src/helpers/FormValidation/FormValidation.test.js +836 -8
- package/src/helpers/FormValidation/validators.ts +203 -0
- package/src/helpers/MessageLabels/MessageLabels.js +28 -0
- package/src/helpers/Url/Url.test.js +19 -6
- package/src/helpers/Url/urlRegex.js +1 -1
- package/src/helpers/User/User.js +1 -1
- package/src/helpers/index.js +2 -0
- package/src/hooks/client/useClient.js +1 -1
- package/src/middleware/api.js +4 -2
- package/src/middleware/index.js +1 -0
- package/src/middleware/userSessionReset.js +46 -0
- package/src/store.js +2 -0
- package/test-setup-config.jsx +10 -0
- package/theme/themes/default/modules/embed.variables +1 -1
- package/theme/themes/pastanaga/collections/form.overrides +34 -0
- package/theme/themes/pastanaga/extras/blocks.less +6 -0
- package/theme/themes/pastanaga/extras/sidebar.less +4 -0
- package/theme/themes/pastanaga/extras/toolbar.less +10 -3
- package/tsconfig.declarations.json +3 -2
- package/types/components/index.d.ts +0 -1
- package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
- package/types/components/manage/Blocks/Block/Order/Order.d.ts +2 -1
- package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
- package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
- package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
- package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
- package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
- package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
- package/types/components/manage/Contents/index.d.ts +1 -1
- package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
- package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
- package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
- package/types/components/manage/Controlpanels/index.d.ts +4 -4
- package/types/components/manage/Display/Display.stories.d.ts +8 -0
- package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
- package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
- package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
- package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
- package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
- package/types/components/manage/Toolbar/More.d.ts +8 -5
- package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
- package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
- package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
- package/types/components/manage/Widgets/index.d.ts +1 -1
- package/types/components/theme/Register/Register.d.ts +2 -2
- package/types/components/theme/Register/Register.stories.d.ts +9 -0
- package/types/components/theme/Tags/Tags.d.ts +15 -7
- package/types/components/theme/View/AlbumView.d.ts +3 -17
- package/types/config/ControlPanels.d.ts +8 -0
- package/types/config/RichTextEditor/ToHTML.d.ts +1 -1
- package/types/config/Widgets.d.ts +3 -3
- package/types/config/slots.d.ts +21 -0
- package/types/config/validation.d.ts +3 -0
- package/types/helpers/Blocks/Blocks.d.ts +6 -0
- package/types/helpers/Extensions/withBlockExtensions.d.ts +1 -1
- package/types/helpers/FormValidation/FormValidation.d.ts +2 -0
- package/types/helpers/FormValidation/validators.d.ts +29 -0
- package/types/helpers/MessageLabels/MessageLabels.d.ts +36 -0
- package/types/helpers/User/User.d.ts +1 -1
- package/types/helpers/index.d.ts +2 -2
- package/types/middleware/index.d.ts +1 -0
- package/types/middleware/userSessionReset.d.ts +5 -0
- package/src/components/theme/SocialSharing/SocialSharing.jsx +0 -48
- package/src/components/theme/SocialSharing/SocialSharing.test.jsx +0 -14
package/src/config/Widgets.jsx
CHANGED
|
@@ -55,7 +55,6 @@ import ImageWidget from '@plone/volto/components/manage/Widgets/ImageWidget';
|
|
|
55
55
|
// Widgets mapping
|
|
56
56
|
export const widgetMapping = {
|
|
57
57
|
id: {
|
|
58
|
-
schema: SchemaWidget,
|
|
59
58
|
subjects: TokenWidget,
|
|
60
59
|
query: QuerystringWidget,
|
|
61
60
|
recurrence: RecurrenceWidget,
|
|
@@ -89,6 +88,7 @@ export const widgetMapping = {
|
|
|
89
88
|
autocomplete: SelectAutoComplete,
|
|
90
89
|
color_picker: ColorPickerWidget,
|
|
91
90
|
select: SelectWidget,
|
|
91
|
+
schema: SchemaWidget,
|
|
92
92
|
},
|
|
93
93
|
vocabulary: {
|
|
94
94
|
'plone.app.vocabularies.Catalog': ObjectBrowserWidget,
|
package/src/config/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { components } from './Components';
|
|
19
19
|
import { loadables } from './Loadables';
|
|
20
20
|
import { workflowMapping } from './Workflows';
|
|
21
|
+
import slots from './slots';
|
|
21
22
|
|
|
22
23
|
import { contentIcons } from './ContentIcons';
|
|
23
24
|
import { styleClassNameConverters, styleClassNameExtenders } from './Style';
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
controlPanelsIcons,
|
|
26
27
|
filterControlPanels,
|
|
27
28
|
filterControlPanelsSchema,
|
|
29
|
+
unwantedControlPanelsFields,
|
|
28
30
|
} from './ControlPanels';
|
|
29
31
|
|
|
30
32
|
import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
|
|
@@ -32,6 +34,7 @@ import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
|
|
|
32
34
|
import ConfigRegistry from '@plone/volto/registry';
|
|
33
35
|
|
|
34
36
|
import { getSiteAsyncPropExtender } from '@plone/volto/helpers';
|
|
37
|
+
import { registerValidators } from './validation';
|
|
35
38
|
|
|
36
39
|
const host = process.env.HOST || 'localhost';
|
|
37
40
|
const port = process.env.PORT || '3000';
|
|
@@ -97,7 +100,7 @@ let config = {
|
|
|
97
100
|
process.env.RAZZLE_INTERNAL_API_PATH ||
|
|
98
101
|
process.env.RAZZLE_API_PATH ||
|
|
99
102
|
'http://localhost:8080/Plone', // Set it to '' for disabling the proxy
|
|
100
|
-
// proxyRewriteTarget Set it for set a custom target for the proxy or
|
|
103
|
+
// proxyRewriteTarget Set it for set a custom target for the proxy or override the internal VHM rewrite
|
|
101
104
|
// proxyRewriteTarget: '/VirtualHostBase/http/localhost:8080/Plone/VirtualHostRoot/_vh_api'
|
|
102
105
|
// proxyRewriteTarget: 'https://myvoltositeinproduction.com'
|
|
103
106
|
proxyRewriteTarget: process.env.RAZZLE_PROXY_REWRITE_TARGET || undefined,
|
|
@@ -152,6 +155,7 @@ let config = {
|
|
|
152
155
|
controlPanelsIcons,
|
|
153
156
|
filterControlPanels,
|
|
154
157
|
filterControlPanelsSchema,
|
|
158
|
+
unwantedControlPanelsFields,
|
|
155
159
|
externalRoutes: [
|
|
156
160
|
// URL to be considered as external
|
|
157
161
|
// {
|
|
@@ -167,6 +171,7 @@ let config = {
|
|
|
167
171
|
],
|
|
168
172
|
showSelfRegistration: false,
|
|
169
173
|
contentMetadataTagsImageField: 'image',
|
|
174
|
+
contentPropertiesSchemaEnhancer: null,
|
|
170
175
|
hasWorkingCopySupport: false,
|
|
171
176
|
maxUndoLevels: 200, // undo history size for the main form
|
|
172
177
|
addonsInfo: addonsInfo,
|
|
@@ -209,8 +214,9 @@ let config = {
|
|
|
209
214
|
},
|
|
210
215
|
addonRoutes: [],
|
|
211
216
|
addonReducers: {},
|
|
212
|
-
slots: {},
|
|
213
217
|
components,
|
|
218
|
+
slots: {},
|
|
219
|
+
utilities: {},
|
|
214
220
|
};
|
|
215
221
|
|
|
216
222
|
// The apiExpanders depends on a config of the object, so it's done here
|
|
@@ -238,5 +244,20 @@ ConfigRegistry.addonRoutes = config.addonRoutes;
|
|
|
238
244
|
ConfigRegistry.addonReducers = config.addonReducers;
|
|
239
245
|
ConfigRegistry.components = config.components;
|
|
240
246
|
ConfigRegistry.slots = config.slots;
|
|
247
|
+
ConfigRegistry.utilities = config.utilities;
|
|
248
|
+
|
|
249
|
+
// Register slots
|
|
250
|
+
Object.entries(slots).forEach(([slotName, components]) => {
|
|
251
|
+
components.forEach(({ name, component, predicates = [] }) => {
|
|
252
|
+
ConfigRegistry.registerSlotComponent({
|
|
253
|
+
slot: slotName,
|
|
254
|
+
name,
|
|
255
|
+
component,
|
|
256
|
+
predicates,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
registerValidators(ConfigRegistry);
|
|
241
262
|
|
|
242
263
|
applyAddonConfiguration(ConfigRegistry);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ConfigType } from '@plone/registry';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
minLengthValidator,
|
|
5
|
+
maxLengthValidator,
|
|
6
|
+
urlValidator,
|
|
7
|
+
emailValidator,
|
|
8
|
+
isNumberValidator,
|
|
9
|
+
maximumValidator,
|
|
10
|
+
minimumValidator,
|
|
11
|
+
isIntegerValidator,
|
|
12
|
+
maxItemsValidator,
|
|
13
|
+
minItemsValidator,
|
|
14
|
+
hasUniqueItemsValidator,
|
|
15
|
+
startEventDateRangeValidator,
|
|
16
|
+
endEventDateRangeValidator,
|
|
17
|
+
patternValidator,
|
|
18
|
+
} from '@plone/volto/helpers/FormValidation/validators';
|
|
19
|
+
|
|
20
|
+
const registerValidators = (config: ConfigType) => {
|
|
21
|
+
config.registerUtility({
|
|
22
|
+
name: 'minLength',
|
|
23
|
+
type: 'validator',
|
|
24
|
+
dependencies: { fieldType: 'string' },
|
|
25
|
+
method: minLengthValidator,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
config.registerUtility({
|
|
29
|
+
name: 'maxLength',
|
|
30
|
+
type: 'validator',
|
|
31
|
+
dependencies: { fieldType: 'string' },
|
|
32
|
+
method: maxLengthValidator,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
config.registerUtility({
|
|
36
|
+
name: 'pattern',
|
|
37
|
+
type: 'validator',
|
|
38
|
+
dependencies: { fieldType: 'string' },
|
|
39
|
+
method: patternValidator,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
config.registerUtility({
|
|
43
|
+
name: 'minLength',
|
|
44
|
+
type: 'validator',
|
|
45
|
+
dependencies: { fieldType: 'password' },
|
|
46
|
+
method: minLengthValidator,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
config.registerUtility({
|
|
50
|
+
name: 'maxLength',
|
|
51
|
+
type: 'validator',
|
|
52
|
+
dependencies: { fieldType: 'password' },
|
|
53
|
+
method: maxLengthValidator,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
config.registerUtility({
|
|
57
|
+
name: 'pattern',
|
|
58
|
+
type: 'validator',
|
|
59
|
+
dependencies: { fieldType: 'password' },
|
|
60
|
+
method: patternValidator,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
config.registerUtility({
|
|
64
|
+
name: 'email',
|
|
65
|
+
type: 'validator',
|
|
66
|
+
dependencies: { widget: 'email' },
|
|
67
|
+
method: emailValidator,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
config.registerUtility({
|
|
71
|
+
name: 'url',
|
|
72
|
+
type: 'validator',
|
|
73
|
+
dependencies: { widget: 'url' },
|
|
74
|
+
method: urlValidator,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
config.registerUtility({
|
|
78
|
+
name: 'number',
|
|
79
|
+
type: 'validator',
|
|
80
|
+
dependencies: { fieldType: 'number' },
|
|
81
|
+
method: isNumberValidator,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
config.registerUtility({
|
|
85
|
+
name: 'minimum',
|
|
86
|
+
type: 'validator',
|
|
87
|
+
dependencies: { fieldType: 'number' },
|
|
88
|
+
method: minimumValidator,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
config.registerUtility({
|
|
92
|
+
name: 'maximum',
|
|
93
|
+
type: 'validator',
|
|
94
|
+
dependencies: { fieldType: 'number' },
|
|
95
|
+
method: maximumValidator,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
config.registerUtility({
|
|
99
|
+
name: 'integer',
|
|
100
|
+
type: 'validator',
|
|
101
|
+
dependencies: { fieldType: 'integer' },
|
|
102
|
+
method: isIntegerValidator,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
config.registerUtility({
|
|
106
|
+
name: 'minimum',
|
|
107
|
+
type: 'validator',
|
|
108
|
+
dependencies: { fieldType: 'integer' },
|
|
109
|
+
method: minimumValidator,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
config.registerUtility({
|
|
113
|
+
name: 'maximum',
|
|
114
|
+
type: 'validator',
|
|
115
|
+
dependencies: { fieldType: 'integer' },
|
|
116
|
+
method: maximumValidator,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
config.registerUtility({
|
|
120
|
+
name: 'maxItems',
|
|
121
|
+
type: 'validator',
|
|
122
|
+
dependencies: { fieldType: 'array' },
|
|
123
|
+
method: maxItemsValidator,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
config.registerUtility({
|
|
127
|
+
name: 'minItems',
|
|
128
|
+
type: 'validator',
|
|
129
|
+
dependencies: { fieldType: 'array' },
|
|
130
|
+
method: minItemsValidator,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
config.registerUtility({
|
|
134
|
+
name: 'uniqueItems',
|
|
135
|
+
type: 'validator',
|
|
136
|
+
dependencies: { fieldType: 'array' },
|
|
137
|
+
method: hasUniqueItemsValidator,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
config.registerUtility({
|
|
141
|
+
name: 'dateRangeValidator',
|
|
142
|
+
type: 'validator',
|
|
143
|
+
dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'start' },
|
|
144
|
+
method: startEventDateRangeValidator,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
config.registerUtility({
|
|
148
|
+
name: 'dateRangeValidator',
|
|
149
|
+
type: 'validator',
|
|
150
|
+
dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'end' },
|
|
151
|
+
method: endEventDateRangeValidator,
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { registerValidators };
|
|
@@ -161,7 +161,7 @@ export function addBlock(formData, type, index, blocksConfig) {
|
|
|
161
161
|
|
|
162
162
|
return [
|
|
163
163
|
id,
|
|
164
|
-
|
|
164
|
+
applyBlockInitialValue({
|
|
165
165
|
id,
|
|
166
166
|
value,
|
|
167
167
|
blocksConfig,
|
|
@@ -197,8 +197,12 @@ export function addBlock(formData, type, index, blocksConfig) {
|
|
|
197
197
|
* to call `onChangeBlock` at their creation time, as this is prone to racing
|
|
198
198
|
* issue on block data storage.
|
|
199
199
|
*/
|
|
200
|
-
const
|
|
201
|
-
|
|
200
|
+
export const applyBlockInitialValue = ({
|
|
201
|
+
id,
|
|
202
|
+
value,
|
|
203
|
+
blocksConfig,
|
|
204
|
+
formData,
|
|
205
|
+
}) => {
|
|
202
206
|
const type = value['@type'];
|
|
203
207
|
blocksConfig = blocksConfig || config.blocks.blocksConfig;
|
|
204
208
|
|
|
@@ -208,6 +212,7 @@ const _applyBlockInitialValue = ({ id, value, blocksConfig, formData }) => {
|
|
|
208
212
|
value,
|
|
209
213
|
formData,
|
|
210
214
|
});
|
|
215
|
+
const blocksFieldname = getBlocksFieldname(formData);
|
|
211
216
|
formData[blocksFieldname][id] = value;
|
|
212
217
|
}
|
|
213
218
|
|
|
@@ -238,7 +243,7 @@ export function mutateBlock(formData, id, value, blocksConfig) {
|
|
|
238
243
|
const trailId = formData[blocksLayoutFieldname].items[index];
|
|
239
244
|
if (trailId) {
|
|
240
245
|
const block = formData[blocksFieldname][trailId];
|
|
241
|
-
newFormData =
|
|
246
|
+
newFormData = applyBlockInitialValue({
|
|
242
247
|
id,
|
|
243
248
|
value,
|
|
244
249
|
blocksConfig,
|
|
@@ -256,7 +261,7 @@ export function mutateBlock(formData, id, value, blocksConfig) {
|
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
const idTrailingBlock = uuid();
|
|
259
|
-
newFormData =
|
|
264
|
+
newFormData = applyBlockInitialValue({
|
|
260
265
|
id,
|
|
261
266
|
value,
|
|
262
267
|
blocksConfig,
|
|
@@ -307,8 +312,8 @@ export function insertBlock(
|
|
|
307
312
|
});
|
|
308
313
|
|
|
309
314
|
const newBlockId = uuid();
|
|
310
|
-
const newFormData =
|
|
311
|
-
id,
|
|
315
|
+
const newFormData = applyBlockInitialValue({
|
|
316
|
+
id: newBlockId,
|
|
312
317
|
value,
|
|
313
318
|
blocksConfig,
|
|
314
319
|
formData: {
|
|
@@ -511,6 +511,21 @@ describe('Blocks', () => {
|
|
|
511
511
|
});
|
|
512
512
|
});
|
|
513
513
|
|
|
514
|
+
it('initializes data for new block with initialValue in insertBlock', () => {
|
|
515
|
+
const [newId, form] = insertBlock(
|
|
516
|
+
{
|
|
517
|
+
blocks: { a: { value: 1 }, b: { value: 2 } },
|
|
518
|
+
blocks_layout: { items: ['a', 'b'] },
|
|
519
|
+
},
|
|
520
|
+
'b',
|
|
521
|
+
{ '@type': 'dummyText' },
|
|
522
|
+
);
|
|
523
|
+
expect(form.blocks[newId]).toStrictEqual({
|
|
524
|
+
'@type': 'dummyText',
|
|
525
|
+
marker: true,
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
|
|
514
529
|
it('initializes data for new block based on schema defaults', () => {
|
|
515
530
|
const [newId, form] = addBlock(
|
|
516
531
|
{
|
|
@@ -51,7 +51,7 @@ export function resolveExtension(name, extensions, data) {
|
|
|
51
51
|
* - extensions is the blocksConfig extensions object for that block
|
|
52
52
|
* - resolvedExtensions is an object with
|
|
53
53
|
* `{ variation, <someExtensionA>, <someExtensionB> }` and each of these
|
|
54
|
-
* fields hold the
|
|
54
|
+
* fields hold the corresponding definition object from the block's
|
|
55
55
|
* configuration.
|
|
56
56
|
*/
|
|
57
57
|
export function resolveBlockExtensions(data, blocksConfig) {
|