details:   https://code.openbravo.com/erp/devel/pi/rev/16d51ad008c0
changeset: 13634:16d51ad008c0
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Wed Aug 31 17:56:10 2011 +0200
summary:   Fixed jslint problem

details:   https://code.openbravo.com/erp/devel/pi/rev/b9c2bbdb1ae6
changeset: 13635:b9c2bbdb1ae6
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Wed Aug 31 17:58:02 2011 +0200
summary:   Fixed issue 16919. Now the number of notes in a record will be shown.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  24 +++++++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
           |  15 ++++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
                 |  13 +++++-
 3 files changed, 46 insertions(+), 6 deletions(-)

diffs (146 lines):

diff -r 153b8abe678a -r b9c2bbdb1ae6 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Wed Aug 31 17:19:02 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Wed Aug 31 17:58:02 2011 +0200
@@ -49,6 +49,7 @@
 import org.openbravo.base.structure.ClientEnabled;
 import org.openbravo.base.structure.OrganizationEnabled;
 import org.openbravo.client.application.DynamicExpressionParser;
+import org.openbravo.client.application.Note;
 import 
org.openbravo.client.application.window.servlet.CalloutHttpServletResponse;
 import org.openbravo.client.application.window.servlet.CalloutServletConfig;
 import org.openbravo.client.kernel.BaseActionHandler;
@@ -247,14 +248,18 @@
       long t7 = System.currentTimeMillis();
       List<JSONObject> attachments = attachmentForRows(tab, rowId, 
multipleRowIds);
 
+      // Notes information
+      long t8 = System.currentTimeMillis();
+      int noteCount = computeNoteCount(tab, rowId);
+
       // Construction of the final JSONObject
-      long t8 = System.currentTimeMillis();
+      long t9 = System.currentTimeMillis();
       JSONObject finalObject = buildJSONObject(mode, tab, columnValues, row, 
changeEventCols,
-          calloutMessages, attachments, jsExcuteCode, hiddenInputs);
-      long t9 = System.currentTimeMillis();
+          calloutMessages, attachments, jsExcuteCode, hiddenInputs, noteCount);
+      long t10 = System.currentTimeMillis();
       log.debug("Elapsed time: " + (System.currentTimeMillis() - iniTime) + 
"(" + (t2 - t1) + ","
           + (t3 - t2) + "," + (t4 - t3) + "," + (t5 - t4) + "," + (t6 - t5) + 
"," + (t7 - t6) + ","
-          + (t8 - t7) + "," + (t9 - t8) + ")");
+          + (t8 - t7) + "," + (t9 - t8) + "," + (t10 - t9) + ")");
       log.debug("Attachment exists: " + 
finalObject.getBoolean("attachmentExists"));
       return finalObject;
     } catch (Throwable t) {
@@ -271,6 +276,13 @@
     return null;
   }
 
+  private int computeNoteCount(Tab tab, String rowId) {
+    OBCriteria<Note> criteria = OBDao.getFilteredCriteria(Note.class,
+        Restrictions.eq("table.id", (String) DalUtil.getId(tab.getTable())),
+        Restrictions.eq("record", rowId));
+    return criteria.count();
+  }
+
   private List<String> convertJSONArray(JSONArray jsonArray) {
     List<String> visibleProperties = new ArrayList<String>();
     for (int i = 0; i < jsonArray.length(); i++) {
@@ -312,7 +324,8 @@
 
   private JSONObject buildJSONObject(String mode, Tab tab, Map<String, 
JSONObject> columnValues,
       BaseOBObject row, List<String> changeEventCols, List<JSONObject> 
calloutMessages,
-      List<JSONObject> attachments, List<String> jsExcuteCode, Map<String, 
Object> hiddenInputs) {
+      List<JSONObject> attachments, List<String> jsExcuteCode, Map<String, 
Object> hiddenInputs,
+      int noteCount) {
     JSONObject finalObject = new JSONObject();
     try {
       if (mode.equals("NEW") || mode.equals("CHANGE")) {
@@ -407,6 +420,7 @@
             finalObject.put("_readOnly", true);
           }
         }
+        finalObject.put("noteCount", noteCount);
       }
       finalObject.put("attachments", new JSONArray(attachments));
       finalObject.put("attachmentExists", attachments.size() > 0);
diff -r 153b8abe678a -r b9c2bbdb1ae6 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
       Wed Aug 31 17:19:02 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
       Wed Aug 31 17:58:02 2011 +0200
@@ -38,6 +38,8 @@
   canvasItem : null,
 
   visible : true,
+  
+  noteCount: 0,
  
   // this field group does not participate in personalization
   personalizable: false,
@@ -52,6 +54,15 @@
 
     this.Super('init', arguments);
   },
+  
+  setNoteCount: function(lNoteCount) {
+    this.noteCount = lNoteCount;
+    if(lNoteCount !== 0) {
+      this.setValue(OB.I18N.getLabel('OBUIAPP_NotesTitle') + ' (' + 
lNoteCount+')');
+    }else{
+      this.setValue(OB.I18N.getLabel('OBUIAPP_NotesTitle'));
+    }
+  },
 
   getNotePart : function() {
     if (!this.canvasItem) {
@@ -132,6 +143,8 @@
 
     // clean text area
     this.noteDynamicForm.getItem('noteOBTextAreaItem').clearValue();
+    
+    
this.parentElement.noteSection.setNoteCount(this.parentElement.noteSection.noteCount
 + 1);
   },
 
   /**
@@ -139,11 +152,13 @@
    */
   deleteNote : function( /* note id to delete */id) {
     var noteDS = this.getNoteDataSource();
+    var noteSection = this.parentElement.noteSection;
     isc.confirm(OB.I18N.getLabel('OBUIAPP_ConfirmRemoveNote'), 
function(clickedOK){
       if(clickedOK){
         noteDS.removeData({
           'id' : id
         });
+        noteSection.setNoteCount(noteSection.noteCount - 1);
       }
     },{title: OB.I18N.getLabel('OBUIAPP_ConfirmRemoveTitle')});
   },
diff -r 153b8abe678a -r b9c2bbdb1ae6 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Wed Aug 31 17:19:02 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Wed Aug 31 17:58:02 2011 +0200
@@ -624,13 +624,24 @@
     
     if(retHiddenInputs) {
       for(prop in retHiddenInputs) {
-        this.hiddenInputs[prop] = retHiddenInputs[prop];
+        if(retHiddenInputs.hasOwnProperty(prop)){
+          this.hiddenInputs[prop] = retHiddenInputs[prop];
+        }
       }
     }
     
     if(this.attachmentsSection) {
       this.attachmentsSection.fillAttachments(data.attachments);
     }
+    
+    // We will show the note count if it has been calculated and is different 
from 0
+    if(this.noteSection) {
+      if(data.noteCount) {
+        this.noteSection.setNoteCount(data.noteCount);
+      } else if(request.params.MODE === 'EDIT') {
+        this.noteSection.setNoteCount(0);
+      }
+    }
 
     // apparently sometimes an empty string is returned
     if (calloutMessages && calloutMessages.length > 0 && 
calloutMessages[0].text !== '') {

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to