Fixes issue 18381: Forms personalization does not persist personalized layout
authorMartin Taal <martin.taal@openbravo.com>
Wed, 31 Aug 2011 20:54:22 +0200
changeset 13638 8608083895a6
parent 13637 144538d99c98
child 13639 ecb8f9e371a5
Fixes issue 18381: Forms personalization does not persist personalized layout
Store personalization on window class level and update when the user changes the layout
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Wed Aug 31 20:06:35 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Wed Aug 31 20:54:22 2011 +0200
@@ -89,6 +89,8 @@
     // method is also called explicitly from the personalization window
     if (!this.getClass().windowSettingsRead) {
       this.readWindowSettings();
+    } else if (this.getClass().personalization) {
+      OB.Personalization.personalizeWindow(this.getClass().personalization, this);
     }
   },
   
@@ -114,6 +116,7 @@
     if (this.getClass().windowSettingsRead) {
       return;
     }
+    this.getClass().personalization = data.personalization;
     this.getClass().windowSettingsRead = true;
     this.getClass().uiPattern = data.uiPattern;
     this.getClass().autoSave = data.autoSave;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Wed Aug 31 20:06:35 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Wed Aug 31 20:54:22 2011 +0200
@@ -590,6 +590,8 @@
         'org.openbravo.client.application.personalization.PersonalizationActionHandler', 
         this.getPersonalizationFields(), params,
         function(resp, data, req){
+          var personalization;
+          
           // if there is no personalization data then create it
           if (!me.personalizationData) {
             me.personalizationData = {};
@@ -621,6 +623,12 @@
           if (callback) {
             callback();
           }
+          
+          // update the information in the global class
+          // so that the settings are maintained when the window
+          // is re-opened
+          personalization = me.getStandardWindow().getClass().personalization;
+          personalization[me.tabId] = me.personalizationData;          
         });
   },
 
@@ -656,6 +664,9 @@
           me.hasBeenDeleted = true;
           // close when returned
           me.doClose(true);
+          
+          personalization = me.getStandardWindow().getClass().personalization;
+          personalization[me.tabId] = null;          
         }
      );
   },
@@ -925,6 +936,14 @@
     }
   },
   
+  getStandardWindow: function() {
+    if (this.openedFromMaintenanceWindow) {
+      return this.maintenanceView.standardWindow;
+    } else {
+      return this.form.view.standardWindow;
+    }
+  },
+  
   // close the form personalizer, refresh the existing form so that 
   // the changes are shown immediately, or if called from the 
   // maintenance window refresh the record there