Question

How to do to showInformationDialog waits for user to click OK and no continue execution before it closes

In this piece of code located in the module called UsrSolicitds3Page the app continue its execution and doesn’t waits user to accept the message, it even lets the user to finish reading the message until the application closes the window automatically. We need to implement this and when the showInformationDialog, the execution of the code stops and wait for the user interaction clicking on the OK button

guardaIncidente: function() {
        var hoyEs = new Date();
        var config = {
                        callback: Terrasoft.emptyFn,
                        isSilent: true
                };
               
        this.save( config );
       
        // Despliega mensaje
        this.showInformationDialog( "AVISO\n\n" +
                "Se ha cerrado Solicitud de Intervención de\n" +
                "Seguimiento y todas las Intervenciones\n" +
                "asociadas:\n\n" +
                "Numero de Intervención principal: " + this.get( "UsrNumeroint" ) +
                "\nNiño/a: " + this.get( "UsrNinoa2" ).displayValue +
                "\nConsultante: " + this.get( "UsrConsultante" ).displayValue +
                "\nFecha/Hora cierre: " + hoyEs.toLocaleDateString() + " a las " +
                hoyEs.getHours() + ":" + hoyEs.getMinutes() + ".",
                function() {}, {
                        style: Terrasoft.MessageBoxStyles.BLUE
        } );
       
},

 

File attachments

Like

6 comments

 If you need to stop user from saving a record until he clicks OK, then you need to merge the save button and change the "Click" method to your new one. Your new method will show the dialog and call this.save() after OK click.

Hi Eugene, sorry, I'm not explained well.

I need to inform the user after saves the record with a summary with some info, because of this I use a showInformationWindow, it's opens, but closes after a few of seconds automatically without the intervention of the user. What I need is it closes when users clicks on OK in the showInformationWindow. 

How it works, when user clicks on Cerrado changing UsrEstadocaso field value and some other conditions apply, we ask the user if it agrees to change the status of this record to Cerrado, this code is on onUsrEstadoCasoChanged method, when user clicks on Aceptar button calls cierraHijas method with the name of the method that finally saves the current record:

this.cierraHijas( this.get( "Id" ), this.guardaIncidente );

In cierraHijas method I change the UsrEstadoCaso on all related records to the current and finally call to the method guardaIncidente wich saves current record and displays a message to the user with the summary, here is where the code fails, because showInformationWindow closes automatically after a few seconds, I need the message was viewed in detail by the user and was be the user who decides to closes the message, not the application.

I expect I explayed better now...please let me now if you need more details

The whole piece of code is the following:

onUsrEstadoCasoChanged: function() {
	if ( this.get( "UsrEstadoCaso" ) ? ( this.get( "UsrEstadoCaso" ).displayValue === "Cerrado" ) : false ) {
		// Esta tratando de cerrar
		if ( this.get( "UsrIdultimahija" ) ) {
			// Solicitud Madre,
			this.showConfirmationDialog( "AVISO\n\nVamos a cerrar todas las hijas, seguro de querer continuar?", 
					function( returnCode ) {
						if ( returnCode === "Aceptar" ) {
							// Procede a cerrar las hijas, pasa ID de Solicitud madre
							//var varBorrar = this.get( "UsrIdultimahija" )
							this.cierraHijas( this.get( "Id" ), this.guardaIncidente );
							
						} else {
							// Usuario cancelar, deja abierta
							this.CambiaEstadoSolicitud( "Abrir" );
							
						}
					}, [ { caption:"Aceptar",
							className:"Terrasoft.Button",
							markerValue:"Aceptar",
							returnCode:"Aceptar" },
						 { caption:"Cancelar",
							className:"Terrasoft.Button",
							markerValue:"Cancelar",
							returnCode:"Cancelar" } ] );
				
		} else {
			// Si es solicitud hija de seguimiento, no deja cerrar
			if ( this.get( "Usrseguimiento" ) ? this.get( "Usrseguimiento" ) : false ) {
			// Solicitud hija NO se puede cerrar
				this.showInformationDialog( "ERROR. No puede cerrar Solicitud de Seguimiento,\n" +
								"debe cerrar la Solicitud Principal" );
				this.CambiaEstadoSolicitud( "Abrir" );
			}
		}
	}
},

// PRUEBA showConfirmationDialog
cierraHijas: function( idMadre, callback ) {
	// Cerrar hijas
	var updateQuery = Ext.create( "Terrasoft.UpdateQuery", {
		rootSchemaName: "UsrSolicitds3"
	} );
	
	// Filtro
	var filters = updateQuery.filters;
	var madreFilter = Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL,
		"Usridmadre", idMadre );
	filters.add( "IdFilter", madreFilter );
	
	// Agrega filtro a lla Query
	updateQuery.setParameterValue( "UsrEstadoCaso", "88c71452-7487-40aa-9174-b4c04609108c", Terrasoft.DataValueType.LOOKUP );
	
	// Ejecuta
	updateQuery.execute( function( result ) {
		if ( Ext.isFunction( callback ) ) {
			callback.call( scope, result );
		}
	}, this );
	
},	

// 20170109 JFL <-
guardaIncidente: function() {
	var hoyEs = new Date();
	var config = {
		callback: Terrasoft.emptyFn,
		isSilent: true
	};
		
	// Save current record
	this.save( config );
	
	// Despliega mensaje
	this.showInformationDialog( "AVISO\n\n" + 
		"Se ha cerrado Solicitud de Intervención de\n" +
		"Seguimiento y todas las Intervenciones\n" +
		"asociadas:\n\n" + 
		"Numero de Intervención principal: " + this.get( "UsrNumeroint" ) +
		"\nNiño/a: " + this.get( "UsrNinoa2" ).displayValue +
		"\nConsultante: " + this.get( "UsrConsultante" ).displayValue +
		"\nFecha/Hora cierre: " + hoyEs.toLocaleDateString() + " a las " + 
		hoyEs.getHours() + ":" + hoyEs.getMinutes() + ".", 
		function() {}, {
			style: Terrasoft.MessageBoxStyles.BLUE
	} );
},

 

Try to call save method in callback of showInformationDialog:

guardaIncidente: function() {

        var scope = this;

        

        var hoyEs = new Date();

        var config = {

                callback: Terrasoft.emptyFn,

                isSilent: true

        };

        

        this.showInformationDialog( "message.....", 

                function() { scope.save( config ); }, {

                style: Terrasoft.MessageBoxStyles.BLUE

        } );

        

},

Good!!, thanks Maksym, it works, but

Wich is the trick to use showInformationDialog usually, I have several ways when I need to communicate something to users and in variouos of them have the same problem, how we must use to it works as a modal dialog?,

When could be used simply as this.showInformationDialog( "Some text to usr" ); and when we need to use, using a function to do something?

thanks again

 

Dear Julio,

You can use showInformationDialog in case you want to display information to users. However, in case you want some particular function to execute after recieved response from users, please, write your code withing a callback function.

However, in case a sequance is not important, you can write your code after the showInformationDialog function.

Thanks Anastasia!

Show all comments