How to create custom action "disable download document" in alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
muralidharand
Established Member II

Re: How to create custom action "disable download document" in alfresco

Here is the updated javascript from your post.

Make sure, you have placed this file in the tomcat\webapps\share folder rather adding them into difference place.

(function () {
    var me = this;

    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onDisableDownload",
        fn: function dlA_onDisableDownload(asset) {


            var node  = new Alfresco.util.NodeRef(asset.nodeRef).uri;
            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 added: ["quanticate:disableDownloadAspect"]
                },
                successCallback:
                {
                 fn: function(response)
                    {
                        Alfresco.util.PopupManager.displayMessage(
                        {
                           text: "Download action disabled successfully"
                        });
                        window.location.reload();
                    }
                },

                failureCallback:
                {
                fn: function(response)
                   {
                       this.msg("message.failure")
                   }
                }
            });
        }
    });
    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onEnableDownload",
        fn: function dlA_onEnableDownload(asset) {


            var node  = new Alfresco.util.NodeRef(asset.nodeRef).uri;
            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 removed: ["quanticate:disableDownloadAspect"]
                },
                successCallback:
                {
                 fn: function(response)
                    {
                        Alfresco.util.PopupManager.displayMessage(
                        {
                           text: "Download action enabled successfully"
                        });
                        window.location.reload();
                    }
                },

                failureCallback:
                {
                fn: function(response)
                   {
                       this.msg("message.failure")
                   }
                }
            });
        }
    });



})();

Hope this helps you.

If not, please let me know, will help you.

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai kgastaldo,

I tested this code but this code not taking any action. can you please

explain steps wise. please i need your help.

i am using alfresco-community-5.1.f

muralidharand
Established Member II

Re: How to create custom action "disable download document" in alfresco

Are you getting error in browser console ? While using your javascript, I had issues and i fixed the javascript and posted in the prev.post.

Please let me know, what you've placed the javascript (my-custom-action.js) file ?

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Dear muralidharand,

1) I created custom-slingshot-share-context.xml in

/alfresco/web-extension with following code

3) I created my-custom-actions.js in /webapps/share/scripts with

following code

(function () {

var me = this;

YAHOO.Bubbling.fire("registerAction", {

actionName: "onDisableDownload",

fn: function dlA_onDisableDownload(asset) {

var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;

var url = Alfresco.constants.PROXY_URI +

"slingshot/doclib/action/aspects/node/" + node;

Alfresco.util.Ajax.jsonRequest({

url: url,

method: "POST",

dataObj:

{

added: ["quanticate:disableDownloadAspect"]

},

successCallback:

);

window.location.reload();

}

},

failureCallback:

}

});

}

});

YAHOO.Bubbling.fire("registerAction", ,

successCallback:

);

window.location.reload();

}

},

failureCallback:

}

});

}

});

})();

I tested these steps, but ' disable -download' button not taking any

action. if i did any mistake. please inform me friend. help me. how i need

to steps wise. please

On Fri, Apr 7, 2017 at 3:48 PM, muralidharand <community@alfresco.com>

muralidharand
Established Member II

Re: How to create custom action "disable download document" in alfresco

My guess, you might have missed the model (repo) side changes.

I have attached all the files that I used + you required.

Please update them in your instance properly and let me know.

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Dear Muralidharan Deenathayalan,

1) I created custom-slingshot-share-context.xml in /alfresco/web-extension   with following code

 <bean id="share.custom.config" class="org.springframework.extensions.config.ConfigBootstrap"
        init-method="register">
        <property name="configService" ref="web.config" />
        <property name="configs">
            <list>
                <value>classpath:alfresco/web-extension/doclib-share-config.xml</value>
            </list>
        </property>
    </bean>
    <bean id="evaluator.doclib.isDisableDownloadEvaluator" parent="evaluator.doclib.action.hasAspect">
        <property name="aspects">
            <list>
                <value>my:disableDownload</value>
            </list>
        </property>
    </bean>

2) I created doclib-share-config.xml in /alfresco/web-extension   with following code

<!-- Document Library Custom Code config section -->
       <config evaluator="string-compare" condition="DocLibCustom">
         <dependencies>
            <js src="my-custom-action.js" />
         </dependencies>
          <dependencies />
       </config>

 

    <config evaluator="string-compare" condition="DocLibActions">
        <actions>
            <action id="disable-download" type="javascript" label="actions.disable-download">
                <param name="function">onDisableDownload</param>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>
            <action id="enable-download" type="javascript" label="actions.enable-download">
                <param name="function">onEnableDownload</param>
                <evaluator>evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>

 

             <!-- OVERRIDE ACTION Download document -->
             <action id="document-download" type="link" label="actions.document.download">
                <param name="href">{downloadUrl}</param>
                <param name="target">_blank</param>
                <evaluator>evaluator.doclib.action.downloadBrowser</evaluator>
                <evaluator>evaluator.doclib.action.hasContent</evaluator>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
             </action>

        </actions>
        <actionGroups>
              <actionGroup id="document-browse">
                <action index="101" id="disable-download" />
                <action index="102" id="enable-download" />
              </actionGroup>
        </actionGroups>
    </config>

3) I created my-custom-actions.js in /webapps/share/scripts   with following code

(function () {
    var me = this;

    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onDisableDownload",
        fn: function dlA_onDisableDownload(asset) {


            var node  = new Alfresco.util.NodeRef(asset.nodeRef).uri;
            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 added: ["quanticate:disableDownloadAspect"]
                },
                successCallback:
                {
                 fn: function(response)
                    {
                        Alfresco.util.PopupManager.displayMessage(
                        {
                           text: "Download action disabled successfully"
                        });
                        window.location.reload();
                    }
                },

                failureCallback:
                {
                fn: function(response)
                   {
                       this.msg("message.failure")
                   }
                }
            });
        }
    });
    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onEnableDownload",
        fn: function dlA_onEnableDownload(asset) {


            var node  = new Alfresco.util.NodeRef(asset.nodeRef).uri;
            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 removed: ["quanticate:disableDownloadAspect"]
                },
                successCallback:
                {
                 fn: function(response)
                    {
                        Alfresco.util.PopupManager.displayMessage(
                        {
                           text: "Download action enabled successfully"
                        });
                        window.location.reload();
                    }
                },

                failureCallback:
                {
                fn: function(response)
                   {
                       this.msg("message.failure")
                   }
                }
            });
        }
    });

})();

I tested these steps, but ' disable -download' button not taking any action. if i did any mistake. please inform me friend. help me. how i need to steps wise. please

muralidharand
Established Member II

Re: How to create custom action "disable download document" in alfresco

Have you updated the model , to have the aspect? Any errors in browser console ?

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai Muralidharan,

i am not updated any model friend, no errors friend.

(sorry for my bad english)

muralidharand
Established Member II

Re: How to create custom action "disable download document" in alfresco

You should have the aspect in your model, otherwise Alfresco Repository can't store the download/disable value.

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai Muralidharan,

Can you please suggest how to create aspect ....?