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.
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
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 ?
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>
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.
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
Have you updated the model , to have the aspect? Any errors in browser console ?
You should have the aspect in your model, otherwise Alfresco Repository can't store the download/disable value.
Hai Muralidharan,
Can you please suggest how to create aspect ....?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.