We are adding some custom actions in Selected Items menu in Faceted search screen 5.1+aikau(100.0.1);
but when i load the page,In Custom widget postCreate method is calling twice and when i select 'Edit properties' then also onSelectedDocumentsAction function calling twice.
if i push one more extra item in selectedItemsActionsGroup then that many times(3 times) its calling.
var selectedItemsActionsGroup = widgetUtils.findObject(model.jsonModel.widgets,"id", "SELECTED_ITEMS_ACTIONS_GROUP");
selectedItemsActionsGroup.config.widgets.push(
{
id : "OnActionEditProperties",
name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
config : {
label : "Edit",
iconImage : url.context
+ "/res/components/documentlibrary/actions/y-16.png",
type : "action-link",
permission : "",
asset : "",
href : "",
hasAspect : "",
notAspect : "",
publishTopic : "BULK_OPS",
publishPayload : {
action : "onActionEditProperties",
}
}
},
{
id : "OnActionManaged",
name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
config : {
label : "Managed",
iconImage : url.context
+ "/res/components/documentlibrary/actions/x-16.png",
type : "action-link",
permission : "",
asset : "",
href : "",
hasAspect : "",
notAspect : "",
publishTopic : "BULK_OPS",
publishPayload : {
action : "OnActionManaged",
}
}
});
*****************
CustomBulkSelectItems.js
**********************
define(["dojo/_base/declare",
"alfresco/services/FormsRuntimeService",
"alfresco/core/UrlUtilsMixin",
"alfresco/enums/urlTypes",
"alfresco/core/Core",
"alfresco/menus/AlfFilteringMenuItem",
"alfresco/documentlibrary/_AlfDocumentListTopicMixin",
"alfresco/core/CoreXhr",
"dojo/_base/lang",
"dojo/dom-class",
"dojo/_base/array",
"service/constants/Default","alfresco/core/topics"],
function(declare,FormsRuntimeService, UrlUtilsMixin,urlTypes,AlfCore ,AlfFilteringMenuItem, _AlfDocumentListTopicMixin,AlfCoreXhr, lang, domClass,
array, AlfConstants,topics) {
return declare([FormsRuntimeService,UrlUtilsMixin,AlfCore,AlfFilteringMenuItem,_AlfDocumentListTopicMixin,AlfCoreXhr], {
i18nRequirements: [ {i18nFile: "./CustomBulkSeledtItems.properties"} ],
postCreate: function alfresco_documentlibrary_CustomBulkSelectItems__postCreate() {
console.log(" bulkops postCreate************.");
this.alfSubscribe("BULK_OPS", lang.hitch(this, this.onSelectedDocumentsAction));
this.inherited(arguments);
} ,
/**
* This function handles requests to perform actions on the currently selected documents. It takes the
* provided payload and updates it with the
*
* @instance
* @param {object} payload The payload containing the details of the action being requested
* @fires alfresco/core/topics#MULTIPLE_ITEM_ACTION_REQUEST
*/
onSelectedDocumentsAction: function alfresco_documentlibrary_CustomBulkSelectItems__onSelectedDocumentsAction(payload) {
console.log(" bulkops onSelectedDocumentsAction************.");
}
});
});
I think you're calling same widget
faceted-search/CustomBulkSelectItems/CustomBulkSelectItemstwice andpublishTopicalso called twice from the get.js file. After change the widget in the get.js it is looking fine to me.Share your thoughts.
I changed your something like below and the output is like that.
Updated info
Please look at the AlfFilteringMenuItem.js and
and
There is no specific implemenation is found. If you enable debug logs, you should be able to the warn messages.
I looked at the aikau logs and you can see the default behaviour also having muliple requests( each request for each widger) similar to yours. The only difference is ,
filtermethod andpublish (lang.hitch)stuffs. Hope you're clear now.