3

I am a newbie to the alfresco. I am trying to do following task in alfresco and reflect the modification in alfresco share. what I am trying to do is create a new rule-action called XCopy this would identical to the copy function. the only different is the name. It should be possible to attach with a rule defined for a given folder and should accept a file location to be copied.

I am ok with the spring configuration in alfresco module. but I am confused with the share module configuration. Can anybody suggest me a way to add my custom action to the share ? Thanks.

Kanishka Dilshan
  • 724
  • 2
  • 10
  • 19

1 Answers1

4

You have to customize rule-config-action.get.config.xml located at site-webscripts\org\alfresco\components\rules\config by copying the same file to web-extension with same folder structure. Add your custom action in <menu><group> and then in <customise>. say,

<group>
   <action name="copy"/>
   <action name="move"/>
    <action name="xcopy"/>
</group>
<customise>
      <item id="select">Select</item>
       ......
      <action name="copy">Copy</action>
      <action name="move">Move</action>
      <action name="xcopy">CreateLinkToDocument</action>    <!--xcopy should be id of spring bean configured as action-executer -->
</customise>

Add custom javascript js in rule-details.get.head.ftl and rule-edit.get.head.ftl

<!--Custom javascript file include for detail mode -->
<@script type="text/javascript" src="${page.url.context}/test/components/rules/config/rule-config-action-custom.js"></@script>

create rule-config-action-custom.js in test/components/rules/config folder under share root folder

Add below code to if for opening file selector in Share,

if (typeof SomeCo == "undefined" || !SomeCo)
{
   var SomeCo = {};
}

/**
 * RuleConfigActionCustom.
 *
 * @namespace SomeCo
 * @class SomeCo.RuleConfigActionCustom
 */
(function()
{

   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom,
      Selector = YAHOO.util.Selector,
      Event = YAHOO.util.Event;

   /**
    * Alfresco Slingshot aliases
    */
    var $html = Alfresco.util.encodeHTML,
       $hasEventInterest = Alfresco.util.hasEventInterest;

   SomeCo.RuleConfigActionCustom = function(htmlId)
   {
      SomeCo.RuleConfigActionCustom.superclass.constructor.call(this, htmlId);

      // Re-register with our own name
      this.name = "SomeCo.RuleConfigActionCustom";
      Alfresco.util.ComponentManager.reregister(this);

      // Instance variables
      this.customisations = YAHOO.lang.merge(this.customisations, SomeCo.RuleConfigActionCustom.superclass.customisations);
      this.renderers = YAHOO.lang.merge(this.renderers, SomeCo.RuleConfigActionCustom.superclass.renderers);

      return this;
   };

   YAHOO.extend(SomeCo.RuleConfigActionCustom, Alfresco.RuleConfigAction,
   {

      /**
       * CUSTOMISATIONS
       */

      customisations:
      {         
          CreateLinkToDocument:
         {
            text: function(configDef, ruleConfig, configEl)
            {
                 // Display as path
                 this._getParamDef(configDef, "destination-folder")._type = "path";
                 return configDef;
            },
            edit: function(configDef, ruleConfig, configEl)
            {
                // Hide all parameters since we are using a cusotm ui but set default values
                this._hideParameters(configDef.parameterDefinitions);

                // Make parameter renderer create a "Destination" button that displays an destination folder browser
                configDef.parameterDefinitions.push({
                   type: "arca:destination-dialog-button",
                   displayLabel: this.msg("label.to"),
                   _buttonLabel: this.msg("button.select-folder"),
                   _destinationParam: "destination-folder"
                });
                return configDef;
            }
         },
      },

   });

})();

Check this for reference: http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf

Please let me know in case you need any more help for the same

Zlatko
  • 18,936
  • 14
  • 70
  • 123
Pritesh Shah
  • 857
  • 1
  • 7
  • 8