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
Solved! Go to Solution.
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
Your customized toolbar.js will be replaced here:
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.
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/
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
Your customized toolbar.js will be replaced here:
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.
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/
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.
@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.
Are you sure that we can use evaluators on multi-selects? Because i read that's impossible.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.