details:   /erp/devel/pi/rev/71bddb24ab5e
changeset: 10336:71bddb24ab5e
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Wed Feb 02 17:47:26 2011 +0100
summary:   Now the state of the grid will be saved and restored when the window 
is opened again

diffstat:

 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
                           |  12 ++++
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java
 |   8 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js
         |  16 +++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
          |   3 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
        |  11 ++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
              |  26 ++++++++++
 6 files changed, 67 insertions(+), 9 deletions(-)

diffs (172 lines):

diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
       Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
       Wed Feb 02 17:47:26 2011 +0100
@@ -139,6 +139,18 @@
 <!--CF6EAC4255D0484399EF03DB23376CD5-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--CF6EAC4255D0484399EF03DB23376CD5--></AD_REF_LIST>
 
+<!--FF8080812DE1CD58012DE1FC1FB9002F--><AD_REF_LIST>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_REF_LIST_ID><![CDATA[FF8080812DE1CD58012DE1FC1FB9002F]]></AD_REF_LIST_ID>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<VALUE><![CDATA[OBUIAPP_GridConfiguration]]></VALUE>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  <NAME><![CDATA[Grid 
Configuration]]></NAME>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  <DESCRIPTION><![CDATA[Contains the 
configuration of the grid for a particular window]]></DESCRIPTION>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--FF8080812DE1CD58012DE1FC1FB9002F-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FF8080812DE1CD58012DE1FC1FB9002F--></AD_REF_LIST>
+
 <!--FF8081812DB867FE012DB86CD07D0017--><AD_REF_LIST>
 <!--FF8081812DB867FE012DB86CD07D0017-->  
<AD_REF_LIST_ID><![CDATA[FF8081812DB867FE012DB86CD07D0017]]></AD_REF_LIST_ID>
 <!--FF8081812DB867FE012DB86CD07D0017-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java
     Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java
     Wed Feb 02 17:47:26 2011 +0100
@@ -29,6 +29,7 @@
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.model.ad.ui.Window;
 
 /**
  * Is responsible for storing a preference.
@@ -50,9 +51,14 @@
             "{msg: 'No property name in request, ignoring property store 
request'}");
       }
       final String cleanedData = data == null ? null : data.replaceAll("\\n", 
"");
+      String windowId = (String) parameters.get("windowId");
+      Window window = null;
+      if (windowId != null) {
+        window = OBDal.getInstance().get(Window.class, windowId);
+      }
       Preferences.setPreferenceValue(propertyName, cleanedData, true, 
OBContext.getOBContext()
           .getCurrentClient(), 
OBContext.getOBContext().getCurrentOrganization(), OBContext
-          .getOBContext().getUser(), OBContext.getOBContext().getRole(), null, 
null);
+          .getOBContext().getUser(), OBContext.getOBContext().getRole(), 
window, null);
       OBDal.getInstance().flush();
       return new JSONObject("{msg: 'Property Stored'}");
     } catch (Exception e) {
diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js
     Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js
     Wed Feb 02 17:47:26 2011 +0100
@@ -74,20 +74,22 @@
     // * {{{propertyName}}}: the name of the property
     // * {{{value}}}: the value of the property
     //
-    set: function(/* String */propertyName, /* Object */ value){
-      var currentValue = OB.Properties[propertyName];
+    set: function(/* String */propertyName, /* Object */ value, windowId){
+      var currentValue = OB.Properties[propertyName], data={property: 
propertyName}, localPropertyName=propertyName;
+      if(windowId){
+       data.windowId=windowId;
+       localPropertyName=propertyName + '_' + windowId;
+      }
       // set it locally
-      OB.Properties[propertyName] = value;
+      OB.Properties[localPropertyName] = value;
       
       // and set it in the server also
-      
OB.RemoteCallManager.call('org.openbravo.client.application.StorePropertyActionHandler',
 value, {
-        property: propertyName
-      }, function(){
+      
OB.RemoteCallManager.call('org.openbravo.client.application.StorePropertyActionHandler',
 value, data, function(){
       });
       
       // call the listeners
       for (var i = 0; i < this.listeners.length; i++) {
-        this.listeners[i](propertyName, currentValue, value);
+        this.listeners[i](localPropertyName, currentValue, value);
       }
       
     },
diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 02 17:47:26 2011 +0100
@@ -231,7 +231,6 @@
     this.createMainParts();
     this.createViewStructure();
     this.dataSource.view = this;
-    this.viewGrid.setDataSource(this.dataSource, this.viewGrid.completeFields 
|| this.viewGrid.fields);
     
     // directTabInfo is set when we are in direct link mode, i.e. directly 
opening
     // a specific tab with a record, the direct link logic will already take 
care
@@ -351,6 +350,8 @@
         }
       });
       
+      this.viewGrid.setDataSource(this.dataSource, 
this.viewGrid.completeFields || this.viewGrid.fields);
+      
       if (this.viewGrid) {
         this.viewGrid.setWidth('100%');
         this.viewGrid.setView(this);
diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Wed Feb 02 17:47:26 2011 +0100
@@ -79,6 +79,7 @@
     if (this.command === isc.OBStandardWindow.COMMAND_NEW) {
       this.viewProperties.allowDefaultEditMode = false;
     }
+    
this.viewState=OB.PropertyStore.get("OBUIAPP_GridConfiguration",this.windowId);
     this.view = isc.OBStandardView.create(this.viewProperties);
     this.addView(this.view);
     this.addMember(this.view);
@@ -270,5 +271,15 @@
       return false;
     }
     return this.isEqualParams(params) && viewName === this.getClassName();
+  },
+  
+  storeViewState: function(){
+       var result={};
+    for (var i = 0; i < this.views.length; i++) {
+      if(this.views[i].viewGrid){
+        result[this.views[i].tabId]=this.views[i].viewGrid.getViewState();
+      }
+    }
+       OB.PropertyStore.set('OBUIAPP_GridConfiguration', result, 
this.windowId);
   }
 });
diff -r 75e8581e0906 -r 71bddb24ab5e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Wed Feb 02 17:28:31 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Wed Feb 02 17:47:26 2011 +0100
@@ -235,6 +235,9 @@
   setView: function(view){
     this.view = view;
     this.editFormDefaults.view = view;
+    if(this.view.standardWindow.viewState && 
this.view.standardWindow.viewState[this.view.tabId]){
+       this.setViewState(this.view.standardWindow.viewState[this.view.tabId]); 
+    }
   },
   
   show: function(){
@@ -1052,6 +1055,29 @@
   isEditLinkColumn: function(colNum){
     var fieldName = this.getFieldName(colNum);
     return (fieldName === isc.OBViewGrid.EDIT_LINK_FIELD_NAME);
+  },
+  
+  reorderField: function(fieldNum, moveToPosition){
+       var res = this.Super('reorderField', arguments);
+       this.view.standardWindow.storeViewState();
+       return res;
+  },
+  
+  hideField: function(field, suppressRelayout){
+       var res =  this.Super('hideField', arguments);
+       this.view.standardWindow.storeViewState();
+       return res;
+  },
+  
+  showField: function(field, suppressRelayout){
+       var res =  this.Super('showField', arguments);
+       this.view.standardWindow.storeViewState();
+       return res;
+  },
+  
+  resizeField: function(fieldNum, newWidth, storeWidth){
+       this.view.standardWindow.storeViewState();
+       return this.Super('resizeField', arguments);
   }
   
 });

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to