From 7f1ae9c61c9a1fac33b183aae04557f1e845ce35 Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:00:02 +0200 Subject: [PATCH 1/7] Add numberOfFolderishDocuments catalog metadata to allow UX affordance in folder contents in Volto. --- news/numberOfFolderishDocuments.feature | 2 ++ src/plone/volto/configure.zcml | 4 ++++ src/plone/volto/indexers.py | 16 ++++++++++++++++ src/plone/volto/profiles/default/catalog.xml | 1 + src/plone/volto/profiles/default/metadata.xml | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 news/numberOfFolderishDocuments.feature diff --git a/news/numberOfFolderishDocuments.feature b/news/numberOfFolderishDocuments.feature new file mode 100644 index 00000000..83aeb0b0 --- /dev/null +++ b/news/numberOfFolderishDocuments.feature @@ -0,0 +1,2 @@ +- Add numberOfFolderishDocuments catalog metadata to allow UX affordance in folder contents in Volto. + [jaroel] diff --git a/src/plone/volto/configure.zcml b/src/plone/volto/configure.zcml index 84dec901..3e1b7cef 100644 --- a/src/plone/volto/configure.zcml +++ b/src/plone/volto/configure.zcml @@ -45,6 +45,10 @@ zcml:condition="not-have plone-60" /> + + diff --git a/src/plone/volto/profiles/default/metadata.xml b/src/plone/volto/profiles/default/metadata.xml index f746bae4..f32183b5 100644 --- a/src/plone/volto/profiles/default/metadata.xml +++ b/src/plone/volto/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 1016 + 1017 profile-plone.restapi:blocks From bdc3c4f45ff9ff8cad3fc4a498ba2cc6874fc9ab Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:19:21 +0200 Subject: [PATCH 2/7] lint --- src/plone/volto/indexers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index 72802225..d52617e2 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -16,7 +16,7 @@ def numberOfFolderishDocuments(obj): catalog = getToolByName(obj, 'portal_catalog') query = { 'object_provides': IFolderishDocument.__identifier__, - 'path': {'query':"/".join(obj.getPhysicalPath()), 'depth': 1}} + 'path': {'query': '/'.join(obj.getPhysicalPath()), 'depth': 1}} return len(catalog.unrestrictedSearchResults(query)) From da513137ff3a2a65af92500589853110c21df82e Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:23:28 +0200 Subject: [PATCH 3/7] black --- src/plone/volto/indexers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index d52617e2..fcb7271a 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -13,10 +13,11 @@ def numberOfFolderishDocuments(obj): How many FolderishDocument are contained in the FolderishDocument obj. For UX affordance to show which pages aren't leaf nodes. """ - catalog = getToolByName(obj, 'portal_catalog') + catalog = getToolByName(obj, "portal_catalog") query = { - 'object_provides': IFolderishDocument.__identifier__, - 'path': {'query': '/'.join(obj.getPhysicalPath()), 'depth': 1}} + "object_provides": IFolderishDocument.__identifier__, + "path": {"query": "/".join(obj.getPhysicalPath()), "depth": 1}, + } return len(catalog.unrestrictedSearchResults(query)) From fe87824b1dec8a195f9473b064e302f410b93e11 Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:26:40 +0200 Subject: [PATCH 4/7] isort --- src/plone/volto/indexers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index fcb7271a..195bcce5 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -1,10 +1,9 @@ from Acquisition import aq_base -from Products.CMFCore.utils import getToolByName - from plone.dexterity.interfaces import IDexterityContent from plone.indexer.decorator import indexer from plone.volto.behaviors.preview import IPreview from plone.volto.interfaces import IFolderishDocument +from Products.CMFCore.utils import getToolByName @indexer(IFolderishDocument) From 1aae57c4592e516e8616eed3b360b442eb35a2f7 Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:44:23 +0200 Subject: [PATCH 5/7] Any old DX Container is indicative of a branch node. --- src/plone/volto/indexers.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index 195bcce5..c3169d07 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -1,24 +1,17 @@ from Acquisition import aq_base + from plone.dexterity.interfaces import IDexterityContent from plone.indexer.decorator import indexer from plone.volto.behaviors.preview import IPreview from plone.volto.interfaces import IFolderishDocument -from Products.CMFCore.utils import getToolByName @indexer(IFolderishDocument) def numberOfFolderishDocuments(obj): """ - How many FolderishDocument are contained in the FolderishDocument obj. For UX affordance to show which pages aren't leaf nodes. """ - catalog = getToolByName(obj, "portal_catalog") - query = { - "object_provides": IFolderishDocument.__identifier__, - "path": {"query": "/".join(obj.getPhysicalPath()), "depth": 1}, - } - return len(catalog.unrestrictedSearchResults(query)) - + return len(obj.objectIds(spec=obj.meta_type, ordered=False)) @indexer(IPreview) def hasPreviewImage(obj): From 59263845ce10fd7d76039c0b582f1accd91ad537 Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 17:46:48 +0200 Subject: [PATCH 6/7] black --- src/plone/volto/indexers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index c3169d07..aa8b31d4 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -13,6 +13,7 @@ def numberOfFolderishDocuments(obj): """ return len(obj.objectIds(spec=obj.meta_type, ordered=False)) + @indexer(IPreview) def hasPreviewImage(obj): """ From bfb811c9d42816db3a1dbdcd26c01a08491b16e7 Mon Sep 17 00:00:00 2001 From: Roel Bruggink Date: Tue, 16 May 2023 18:18:40 +0200 Subject: [PATCH 7/7] isort --- src/plone/volto/indexers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plone/volto/indexers.py b/src/plone/volto/indexers.py index aa8b31d4..f825623e 100644 --- a/src/plone/volto/indexers.py +++ b/src/plone/volto/indexers.py @@ -1,5 +1,4 @@ from Acquisition import aq_base - from plone.dexterity.interfaces import IDexterityContent from plone.indexer.decorator import indexer from plone.volto.behaviors.preview import IPreview