cancel
Showing results for 
Search instead for 
Did you mean: 

Share - multi-select (selected items) actions based on current site

l_hobza
Champ in-the-making
Champ in-the-making

Hi,
I need to add one action (and remove other) to multi-select but only if user is in particular site. With normal DocLibActions this is easy - you just add evaluator but multi-select actions do not support custom evaluators. There are some "evaluators" which could be used for multi-select actions (for e.g., hasAspect) but nothing that would help me.

Do I need to override whole multi-select component to achieve this? And if I do are there any examples of that?

I am using ACS 5.2

1 ACCEPTED ANSWER

abhinavmishra14
World-Class Innovator
World-Class Innovator

Evaluators for multiselect would have been cleaner option, but Unfortunately evaluators doesn't work for multi-select actions like doclib actions. 

permission,notAspect,hasAspect etc. could be helpful in some cases but to your specific case it will not work.

You need to extend toolbar webscript and mainly extend the toolbar.js

https://github.com/Alfresco/share/blob/master/share/src/main/resources/alfresco/site-webscripts/org/...

Your customized toolbar.js will be replaced here:

https://github.com/Alfresco/share/blob/master/share/src/main/resources/alfresco/site-webscripts/org/...

e.g.

<@markup id="custom-js" target="js" action="replace">
   <#-- JavaScript Dependencies -->
   <#-- Overridden toolbar.js -->
   <@script src="${url.context}/res/components/profile/toolbar-custom.js" group="profile"/>
</@>


In toolbar.js, you would have to add a customlogic to test the sitepreset or siteshortName based on selected nodes and restrict the actions as needed.

https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/toolb...

https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/toolb...

You would also be needing a repository webscript that will use SiteService to get the siteInfo -> siteShortName/sitePreset based on an input nodeRef.

files[0].nodeRef -> would give you the nodeRef that can be used for repository layer webscript to get the siteshortname back in reponse.

Checkout these docs for more on extending ootb components:

https://docs.alfresco.com/content-services/5.2/develop/share-ext-points/surf-extension-modules/

https://docs.alfresco.com/content-services/5.2/develop/share-ext-points/modify-ootb-code/

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

4 REPLIES 4

abhinavmishra14
World-Class Innovator
World-Class Innovator

Evaluators for multiselect would have been cleaner option, but Unfortunately evaluators doesn't work for multi-select actions like doclib actions. 

permission,notAspect,hasAspect etc. could be helpful in some cases but to your specific case it will not work.

You need to extend toolbar webscript and mainly extend the toolbar.js

https://github.com/Alfresco/share/blob/master/share/src/main/resources/alfresco/site-webscripts/org/...

Your customized toolbar.js will be replaced here:

https://github.com/Alfresco/share/blob/master/share/src/main/resources/alfresco/site-webscripts/org/...

e.g.

<@markup id="custom-js" target="js" action="replace">
   <#-- JavaScript Dependencies -->
   <#-- Overridden toolbar.js -->
   <@script src="${url.context}/res/components/profile/toolbar-custom.js" group="profile"/>
</@>


In toolbar.js, you would have to add a customlogic to test the sitepreset or siteshortName based on selected nodes and restrict the actions as needed.

https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/toolb...

https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/toolb...

You would also be needing a repository webscript that will use SiteService to get the siteInfo -> siteShortName/sitePreset based on an input nodeRef.

files[0].nodeRef -> would give you the nodeRef that can be used for repository layer webscript to get the siteshortname back in reponse.

Checkout these docs for more on extending ootb components:

https://docs.alfresco.com/content-services/5.2/develop/share-ext-points/surf-extension-modules/

https://docs.alfresco.com/content-services/5.2/develop/share-ext-points/modify-ootb-code/

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Thank you so much for your detailed solution! I managed to get it working. Instead of making the repository webscript for getting the current site I am checking if the current URL is containing the substring: /site/<site_name>/documentlibrary It seemes to me like a more performant solution since no call to Alfresco repository is needed.

abhinavmishra14
World-Class Innovator
World-Class Innovator

@l_hobza wrote:

Thank you so much for your detailed solution! I managed to get it working. Instead of making the repository webscript for getting the current site I am checking if the current URL is containing the substring: /site/<site_name>/documentlibrary It seemes to me like a more performant solution since no call to Alfresco repository is needed.


Glad to hear that it worked for you. Yes that's smart option if you have a list of specific sites. If you want to rely on site types (site-presets) then you can always switch to repo call if required.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Are you sure that we can use evaluators on multi-selects? Because i read that's impossible.