AlfButton

cancel
Showing results for 
Search instead for 
Did you mean: 
riadhazzouz
Active Member

AlfButton

How Can I add an action to the button.

var Button =  {
      name: "alfresco/buttons/AlfButton",
      config: {
            label: "click to update"
      }
};

3 Replies
roberto_gamiz
Established Member II

Re: AlfButton

Asuming you are trying to execute a custom action, you must to use the property publishTopic of AlfButton to set the topic to publish when the button is clicked.

JSDoc: Module: alfresco/buttons/AlfButton 

Then yoy need to implement a custom service to subscribe this topic and handle the action.

Take a look to AIKAU tutorial :

Aikau/Tutorial7.md at develop · Alfresco/Aikau · GitHub 

 

Regards

riadhazzouz
Active Member

Re: AlfButton

I found a problem in step 4 : Create Service.
I can't find the path to create that file in my project.

And is there a way to pass the attributes without creating the textBox for each one ? I just don't have fields to fill
but I do have parameters to pass.

Thanks.

riadhazzouz
Active Member

Re: AlfButton

I succeded creating the service, this is the code :

define(["dojo/_base/declare",
"alfresco/core/Core",
"dojo/_base/lang",
"alfresco/core/CoreXhr",
"service/constants/Default"],
function(declare, Core, lang) {

return declare([Core], {

constructor: function service_change_status__constructor(args) {
lang.mixin(this, args);
this.alfSubscribe("SERVICE_CHANGE_STATUS", lang.hitch(this, this.changeStatus));
},

changeStatus: function service_change_status__changeStatus(payload) {

this.serviceXhr({
url: AlfConstants.PROXY_URI + "/alfresco/s/pfe/status?id=" + payload.id,
method: "POST",
successCallback: this.onSuccess,
callbackScope: this
});

},
onSuccess: function service_change_status__onSuccess(response, originalRequestConfig) {
this.alfPublish("ALF_DOCLIST_RELOAD_DATA", {});
},
onFailure: function service_change_status_onFailure(response, originalRequestConfig) {

Alfresco.util.PopupManager.displayMessage({ title: this.message("export.search.result"), text: this.message("export.search.result.no")});
}
});
});

and this is the button :

var button= {
name: "alfresco/buttons/AlfButton",
config: {
label: "button",
publishTopic: "SERVICE_CHANGE_STATUS",
publishPayload: {
id :id
}
}
};

but still nothing happens once i click the button.
Any help ?