cancel
Showing results for 
Search instead for 
Did you mean: 

How to auto close the form upon submit.

satheeshkumar
Champ in-the-making
Champ in-the-making
Hi all,

I have created a form using topic "ALF_CREATE_DIALOG_REQUEST", the sample code snippet is shown below,


var alfDestination = null;

var result = remote.call("url call to repository");

if (result.status.code == status.STATUS_OK) {
   alfDestination = JSON.parse(result).metadata.parent.nodeRef;
}

//Code snippet of my pop-dialog form,
widgets : [
{
   name : "alfresco/menus/AlfMenuBarItem",
   config : {
      label : "Create Product Type using ALF_CREATE_DIALOG_REQUEST",
      publishTopic : "ALF_CREATE_DIALOG_REQUEST",
      publishPayload : {
         dialogTitle : "Create New Product Type",                                                                     
         fixedWidth : false,                                                                     
         widgetsContent : [{
            name : "alfresco/forms/Form",
            config : {
               showOkButton : true,
               okButtonLabel : "Add",
               showCancelButton : true,
               cancelButtonLabel : "Cancel",
               //Specify the TOPIC here
               okButtonPublishTopic : "ALF_CRUD_CREATE",                                                                           
               okButtonPublishGlobal : true,
               okButtonPublishPayload : {                                                                              
                  url : "api/type/hccm%3AproductTypeFolder/formprocessor",                                                                              
                  alf_destination : alfDestination,
                  alfResponseTopic : "HC_PRODUCT_CREATE"
               },
               widgets : [
                         
                  {
                     name : "alfresco/forms/controls/TextBox",
                     config : {
                        fieldId : "PRODUCT_NAME",
                        label : "Product Name",
                        name : "prop_cm_name",
                        description : "Provide a Unique Value for the Product Name.",
                        requirementConfig : {
                           initialValue : true
                        },
                        validationConfig : [ {
                           validation : "validateUnique",
                           itemsProperty : "response.productNameList",
                           errorMessage : "The Product Name already exists!",
                           publishTopic : "ALF_CRUD_GET_ALL",
                           publishPayload : {
                              url : "retrieve-library-list?retrieve=Product%20Library"
                           }
                        } ]
                     }
                  },
                  {

                     name : "alfresco/forms/controls/DojoValidationTextBox",
                     config : {
                        label : "Product Title",
                        name : "prop_cm_title"
                     }

                  },
                  {

                     name : "alfresco/forms/controls/DojoValidationTextBox",
                     config : {
                        label : "Product Description",
                        name : "prop_cm_description"
                     }

                  },
                  {

                     name : "alfresco/forms/controls/TextBox",
                     config : {
                        fieldId : "PRODUCT_PREFIX",
                        label : "Product Prefix",
                        name : "prop_hccm_prefix",
                        description : "Provide a Unique Value for the Prefix field.",
                        requirementConfig : {
                           initialValue : true
                        },
                        validationConfig : [ {
                           validation : "validateUnique",
                           itemsProperty : "response.productPrefixList",
                           errorMessage : "This Prefix is already used. Please try different value.",
                           publishTopic : "ALF_CRUD_GET_ALL",
                           publishPayload : {
                              url : "retrieve-library-list?retrieve=Product%20Library"
                           }
                        } ]
                     }

                  }]
            }

         }]                                                                     
      }
   }
} ]


Upon submit the form is posting the data to the mentioned destination and in the specified URl, there is no issue in that, but once I submitted the content the Pop-up Dialog(which contains my form) still exists, it neither close automatically nor clearing the form fields.


What I should do for my pop-up dialog to clear the form fields after submit, or close the pop-up dialog upon submit. Either one would full fill my need.

Any help is greatly appreciated.





I also tried with topic,
"ALF_CREATE_FORM_DIALOG_REQUEST"
,(this form properly closes the pop-up upon submit) I am able to use
formSubmissionTopic for pulish
, and I can create my own subscription topic for the topic published and call a function when subscribed, but in that function I am able to specify only the
URL
but not the
alf_destination
, so even after submitting nothing is happening because I haven't specify the alf_destination and just the dialog gets closed.



//Code snippet of ALF_CREATE_DIALOG_REQUEST
widgets : [
   {
      name : "alfresco/menus/AlfMenuBarItem",
      config : {
         label : "Create Product Type using ALF_CREATE_DIALOG_REQUEST",
         publishTopic : "ALF_CREATE_DIALOG_REQUEST",
         publishPayload : {
            dialogTitle : "Create New Product Type",                                                                     
            fixedWidth : false,                                                                     
            widgetsContent : [{
               name : "alfresco/forms/Form",
               config : {
                  showOkButton : true,
                  okButtonLabel : "Add",
                  showCancelButton : true,
                  cancelButtonLabel : "Cancel",
                  //Specify the TOPIC here
                  okButtonPublishTopic : "ALF_CRUD_CREATE",                                                                           
                  okButtonPublishGlobal : true,
                  okButtonPublishPayload : {                                                                              
                     url : "api/type/hccm%3AproductTypeFolder/formprocessor",                                                                              
                     alf_destination : alfDestination,
                     alfResponseTopic : "HC_PRODUCT_CREATE"
                  },
                  widgets : [
                            
                     {
                        name : "alfresco/forms/controls/TextBox",
                        config : {
                           fieldId : "PRODUCT_NAME",
                           label : "Product Name",
                           name : "prop_cm_name",
                           description : "Provide a Unique Value for the Product Name.",
                           requirementConfig : {
                              initialValue : true
                           },
                           validationConfig : [ {
                              validation : "validateUnique",
                              itemsProperty : "response.productNameList",
                              errorMessage : "The Product Name already exists!",
                              publishTopic : "ALF_CRUD_GET_ALL",
                              publishPayload : {
                                 url : "retrieve-library-list?retrieve=Product%20Library"
                              }
                           } ]
                        }
                     },
                     {

                        name : "alfresco/forms/controls/DojoValidationTextBox",
                        config : {
                           label : "Product Title",
                           name : "prop_cm_title"
                        }

                     },
                     {

                        name : "alfresco/forms/controls/DojoValidationTextBox",
                        config : {
                           label : "Product Description",
                           name : "prop_cm_description"
                        }

                     },
                     {

                        name : "alfresco/forms/controls/TextBox",
                        config : {
                           fieldId : "PRODUCT_PREFIX",
                           label : "Product Prefix",
                           name : "prop_hccm_prefix",
                           description : "Provide a Unique Value for the Prefix field.",
                           requirementConfig : {
                              initialValue : true
                           },
                           validationConfig : [ {
                              validation : "validateUnique",
                              itemsProperty : "response.productPrefixList",
                              errorMessage : "This Prefix is already used. Please try different value.",
                              publishTopic : "ALF_CRUD_GET_ALL",
                              publishPayload : {
                                 url : "retrieve-library-list?retrieve=Product%20Library"
                              }
                           } ]
                        }

                     }]
               }

            }]                                                                     
         }
      }
   } ]
   }
} ]

can someone let me know how to configure both url and alf_destination, when I create a dialog using 
"ALF_CREATE_FORM_DIALOG_REQUEST"
, either in the subscribed function or in the dialog itself.

Thanks in Advance,
3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator
The reason that the dialog you're creating using the "ALF_CREATE_DIALOG_REQUEST" is that the buttons you're seeing are from the form, not the dialog - do make the dialog disappear you'd need to configure "widgetsButtons" array to contain all the buttons that you wish to control your dialog with.

Since you're just using form controls then you should use "ALF_CREATE_FORM_DIALOG_REQUEST", however you're configuring it wrong… if you want to include additional data in the published payload (when the dialog confirmatio button is used) then you should include it in the "formSubmissionPayloadMixin" topic. Examples of using the DialogService can be found in the https://github.com/Alfresco/Aikau/blob/master/aikau/src/test/resources/testApp/WEB-INF/classes/alfre... file in GitHub. If you clone the GitHub repository and build and start the test application (mvn clean install jetty:run) then you can try the test page out at the URL: http://localhost:8089/aikau/page/tp/ws/DialogService

Looking through the existing form dialog tutorials I see that we've not covered the "formSubmissionPayloadMixin" and it's not covered in the JSDoc either - I'll raise an issue on the Aikau backlog to address this.

Regards,
Dave

ddraper
World-Class Innovator
World-Class Innovator
I've raised the feature request on the Aikau backlogs to improve the existing tutorial or add a new chapter that would cover this: https://issues.alfresco.com/jira/browse/AKU-225

ddraper
World-Class Innovator
World-Class Innovator
There's a PR for this now here: https://github.com/Alfresco/Aikau/pull/194 so it should be included in the JSDoc and tutorial as part of the 1.0.15 release.