Метод postCreate, вызывающий несколько раз в Айкау

Мы добавляем некоторые пользовательские действия в меню "Выбранные элементы" на экране "Фасетный поиск" 5.1+aikau(100.0.1);

но когда я загружаю страницу, в пользовательском виджете метод 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************.");

}
});
});

1 ответ

Я думаю, что вы звоните тот же виджет 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, и вы можете увидеть поведение по умолчанию, в котором несколько запросов (каждый запрос для каждого виджета) аналогичны вашим. Единственная разница в том, filter метод и publish (lang.hitch) питания. Надеюсь, теперь тебе ясно.

Другие вопросы по тегам