Question

Prevent DCM Click to change stage

Hi,

I struggle with the onActiveStageClick method of SectionActionsDashboard.

The following doesn't work, I see that there is a onActiveStageClickAsync: async function, but not sure how I can execute an esq and wait for the result.

			onActiveStageClick: function(oldValue, value) {
				var scope = this;
				var valid = false;
				Terrasoft.chain(
					function (next) {
						if (!this._isMasterEntityValid()) {
							valid = false;
							next();
						}
 
						if (this.get("EntitySchemaName") == "UsrDemandes") {
 
							var parentValues = this.getColumnsValues(["UsrTypeDePage", "Id"]);
							var typePage = parentValues["UsrTypeDePage"]
							if (typePage &&
								typePage.value === UsrConsts.Demande.TypePage.DP_LE.value &&
								value === UsrConsts.Demande.Status.DemandeValidation.value) {
 
								var demandeId = parentValues["Id"];
								var gNb = 0;
 
								this.getNbIdentification(demandeId, function (pNb) {
									valid = pNb > 0;
									next();
								});
							} else {
								valid = true;
								next();
							}
 
						} else {
							valid = true;
							next();
						}
					}, function () {
						return valid;
					},
					this
				);
			},			
			getColumnsValues: function(argument) {
				return this.sandbox.publish("GetColumnsValues", argument, [this.sandbox.id]);
			},
           	getNbIdentification: function(demandeId, callback){
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: "UsrIdentification"
				});
 
				esq.addColumn("Id");
 
				var esqDemandeFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrUsrDemandes", demandeId);
				esq.filters.add("esqDemandeFilter", esqDemandeFilter);
                esq.getEntityCollection(function(response) {
                  	if (response.success) {
        				var entities =  response.collection.getItems();
						if (callback) {
							callback.call(this, entities.length);
						}
                  	} else {
                        if (callback) {
                            callback.call(this, 0);
                        }
                  	} 
                }, this);				
 
			}

 

Like 0

Like

2 comments

Hello Jerome,

 

I added the same code to the replaced SectionActionsDashboard and it's triggered and works properly. Please clarify what exactly is not triggered?

Oleg Drobina,

onActiveStageClick expect to return true if case is changed, false to prevent it. It seems that case is switched before evaluating the part, or boolean value is not returned : 
								this.getNbIdentification(demandeId, function (pNb) {
									valid = pNb > 0;
									next();

 

Show all comments