fixes issue 39227: Form Personalization doesn't work having tree based fields
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 11 Sep 2018 17:50:57 +0200
changeset 34766 e5566da8d2a0
parent 34765 3e0f540c5540
child 34767 361d99d453c4
fixes issue 39227: Form Personalization doesn't work having tree based fields

The Form Personalization feature was not working when having fields based on a tree reference. This was happening because when building the pre-visualization form not all the information required by an OBTreeItem instance was provided.

Now we are taking into account if the OBTreeItem instance is being built for the personalization form and in that case we skip the initialization of its components: it will be shown just as a text field.

Besides, we are adding a check within the "moved" function to verify whether the "tree" property exists. This is done to avoid a JS error at that point after opening the personalization form.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js	Mon Sep 10 12:40:04 2018 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js	Tue Sep 11 17:50:57 2018 +0200
@@ -35,6 +35,11 @@
   tree: null,
   init: function (parameters) {
     this.pickerIconSrc = OB.Styles.OBFormField.DefaultComboBox.pickerIconSrc;
+    if (parameters.isPreviewFormItem) {
+      // Do not need to initialize the OBTreeItem components if we are in the personalization form
+      this.Super('init', arguments);
+      return;
+    }
     if (parameters.showTreePopupWindow !== false) {
       this.icons = [{
         src: OB.Styles.OBFormField.DefaultSearch.pickerIconSrc,
@@ -139,7 +144,9 @@
   },
 
   moved: function () {
-    this.tree.updatePosition();
+    if (this.tree) {
+      this.tree.updatePosition();
+    }
     return this.Super('moved', arguments);
   },