AnsweredAssumed Answered

Customize the Share configuration "rule-config-action.get.config.xml"

Question asked by 4535992 on Nov 7, 2018

Hi need to  filter the actions on the dropdown of the actions on the "Create new rule" action.

 

So basically i want to ovverride the file:

 

/opt/alfresco-community/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/config/rule-config-action.get.config.xml

 

 but i can't figure out how do that !!!!!!!!!!!!!!!!!!!!!!!

 

Here some screenshot to make more clear my purpose.

 

I'm using Alfresco Community 5.2 with the SDK 3.0.0.

I based this example on the documentation http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf 

 

So first step i start the action"Create new rule" on share:

 

 

 

For a simple example i just want to remove all my actions and leave only the Alfresco default action.

here my code for accomplish this:

STEP (1)

// --------------------------------------------------------------------------------------------------------------------------------------------------

COPIED THE FOLLOWING FILES WEBSCRIPT ON TO MY PROJECT FROM FOLDER

 

FOLDER SHARE:

/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/

 

/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get.desc.xml
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get.head.ftl
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get.html.ftl
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get.js
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_de.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_en.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_es.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_fr.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_it.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_ja.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_nb.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_nl.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_pt_BR.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_ru.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-details.get_zh_CN.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get.desc.xml
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get.head.ftl
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get.html.ftl
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get.js
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_de.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_en.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_es.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_fr.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_it.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_ja.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_nb.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_nl.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_pt_BR.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_ru.properties
/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/rule-edit.get_zh_CN.properties

 

TO MY SHARE PROJECT FOLDER

 

FOLDER MY PROJECT SHARE :

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/

 

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.desc.xml
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.head.ftl
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.html.ftl
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.js
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_de.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_en.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_es.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_fr.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_it.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_ja.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_nb.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_nl.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_pt_BR.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_ru.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get_zh_CN.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.desc.xml
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.head.ftl
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.html.ftl
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.js
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_de.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_en.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_es.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_fr.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_it.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_ja.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_nb.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_nl.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_pt_BR.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_ru.properties
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get_zh_CN.properties

// --------------------------------------------------------------------------------------------------------------------------------------------------

 

STEP (2)

// -------------------------------------------------------------------------------------------------------------------------------------------

Customize the "RuleConfigActionCustom" with a extension javascript on my project:

 

FOLDER MY PROJECT SHARE :

/<SHARE_PROJECT>/src/main/resources/META-INF/resources/service-custom/components/rules/config/rule-config-action-custom.js

// -------------------------------------------------------------------------------------------------------------------------------------------

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

 

}

 

/**
 * RuleConfigActionCustom.
 * @href http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf
 * @namespace YourCompany
 * @class YourCompany.RuleConfigActionCustom
 */
(function()
{
   ExtAlf.RuleConfigActionCustom = function(htmlId)
   {
      ExtAlf.RuleConfigActionCustom.superclass.constructor.call(this, htmlId);

 

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

 

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

 

      return this;
   };

 

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

      //DO SOMETHING WITH JAVASCRIPT

   });

 

})();

// -------------------------------------------------------------------------------------------------------------------------------------------

STEP (3)

// --------------------------------------------------------------------------------------------------------------------------------------------------

Modify the webscripts files copied on the step (1) by adding the referecne to the new javascript:

========================================================================================

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-details.get.html.ftl

 

<@markup id="js">
   <#-- JavaScript Dependencies -->
   ........................
   <!-- CUSTOM JAVASCRIPT -->
   <@script src="${url.context}/res/service-custom/components/rules/config/rule-config-action-custom.js" group="rules"/>
</@>

 

<@markup id="widgets">
   <@createWidgets group="rules"/>
</@>

 

..............................

====================================================================================
/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/rule-edit.get.html.ftl

 

<@markup id="js">
   <#-- JavaScript Dependencies -->
   ........................
   <!-- CUSTOM JAVASCRIPT -->
   <@script src="${url.context}/res/service-custom/components/rules/config/rule-config-action-custom.js" group="rules"/>
</@>

 

<@markup id="widgets">
   <@createWidgets group="rules"/>
</@>

 

..............................

====================================================================================

// --------------------------------------------------------------------------------------------------------------------------------------------------

STEP (4)

// --------------------------------------------------------------------------------------------------------------------------------------------------

FINALLY COPY THE FILE  rule-config-action.get.config.xml FROM SHARE TO MY PROJECT

PATH SHARE

/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/rules/config/rule-config-action.get.config.xml

 

to

 

PATH MY PROJECT SHARE

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/custom/org/alfresco/components/rules/config/rule-config-action.get.config.xml

 

AND MODIFY WITH THE FOLLOWING

 

// -------------------------------------------------------------------------------------------------------------------------------------------

<rule-config type="action">

 

    <!-- This defines the client-side JavaScript widget to instantiate -->
    <component>ExtAlf.RuleConfigActionCustom</component>
    
    <!-- The "webscript" attribute defines a repository WebScript from which
        to retrieve some data. The remove element will be processed to remove any
        matching elements from the return data. -->
    <config-definitions webscript="/api/actiondefinitions">
        <!-- Public Action Definitions that we don't want displayed in the menu -->
        <!-- ADD CUSTOMIZE ACTION TO HIDE -->
        <remove>
            <action name="copy-to-web-project" />
            <action name="blog-post" />    
        </remove>
    </config-definitions>

 

    <constraints webscript="/api/actionConstraints" />

 

    <menu>
        <group>
            <item id="select" />
        </group>
        <group>
            <action name="script" />
        </group>
        <group>
            <action name="copy" />
            <action name="move" />
        </group>
        <group>
            <action name="check-in" />
            <action name="check-out" />
        </group>
        <group>
            <action name="tag" />
            <action name="link-category" />
        </group>
        <group>
            <action name="add-features" />
            <action name="remove-features" />
        </group>
        <group>
            <action name="simple-workflow" />
        </group>
        <group>
            <action name="mail" />
        </group>
        <group>
            <action name="transform" />
            <action name="transform-image" />
        </group>
        <group>
            <action name="extract-metadata" />
        </group>
        <group>
            <action name="create-thumbnail" />
        </group>
        <group>
            <action name="import" />
        </group>
        <group>
            <action name="specialise-type" />
        </group>
        <group>
            <action name="counter" />
        </group>
        
        <group>
            <action name="set-property-value" />
        </group>

 

        <!-- HERE WHAT I NEED TO MAKE JUST COMMENT THIS PART  -->
        <!--  
        <group>
            <action name="*" />
        </group>
        -->
    </menu>

 

    <customise>
        
        <item id="select">Select</item>
        <action name="specialise-type">SpecialiseType</action>
        <action name="add-features">AddFeatures</action>
        <action name="remove-features">RemoveFeatures</action>
        <action name="check-in">CheckIn</action>
        <action name="check-out">Checkout</action>
        <action name="copy">Copy</action>
        <action name="move">Move</action>
        <action name="simple-workflow">SimpleWorkflow</action>
        <action name="mail">Mail</action>
        <action name="link-category">LinkCategory</action>
        <action name="script">Script</action>
        <action name="transform">Transform</action>
        <action name="transform-image">Transform</action>
        <action name="import">Import</action>
        <action name="set-property-value">SetPropertyValue</action>
        <!-- ADD CUSTOMIZE ACTION TO SHOW -->
    </customise>

</rule-config>

// -------------------------------------------------------------------------------------------------------------------------------------------

STEP(5)

// --------------------------------------------------------------------------------------------------------------------------------------------------

Write e extension with some evaluator

PATH MY PROJECT SHARE:

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-data/extensions/my-overwrite-extension.xml

// --------------------------------------------------------------------------------------------------------------------------------------------------

<extension>
    <modules>
        <module>
            <id>my-overwrite-extension.xml</id>
            <version>1.0</version>
            <auto-deploy>true</auto-deploy>

            <!-- SOME EVALUATOR -->

            <evaluator type="XXXXXXXX">
               .......................
            </evaluator>
            <customizations>

                <customization>
                    <targetPackageRoot>org.alfresco.components.rules</targetPackageRoot>
                    <sourcePackageRoot>custom.org.alfresco.components.rules</sourcePackageRoot>
                </customization>
                <customization>
                    <targetPackageRoot>org.alfresco.components.rules.config</targetPackageRoot>
                    <sourcePackageRoot>custom.org.alfresco.components.rules.config</sourcePackageRoot>
                </customization>
            </customizations>  
        </module>
    </modules>
</extension>

// --------------------------------------------------------------------------------------------------------------------------------------------------

 

but this not work i didn't know what to do i tried even to replace the full component.

 

It's work if i move my webscripts from:

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/custom/org/alfresco/components/rules/

 

to the default location WITHOUT USE THE EXTENSION

 

/<SHARE_PROJECT>/src/main/resources/alfresco/web-extension/site-webscripts/org/alfresco/components/rules/

 

but i didn't want that because i need to pass for some evaluator.

 

 

Ty in advance for any help.

 

Greetings.

Outcomes