fixes issue 27240: On Change Function in Process Definition non editable fields
authorCarlos Aristu <carlos.aristu@openbravo.com>
Wed, 02 Dec 2015 09:27:26 +0100
changeset 28085 0a811f99d7f8
parent 28083 5e894b37c168
child 28086 2ad48c10e4ea
fixes issue 27240: On Change Function in Process Definition non editable fields

The handleItemChange method is the method in charge of execute the on change function on onblur. This event is not fired when setting the value of a field programmatically. To solve this, a new method has been introduced in the API: setValueAndHandleItemChange() which invokes handleItemChange() after setting the value of a the field.

This method will be available automatically just for those Process Definition fields with an on change function assigned to them through the application dictionary.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-form.js	Tue Dec 01 23:08:54 2015 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-form.js	Wed Dec 02 09:27:26 2015 +0100
@@ -36,6 +36,20 @@
     this.paramWindow.handleButtonsStatus();
   },
 
+  setItems: function (itemList) {
+    itemList.forEach(function (item) {
+      if (item.onChangeFunction) {
+        item.setValueAndHandleItemChange = function () {
+          this.Super('setValue', arguments);
+          if (this.view && this.view.theForm) {
+            this.view.theForm.handleItemChange(item);
+          }
+        };
+      }
+    });
+    this.Super('setItems', arguments);
+  },
+
   // this function is invoked on the blur action of the formitems
   // this is the proper place to execute the client-side callouts
   handleItemChange: function (item) {