Alfresco · Adding a waiting message to PopupManager.displayForm

On developing custom actions for Alfresco Share, ActionFormDialog JavaScript component can be used to read a form id from share-config-custom.xml model mapping and to build a user form window quickly. However, sometimes it’s needed to add a waiting message after user click to show activity while performing the requested action on Alfresco. This component does not include this option, but can be achieved by adding the message before form submit when using Alfresco.util.PopupManager.displayForm:

 // Finally display form as dialog
 Alfresco.util.PopupManager.displayForm(config);

 var that = this;
 YAHOO.Bubbling.on("afterFormRuntimeInit", function PopupManager_displayForm_onAfterFormRuntimeInit(layer, args)
 {
     var displayForm = Alfresco.util.ComponentManager.get(config.properties.htmlid + "-form");
     displayForm.formsRuntime.doBeforeFormSubmit =
     {
        fn: function(form, obj)
        {
    	     // Waiting dialog
        	that.widgets.waitDialog = Alfresco.util.PopupManager.displayMessage({
				text : that.msg("publish-action-share.processing"),
				spanClass : "wait",
				displayTime : 0
			 });
        },
        scope: that
     };
 },
 {
    panel: that,
    config: config
 });

And by redefining success and failure callbacks:

 config.success =
 {
    fn: function(response, obj) {

       // Hide waiting dialog
       this.widgets.waitDialog.destroy();

       // Invoke callback if configured and available
       if (YAHOO.lang.isFunction(this[success]))
       {
          this[success].call(this, response, obj);
       }

       // Fire metadataRefresh so other components may update themselves
       YAHOO.Bubbling.fire("metadataRefresh", obj);
    },
    obj: record,
    scope: this
 };

 config.failure =
 {
    fn: function(response, obj) {

       // Hide waiting dialog
       this.widgets.waitDialog.destroy();

       this[failure].call(this, response, obj);

    },
    obj: record,
    scope: this
 };

Note. I’ve reported an Issue on this, because both fallback and success events are calling config.success function.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s