Thursday, 27 August 2015

Coach View - Button click will return it's label name along with alert message


  Button click will return it's label name along with alert message 

  A - Copy button component and create new coach view
  B - Click on variable tab and change business data type from Boolean to String.
  C - Define variable in configuration option
              message (String)
  D - Click on Behavior tab -- Remove previous code exists in event handler's view

  Paste given below code in view


var baseTextDirection = this.context.options._metadata.baseTextDirection && this.context.options._metadata.baseTextDirection.get("value") ? this.context.options._metadata.baseTextDirection.get("value") : utilities.BiDi.BASE_TEXT_DIRECTION._default;
var generalPrefTextDirection = this.context.bpm.system.baseTextDirection;
var button = this.context.element.getElementsByTagName("button")[0];
var visibility = utilities.handleVisibility(this.context, null, null, [button]);
if (visibility != "NONE") {
// if (this.context.options._metadata.label && this.context.options._metadata.label.get("value") != "") {
//  button.innerHTML = this.context.htmlEscape(this.context.options._metadata.label.get("value"));
//  utilities.BiDi.applyTextDir(button, button.innerHTML, baseTextDirection, generalPrefTextDirection);
// } else {
//  // In Firefox a button with no text or " " shows very small, using a non-breaking space prevents this
//  button.innerHTML = " ";
// }
    //button.innerHTML = this.context.options.buttonName.get("value");
    button.innerHTML = this.context.htmlEscape(this.context.options._metadata.label.get("value"));
//  utilities.BiDi.applyTextDir(button, button.innerHTML, baseTextDirection, generalPrefTextDirection);
    
// if (this.context.options._metadata.helpText && this.context.options._metadata.helpText.get("value") != "") {
//  button.title = this.context.options._metadata.helpText.get("value");
// }
 button.onmousedown = function() {
  domClass.add(this, "BPMButton-down");
 };
 button.onmouseout = button.onmouseup = function() {
  domClass.remove(this, "BPMButton-down");
 };
 var _this = this;
 button.onclick = function() {
  if (this.disabled == false) {
   var context = _this.context;
   var message = context.options.message.get("value");
  
   if (context.options.allowMultipleClicks == undefined || !context.options.allowMultipleClicks.get("value")) {
    this.disabled = true;
    domClass.add(this, "BPMButton-disabled");
   }
   if (context.binding) {
    context.binding.set("value", button.innerHTML);
   }
   var _button = this;           
            var response=confirm(message); 
   if(response == true) {
       context.trigger(function() {_button.disabled = false; domClass.remove(_button, "BPMButton-disabled");});
   }
   else {
       this.disabled = false;
    domClass.remove(this, "BPMButton-disabled");
//       _button.disabled = false
//       domClass.remove(_button, "BPMButton-disabled");
       return; //context.trigger();
   }
  }
 }
 this.updateStyle();
};

 E - Coach view is ready with label name. Drag and Drop in Human Service.
 F - Bind it with string variable.


TWX File ---



No comments:

Post a Comment