Custom Action in Share

I`ll extract the information from here; http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf  and here: http://wiki.alfresco.com/wiki/Custom_Actions
This post = just to be able to quickly grab the files I need to change to add more buttons.

In the Share project (part of the my personal Eclipse setup)

/web/share/components/documentlibrary/recalculate-workflow-action.css

CONTENT:
.doclist .onActionXopus a {    background-image: url(plaatje-16.gif) !important; }

/web/share/components/documentlibrary/recalculate-workflow-action.js

CONTENT:

/** DocumentList “Recalculate Workflow ” action **/
(function() {
Alfresco.doclib.Actions.prototype.onActionRecalculateWorkflow = function DL_onActionRecalculateWorkflow(asset)  {
nodeRef = new Alfresco.util.NodeRef(asset.nodeRef);
alert(“comment MJB=” + file.nodeRef);
}
} )  ( ) ;

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/actions-common.get.head.ftl

…..add this line …..
<#– WF Action –>
<@link rel=”stylesheet” type=”text/css” href=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.css” />
<script type=”text/javascript” src=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.js”></script>
……………………………..

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/documentlist.get.config.xml

…..add this line …..
<action type=”action-link” id=”onActionRecalculateWorkflow” permission=”edit” label=”actions.document.recalculateWorkflow” />
…………………………

 

… there is still something missing here….

..  i’ll figure that out soon….

Custom Actions

I added two custom actions to my alfresco environment. This was (relatively) easy to do;

(1) Add the actions you want to  web-client-config-custom.xml

...
<actions>

<action id="CreateMessage">
<permissions> <permission allow="true">Write</permission> </permissions>
<label>CreateMessage</label>
<image>/images/icons/email_users_large.gif</image>
<script>/Company Home/Data Dictionary/Scripts/CreateMessage.js</script>
<params> <param name="nodeRef">#{actionContext.nodeRef}</param> </params>
</action>

<action id="SendMessages">
<permissions> <permission allow="true">Write</permission> </permissions>
<label>SendMessages</label>
<image>/images/icons/check_out_large.gif</image>
<script>/Company Home/Data Dictionary/Scripts/SendMessages.js</script>
<params> <param name="nodeRef">#{actionContext.nodeRef}</param> </params>
</action>	

<action-group id="space_details_actions">
<action idref="CreateMessage" />
<action idref="SendMessages" />
</action-group>

<action-group id="space_browse_menu">
<action idref="CreateMessage" />
<action idref="SendMessages" />
</action-group>

</actions>

(2) Update your scripts.

– Add this to the beginning of your script

nodeRef = args["nodeRef"];
var space = search.findNode(nodeRef);

– Add this to the end of your script

var goBack = "<script>history.back();</script>";
goBack;

That should be enough to make little icons in the details of a space, which will fire of the scripts named here.