Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions docs/source/blocks/editcomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,59 @@ form.widget(
);
```

#### `onlyFolderishSelectable`

If `onlyFolderishSelectable` is set to `true` in `widgetOptions.pattern_options`, only folderish (container) items can be selected. This is useful when you want users to select only folders or other container-type content.

```jsx
<ObjectBrowserWidget ... widgetOptions={{pattern_options:{onlyFolderishSelectable:true}}}>
```

You can also set the `onlyFolderishSelectable` from `plone` when declaring a field for `contenttype`:

```jsx
form.widget(
'location',
RelatedItemsFieldWidget,
(vocabulary = 'plone.app.vocabularies.Catalog'),
(pattern_options = {
onlyFolderishSelectable: true,
}),
);
```

You can combine `onlyFolderishSelectable` with other options like `selectableTypes` and `maximumSelectionSize`:

```jsx
form.widget(
'location',
RelatedItemsFieldWidget,
(vocabulary = 'plone.app.vocabularies.Catalog'),
(pattern_options = {
onlyFolderishSelectable: true,
selectableTypes: ['Folder'],
maximumSelectionSize: 1,
}),
);
```

#### Direct prop passing to ObjectBrowserWidget

You can also pass `onlyFolderishSelectable`, `selectableTypes`, and `maximumSelectionSize` directly as props to the `ObjectBrowserWidget` component (in addition to or instead of using `widgetOptions.pattern_options`):

```jsx
<ObjectBrowserWidget
id="location"
mode="link"
onChange={(id, data) => console.log(data)}
onlyFolderishSelectable={true}
selectableTypes={['Folder']}
maximumSelectionSize={1}
/>
```

This approach is useful when you're using `ObjectBrowserWidget` directly in your components rather than through the schema-driven form system. The widget will prioritize values from `widgetOptions.pattern_options` if both are provided.

## Reusing the blocks engine in your components

You can render a blocks engine form with the `BlocksForm` component.
Expand Down
87 changes: 84 additions & 3 deletions packages/volto/cypress/tests/core/blocks/listing/blocks-listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,34 @@ describe('Listing Block Tests', () => {
cy.addNewBlock('listing');

//******** add relative location criteria filter
cy.addLocationQuerystring('Relative path', '../my-folder');
// cy.addLocationQuerystring('Relative path', '../my-folder');
cy.get('.block-editor-listing').click();
cy.get('.querystring-widget .fields').contains('Add criteria').click();
cy.get('.querystring-widget .react-select__menu .react-select__option')
.contains('Location')
.click();

cy.get(
'#sidebar-properties #default-query-0-querystring #field-query-0-querystring',
)
.eq(1)
.click();

cy.get(
'.querystring-widget .fields:first-of-type .main-fields-wrapper .field:last-of-type .react-select__menu .react-select__option',
)
.contains('Relative path')
.click();

//insert relative path
cy.get(
'.querystring-widget .fields:first-of-type > .field:last-of-type',
).click();
cy.get(
'.querystring-widget .fields:first-of-type > .field:last-of-type .react-select__menu .react-select__option',
)
.contains('./')
.click();

// verify if in list there's a page with name "Document within Folder"
cy.get(`.block.listing .listing-body:first-of-type`).contains(
Expand Down Expand Up @@ -669,6 +696,12 @@ describe('Listing Block Tests', () => {
contentTitle: 'Document within Folder',
path: 'my-page/my-folder',
});
cy.createContent({
contentType: 'Image',
contentId: 'my-image',
contentTitle: 'My Image',
path: 'my-page/my-folder',
});

cy.navigate('/my-page/my-folder');
cy.wait('@content');
Expand All @@ -684,7 +717,29 @@ describe('Listing Block Tests', () => {
cy.addNewBlock('listing');

//******** add absolute location criteria filter
cy.addLocationQuerystring('Absolute path', '/my-page/my-folder');
// cy.addLocationQuerystring('Absolute path', '/my-page/my-folder');
cy.get('.block-editor-listing').click();
cy.get('.querystring-widget .fields').contains('Add criteria').click();
cy.get('.querystring-widget .react-select__menu .react-select__option')
.contains('Location')
.click();

cy.get('.querystring-widget .fields').contains('Absolute path').click();

cy.get(
'#sidebar-properties #default-query-0-querystring div[aria-labelledby="fieldset-default-field-label-query-reference-widget-0"] button[aria-label="Open object browser"]',
).click({ force: true });

cy.get(
'.sidebar-container.sidebar-container-enter-done .object-listing li[aria-label="Select My Image"]',
).should('have.class', 'disabled');

//insert absolute path
cy.get('.sidebar-container button[aria-label="Search SVG"]').click();
cy.get(
'.sidebar-container .input.search input[placeholder="Search content"]',
).type('My Folder');
cy.get('[aria-label="Select My Folder"]').dblclick();

// verify if in list there's a page with name "Document within Folder"
cy.get(`.block.listing .listing-body:first-of-type`).contains(
Expand Down Expand Up @@ -759,7 +814,33 @@ describe('Listing Block Tests', () => {
cy.addNewBlock('listing');

//******** add location criteria filter
cy.addLocationQuerystring('Relative path', '.');
cy.get('.block-editor-listing').click();
cy.get('.querystring-widget .fields').contains('Add criteria').click();
cy.get('.querystring-widget .react-select__menu .react-select__option')
.contains('Location')
.click();

cy.get(
'#sidebar-properties #default-query-0-querystring #field-query-0-querystring',
)
.eq(1)
.click();

cy.get(
'.querystring-widget .fields:first-of-type .main-fields-wrapper .field:last-of-type .react-select__menu .react-select__option',
)
.contains('Relative path')
.click();

//insert relative path
cy.get(
'.querystring-widget .fields:first-of-type > .field:last-of-type',
).click();
cy.get(
'.querystring-widget .fields:first-of-type > .field:last-of-type .react-select__menu .react-select__option',
)
.contains('./')
.click();

// verify if in list there's a page with name "Document within Folder"
cy.get(`.block.listing .listing-body:first-of-type`).contains(
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/af/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/ar/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/bg/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/bn/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/ca/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4936,6 +4936,16 @@ msgstr "privat"
msgid "published"
msgstr "Publicat"

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/cs/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/cy/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/da/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4936,6 +4936,16 @@ msgstr "Privat"
msgid "published"
msgstr "Veröffentlicht"

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr "Aktueller Pfad (./)"

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr "Übergeordneter Pfad (../)"

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/el/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4930,6 +4930,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/en_AU/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/en_GB/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4935,6 +4935,16 @@ msgstr ""
msgid "published"
msgstr ""

#. Default: "Current path (./)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-currentPath"
msgstr ""

#. Default: "Parent path (../)"
#: components/manage/Widgets/QueryWidget
msgid "query-widget-parentPath"
msgstr ""

#. Default: "Select…"
#: components/manage/Widgets/QueryWidget
msgid "querystring-widget-select"
Expand Down
Loading