details:   /erp/devel/pi/rev/f4b726473578
changeset: 11166:f4b726473578
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:43:52 2011 +0100
summary:   Made open window more robust, Fixes issue 16064: Autosave error is 
triggered when closing a tab, even if the form wasn't touched

details:   /erp/devel/pi/rev/1a89209854c6
changeset: 11167:1a89209854c6
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:44:38 2011 +0100
summary:   Made computation of window/tab more robust, take of fragment from ids

details:   /erp/devel/pi/rev/2b4fb6e76d22
changeset: 11168:2b4fb6e76d22
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:45:06 2011 +0100
summary:   Added refresh method to OBDal

details:   /erp/devel/pi/rev/794e4dc0c69c
changeset: 11169:794e4dc0c69c
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:45:47 2011 +0100
summary:   Changed context menu items for record click

details:   /erp/devel/pi/rev/bcdcdbfc5590
changeset: 11170:bcdcdbfc5590
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:46:34 2011 +0100
summary:   Handle small typos in module package name

details:   /erp/devel/pi/rev/e36b3ca87880
changeset: 11171:e36b3ca87880
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 11:47:22 2011 +0100
summary:   Added recent docs functionality

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/ComputeWindowActionHandler.java
                                                     |   15 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
                                      |    5 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-recent-utilities.js
                                                           |   13 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                                                              |   28 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
                                                            |   26 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
                                                                  |   33 ++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                                                                  |    2 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                                                                  |   40 ++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-manager.js
                                                               |    6 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
                                                                              | 
   3 +-
 modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MESSAGE.xml    
                                                                                
   |   11 +
 
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
                                                                              | 
  78 ++++++++-
 
modules/org.openbravo.client.myob/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.myob/images/management/IconRecentDocs.png
 |    0 
 src/org/openbravo/dal/service/OBDal.java                                       
                                                                                
   |   12 +
 15 files changed, 227 insertions(+), 57 deletions(-)

diffs (truncated from 497 to 300 lines):

diff -r 7ef3a62f61f7 -r e36b3ca87880 
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 Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
       Thu Mar 10 11:47:22 2011 +0100
@@ -175,4 +175,16 @@
 <!--FF8081812E7BEED8012E7C2FCFB30063-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--FF8081812E7BEED8012E7C2FCFB30063--></AD_REF_LIST>
 
+<!--FF8081812E9F4334012E9F4855820012--><AD_REF_LIST>
+<!--FF8081812E9F4334012E9F4855820012-->  
<AD_REF_LIST_ID><![CDATA[FF8081812E9F4334012E9F4855820012]]></AD_REF_LIST_ID>
+<!--FF8081812E9F4334012E9F4855820012-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF8081812E9F4334012E9F4855820012-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF8081812E9F4334012E9F4855820012-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF8081812E9F4334012E9F4855820012-->  
<VALUE><![CDATA[OBUIAPP_RecentDocumentsList]]></VALUE>
+<!--FF8081812E9F4334012E9F4855820012-->  
<NAME><![CDATA[OBUIAPP_RecentDocumentsList]]></NAME>
+<!--FF8081812E9F4334012E9F4855820012-->  <DESCRIPTION><![CDATA[Recent 
documents opened by the user]]></DESCRIPTION>
+<!--FF8081812E9F4334012E9F4855820012-->  
<AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--FF8081812E9F4334012E9F4855820012-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FF8081812E9F4334012E9F4855820012--></AD_REF_LIST>
+
 </data>
diff -r 7ef3a62f61f7 -r e36b3ca87880 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ComputeWindowActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ComputeWindowActionHandler.java
     Wed Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ComputeWindowActionHandler.java
     Thu Mar 10 11:47:22 2011 +0100
@@ -49,8 +49,8 @@
 public class ComputeWindowActionHandler extends BaseActionHandler {
 
   protected JSONObject execute(Map<String, Object> parameters, String data) {
-    final String tabId = (String) parameters.get("tabId");
-    final String recordId = (String) parameters.get("recordId");
+    final String tabId = removeFragment((String) parameters.get("tabId"));
+    final String recordId = removeFragment((String) 
parameters.get("recordId"));
 
     try {
       OBContext.setAdminMode();
@@ -102,4 +102,15 @@
       OBContext.restorePreviousMode();
     }
   }
+
+  // solve the case that sometimes the fragment is added to the tabId or the 
record id
+  private String removeFragment(String value) {
+    if (value == null) {
+      return value;
+    }
+    if (value.contains("#")) {
+      return value.substring(0, value.indexOf("#"));
+    }
+    return value;
+  }
 }
diff -r 7ef3a62f61f7 -r e36b3ca87880 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
      Wed Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
      Thu Mar 10 11:47:22 2011 +0100
@@ -109,7 +109,10 @@
   private JSONObject processWindow(Window window, String recordId, String 
entityName)
       throws Exception {
     // create the initial TabInfo
-    final BaseOBObject bob = OBDal.getInstance().get(entityName, recordId);
+    BaseOBObject bob = null;
+    if (entityName != null && recordId != null) {
+      bob = OBDal.getInstance().get(entityName, recordId);
+    }
 
     // special case, no bob
     // find the root tab and return only that
diff -r 7ef3a62f61f7 -r e36b3ca87880 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-recent-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-recent-utilities.js
   Wed Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-recent-utilities.js
   Thu Mar 10 11:47:22 2011 +0100
@@ -93,15 +93,18 @@
         return;
       }
       var currentRecentValue = this.getRecentValue(propertyName);
+      // check if there is already an entry for the new recent
       var currentIndex = -1;
       for (var i = 0; i < currentRecentValue.length; i++) {
-        // if the title is the same then assume they are the same
-        if (currentRecentValue[i].tabTitle && 
+        // if the title is the same then assume they are the same, only 
+        // check this if there is no recentId being used
+        if (!currentRecentValue[i].recentId && currentRecentValue[i].tabTitle 
&& 
             choiceObject.tabTitle && choiceObject.tabTitle === 
currentRecentValue[i].tabTitle) {
           currentIndex = i;
-        } else if (currentRecentValue[i] &&
-        currentRecentValue[i].id === choiceObject.id) {
-          // found it
+        } else  if (currentRecentValue[i].recentId && 
+              choiceObject.recentId && choiceObject.recentId === 
currentRecentValue[i].recentId) {
+            currentIndex = i;
+        } else if (currentRecentValue[i].id && currentRecentValue[i].id === 
choiceObject.id) {
           currentIndex = i;
         }
       }
diff -r 7ef3a62f61f7 -r e36b3ca87880 
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 Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Thu Mar 10 11:47:22 2011 +0100
@@ -485,12 +485,10 @@
     }
     
     url = url + '?tabId=' + this.tabId;
-    if (this.isShowingForm) {
-      if (this.viewForm.isNew && this.isRootView) {
-        url = url + '&command=NEW';
-      } else if (!this.viewForm.isNew) {
-        url = url + '&recordId=' + this.viewGrid.getSelectedRecord().id;
-      }
+    if (this.isShowingForm && this.viewForm.isNew && this.isRootView) {      
+        url = url + '&command=NEW';      
+    } else if (this.viewGrid.getSelectedRecords() && 
this.viewGrid.getSelectedRecords().length === 1) {
+      url = url + '&recordId=' + this.viewGrid.getSelectedRecord().id;
     }
 
     return url;
@@ -592,6 +590,15 @@
     }
   },
   
+  setRecentDocument: function(record) {
+    var params = this.standardWindow.getBookMarkParams();
+    params.targetTabId = this.tabId;
+    params.targetRecordId = record.id;
+    params.recentId = this.tabId + '_' + record.id;
+    params.recentTitle = record[OB.Constants.IDENTIFIER];
+    OB.Layout.ViewManager.addRecentDocument(params);
+  },
+  
   setActiveViewProps: function(state){
     if (state) {
       this.toolBar.show();
@@ -1182,11 +1189,10 @@
       tab.prompt = title;
       tab.showPrompt = true;
       tab.hoverWidth = 150;
-
-      if (title.length > 30) {
-        title = title.substring(0, 30) + "...";
-      }
-
+      
+      // trunc the title if it too large 
+      title = OB.Utilities.truncTitle(title);
+      
       // add the prefix/suffix here to prevent cutoff on that
       title = prefix + title + suffix;
       tabSet.setTabTitle(tab, title);
diff -r 7ef3a62f61f7 -r e36b3ca87880 
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 Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Thu Mar 10 11:47:22 2011 +0100
@@ -252,6 +252,10 @@
   },
   
   closeClick: function(tab, tabSet){
+    if (!this.activeView.viewForm.hasChanged && 
this.activeView.viewForm.isNew) {
+      this.view.standardWindow.setDirtyEditForm(null);
+    }
+
     var actionObject = {
       target: tabSet,
       method: tabSet.doCloseClick,
@@ -299,16 +303,18 @@
           break;
         }
       }
-      
OB.RemoteCallManager.call('org.openbravo.client.application.window.ComputeSelectedRecordActionHandler',
 null, {
-        targetEntity: targetEntity,
-        targetRecordId: this.targetRecordId,
-        windowId: this.windowId
-      }, function(response, data, request){
-        standardWindow.directTabInfo = data.result;
-        standardWindow.view.openDirectTab();
-      });
-      delete this.targetRecordId;
-      delete this.targetTabId;
+      if (targetEntity) {
+        
OB.RemoteCallManager.call('org.openbravo.client.application.window.ComputeSelectedRecordActionHandler',
 null, {
+          targetEntity: targetEntity,
+          targetRecordId: (this.targetRecordId ? this.targetRecordId : null),
+          windowId: this.windowId
+        }, function(response, data, request){
+          standardWindow.directTabInfo = data.result;
+          standardWindow.view.openDirectTab();
+        });
+        delete this.targetRecordId;
+        delete this.targetTabId;
+      }
     } else if (this.command === isc.OBStandardWindow.COMMAND_NEW) {
       var currentView = this.activeView || this.view;
       currentView.editRecord();
diff -r 7ef3a62f61f7 -r e36b3ca87880 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Wed Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Thu Mar 10 11:47:22 2011 +0100
@@ -21,6 +21,21 @@
 // are related to opening views, opening popups, displaying yes/no, etc. 
 OB.Utilities = {};
 
+// ** {{{OB.Utilities.truncTitle}}} **
+// Truncs a string after a specific length. Initial implementation is 
+// simple (just cuts of at the specified length). Returns the trunced title
+// if no cutLength is set then the default length of 30 is chosen. If no
+// suffix is set then ... is appended
+// TODO: more advanced implementations can cut of at a space or dash for 
+// example
+OB.Utilities.truncTitle = function(title, cutLength, suffix){
+  cutLength = cutLength || 30;
+  if (!title || title.length < cutLength) {
+    return title;
+  }
+  return title.substring(0, cutLength) + (suffix || '...');
+};
+
 // ** {{{OB.Utilities.createDialog}}} **
 // Creates a dialog with a title, an ok button and a layout in the middle.
 // The dialog is not shown but returned. The caller needs to call setContent 
to 
@@ -246,6 +261,11 @@
 // is not set then the tab is opened in grid mode. If command is not set then 
default is
 // used.
 OB.Utilities.openDirectTab = function(tabId, recordId, command){
+  
+  tabId = OB.Utilities.removeFragment(tabId);
+  recordId = OB.Utilities.removeFragment(recordId);
+  command = OB.Utilities.removeFragment(command);
+  
   var callback = function(response, data, request){
     command = command || 'DEFAULT';
     var view = {
@@ -272,6 +292,19 @@
   }, callback);
 };
 
+// ** {{{OB.Utilities.removeFragment}}} **
+// remove a # and the rest from a string
+OB.Utilities.removeFragment = function(str) {
+  if (!str) {
+    return str;
+  }
+  var index = str.indexOf('#');
+  if (index !== -1) {
+    return str.substring(0, index);
+  }
+  return str;
+};
+
 // ** {{{OB.Utilities.openView}}} **
 // Open a view taking into account if a specific window should be opened in 
classic mode or not.
 // Returns the object used to open the window.
diff -r 7ef3a62f61f7 -r e36b3ca87880 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Mar 10 11:47:22 2011 +0100
@@ -816,6 +816,8 @@
         //view.messageBar.setMessage(isc.OBMessageBar.TYPE_SUCCESS, null, 
OB.I18N.getLabel('OBUIAPP_SaveSuccess'));
         view.statusBar.setStateLabel('OBUIAPP_Saved', 
view.statusBar.checkedIcon);
         
+        view.setRecentDocument(this.getValues());
+        
         // force a fetch to place the grid on the correct location
         if (form.isNew) {
           view.viewGrid.targetRecordId = data.id;
diff -r 7ef3a62f61f7 -r e36b3ca87880 
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 Mar 09 23:51:07 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Mar 10 11:47:22 2011 +0100
@@ -927,18 +927,7 @@
         });
       }
     }
-    menuItems.add({
-      title: OB.I18N.getLabel('OBUIAPP_CreateRecordInGrid'),
-      click: function(){
-        grid.startEditingNew(rowNum);
-      }
-    });
-    menuItems.add({
-      title: OB.I18N.getLabel('OBUIAPP_CreateRecordInForm'),
-      click: function(){
-        grid.view.newDocument();
-      }
-    });
+
     if (singleSelected && this.canEdit && this.isWritable(record) && 
!this.view.readOnly) {
       menuItems.add({
         title: OB.I18N.getLabel('OBUIAPP_EditInGrid'),
@@ -947,14 +936,27 @@
           grid.startEditing(rowNum, colNum);
         }
       });
-      menuItems.add({
-        title: OB.I18N.getLabel('OBUIAPP_EditInForm'),
-        click: function(){
-          grid.endEditing();
-          grid.view.editRecord(record);
-        }
-      });
+//      menuItems.add({
+//        title: OB.I18N.getLabel('OBUIAPP_EditInForm'),
+//        click: function(){
+//          grid.endEditing();
+//          grid.view.editRecord(record);
+//        }
+//      });
     }
+
+    menuItems.add({

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to