1

我们正在分面搜索屏幕 5.1+aikau(100.0.1) 的 Selected Items 菜单中添加一些自定义操作;

但是当我加载页面时,在自定义小部件 postCreate 方法中调用了两次,当我选择“编辑属性”时,onSelectedDocumentsAction 函数也调用了两次。

如果我在 selectedItemsActionsGroup 中再推一个额外的项目,那么它的调用次数(3 次)。

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************.");

}
});
});
4

1 回答 1

0

我认为您调用faceted-search/CustomBulkSelectItems/CustomBulkSelectItems了两次相同的小部件,并且publishTopic还从 get.js 文件中调用了两次。更改 get.js 中的小部件后,它对我来说看起来不错。

分享你的意见。

我改变了你的东西,如下所示,输出就是这样。

在此处输入图像描述

在此处输入图像描述

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/CustomBulkSelect",
                        config : {
                            label : "Managed",
                            iconImage : url.context
                                    + "/res/components/documentlibrary/actions/x-16.png",
                            type : "action-link",
                            permission : "",
                            asset : "",
                            href : "",
                            hasAspect : "",
                            notAspect : "",
                            publishTopic : "BULK_OPS_1",
                            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************.");

}
});
});

CustomBulkSelect.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(" CustomBulkSeledt bulkops postCreate************.");
         this.alfSubscribe("BULK_OPS_1", 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(" CustomBulkSeledt bulkops onSelectedDocumentsAction************.");

}
});
});

更新信息

请查看AlfFilteringMenuItem.js

postCreate: function alfresco_menus_AlfFilteringMenuItem____postCreate() {
         this.filterTopic && this.alfSubscribe(this.filterTopic, lang.hitch(this, this.filter));
         this.inherited(arguments);
      },

filter: function alfresco_menus_AlfFilteringMenuItem__filter(payload) {
         this.alfLog("warn", "No implementation of filtering extension point", payload);
      }

没有找到具体的实现。如果您启用调试日志,您应该能够收到警告消息。

我查看了 aikau 日志,您可以看到默认行为也具有与您类似的多个请求(每个 widger 的每个请求)。唯一的区别是,filter方法和publish (lang.hitch)材料。希望你现在清楚了。 在此处输入图像描述

于 2017-03-14T13:26:37.043 回答