AnsweredAssumed Answered

Mixin AlfSelectedItemsMenuItem Payloads to DialogService Submit Payload

Question asked by keithb_dtech on Oct 29, 2016
Latest reply on Oct 31, 2016 by afaust

I am having trouble constructing a payload for a DialogService form submission event. The use case is when a user selects the items in a custom search, the AlfSelectedItemsMenuItem populates with the currently selected items and the user can next choose to operate on the selected items. Before the user operates on those items, we display a dialog to the user for additional information. The dialog, upon completion, sends the collected information to a repository webscript using a CrudService POST. However, the Dialog will not mixin with the selected items at all, the selectedItems array is not present in the payload passed to the webscript.

 

The first thing we tied was to use the PROCESS payload type on the AlfSelectedItemsMenuItem as well as supplying a "selectedItems" field in the formSubmissionPayloadMixin with the publishPayloadModifier containing "processCurrentItemTokens" but that did not work. We assumed it was due to there being no "currentItem" on the AlfSelectedItemsMenuItem. Next, we tried to get the selectedItems to populate themselves with the service mixin by supplying the CONFIGURED payload type on the AlfSelectedItemsMenuItem with the publishPayloadItemMixin set to true. That also did not work. I believe what is going on is that the DialogService does not have a handle on the selectedItems and needs to be overridden with the alfresco/lists/SelectedItemStateMixin. I am skeptical that this will work since the SelectedItemStateMixin may not be able to publish to the Dialog since it is created AFTER the user clicks the AlfSelectedItemsMenuItem. I also thought this solution was overkill since we receive the selectedItems field when we publish to the CrudService directly from the AlfSelectedItemsMenuItem to our webscript (no Dialog) without specifying the payload type or any other mixins. Is there any way to solve this problem without potentially re-building the DialogService?

 

Here is a snippet of the code we currently have:

{
    name: "alfresco/documentlibrary/AlfSelectedItemsMenuBarPopup",
    config: {
        label: "Selected Items...",
        itemKeyProperty: "nodeRef",
        widgets: [
            {
                id: "SELECTED_ITEMS_ACTIONS_MENU_GROUP",
                name: "alfresco/menus/AlfMenuGroup",
                config: {
                    widgets: [
                        // ... other widgets
                        {
                            name: "alfresco/menus/AlfSelectedItemsMenuItem",
                            config: {
                                id: "SELECTED_ITEMS_NDS_ACTION",
                                label: "Process NDS",
                                iconImage: url.context + "/res/components/documentlibrary/actions/document-download-16.png",
                                // iconImage: url.context + "/res/components/social-email-16.png",
                                publishTopic: "ALF_CREATE_FORM_DIALOG_REQUEST",
                                publishPayload: {
                                    cancelPublishScope: "",
                                    cancelPublishTopic: "DIALOG_CANCELLED",
                                    //showOkButton: false,
                                    dialogId: "FCTSRCH_NDS_DIALOG",
                                    dialogTitle: "Process NDS",
                                    dialogConfirmationButtonTitle: "Process",
                                    dialogCancellationButtonTitle: "Cancel",
                                    formSubmissionTopic: "ALF_CRUD_CREATE",
                                    formSubmissionPayloadMixin: {
                                        url: "/processnds",
                                    },
                                    widgets: [
                                        {
                                            name: "alfresco/forms/controls/SimplePicker",
                                            config: {
                                                label: "Choose New Handler",
                                                description: "Choose a User to Attach the NDS.",
                                                name: "user",
                                                loadDataPublishTopic: "ALF_CRUD_GET_ALL",
                                                loadDataPublishPayload: {
                                                    url: "api/people"
                                                },
                                                itemsProperty: "people",
                                                itemKey: "userName",
                                                propertyToRender: "userName",
                                                availableItemsLabel: "Available Users",
                                                pickedItemsLabel: "Currently Selected Users"
                                            }
                                        },
                                        {
                                            name: "alfresco/forms/controls/TextBox",
                                            config: {
                                                name: "location",
                                                label: "New Location",
                                                description: "New Location for NDS?"
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        ]
    }
}

If line 20 is instead ALF_CRUD_CREATE and the payload on line 21 contains "url: /processnds", we get the selectedItems just fine returned to our webscript.

Outcomes