cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend existing Share activity-list dashlet?

pl_componize
Champ in-the-making
Champ in-the-making
In Community 4.0.a, I'm posting my custom activities in the repo following this: http://wiki.alfresco.com/wiki/3.0_Activities_Developer_Guide

I have defined my own activity type, with custom bundles and pagelink to display custom needs in the activity dashlet.
But I face an issue, I need to specialize the output based on the activity-type in a similar way of what is done already in activity-list.get.js in the specialize() function.

I can't hack the js cause I'm packaging things in my own amp for Share. Is there a way for me to extend this dashlet, or do I have to write my own?
It's hard for me to believe they provided an API to post a custom activity but yet you can't display it properly in the existing dashlet, so I'm looking for what I've missed here.
3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator
In version 4.0 you can now customize JavaScript controllers for WebScripts to modify the content model (see http://blogs.alfresco.com/wp/ddraper/2011/08/05/customizing-alfresco-share-javascript-controllers/) this should allow you to update the model that is passed to the FreeMarker template prior to rendering.

If this isn't sufficient and you wanted to create your own custom dashlet there is of course no reason why you couldn't use the YUI extension capabilities to build on the existing code without having to start from scratch.

Regards,
Dave

pl_componize
Champ in-the-making
Champ in-the-making
Hi Dave,

Thanks for the link. I've successfully added my custom activity type and extended the controller (activity-list.get.js) as explained in your blog post to make my modifications.

There is still one challenge left to me, is it possible to extend the css configuration file: activity-list.get.config.xml to map my own activity type for an existing css?

I want to add : <style type="com.my-company.module.custom-activity-type" css="document" />

ddraper
World-Class Innovator
World-Class Innovator
Yes, there's a couple of ways in which you can do this:

One option would be to add your new CSS dependency by customizing the "resources" <@markup> directive that is declared in the resources.get.html.ftl WebScript. You can add a new import or link statements either by replacing the default contents (which are empty) or adding a new directive before or after (see http://blogs.alfresco.com/wp/ddraper/2011/08/12/customizing-alfresco-share-freemarker-templates/). The disadvantage of this approach would be that your CSS resource is loaded for every page.

An alternative approach (which I haven't blogged about yet) would be to use the <dependencies> element in a customization. This allows new CSS or JavaScript dependencies to be added when particular packages are requested. For example, to add a new CSS dependency when the activity-list webscript is used you could add the following customization:

<extension>
    <modules>
        <module>
            <id>Add CSS for activity list</id>
            <evaluator>default.extensibility.evaluator</evaluator>
            <customizations>
                <customization>
                    <targetPackageRoot>org.alfresco.components.dashlets</targetPackageRoot>
                    <sourcePackageRoot>custom.package</sourcePackageRoot>
                    <dependencies>
                        <css>/res/dependencies/new-dependency.css</css>
                    </dependencies>
           </customization>
            </customizations>
        </module>
   </modules>
</extension>

The specified CSS resource would be imported whenever anything in the dashlets package is used (so not tied exclusively to the activity-list WebScript, but not global). Hopefully I'll get the chance to blog about this capability soon to provide more details instructions !

Let me know if you have any problems with this,

Regards,
Dave