details:   https://code.openbravo.com/erp/devel/pi/rev/82a3e88a20e8
changeset: 32887:82a3e88a20e8
user:      Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date:      Sat Oct 28 13:27:49 2017 +0200
summary:   Related with issue 36838: multiple requests to load product image 
are performed

The problem was that multiple ShowImage requests were performed when it 
shouldn't.

Now, the problem is fixed by take into account when the image has been loaded 
previously. In this case,
the setValue of the ob-formitem-image avoids to performed an unnecessary 
request to the server.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js
 |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 8071a84ccfe2 -r 82a3e88a20e8 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js
       Fri Oct 20 11:58:31 2017 +0530
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js
       Sat Oct 28 13:27:49 2017 +0200
@@ -241,8 +241,10 @@
     if (!newValue || newValue === '') {
       this.canvas.setImage('');
     } else {
-      this.canvas.setImage("../utility/ShowImage?id=" + newValue + '&nocache=' 
+ Math.random());
-      if (this.getValue() !== newValue) {
+      if (this.isLoadedCurrentImage(newValue)) {
+        this.canvas.setImage(this.canvas.image.src);
+      } else {
+        this.canvas.setImage("../utility/ShowImage?id=" + newValue + 
'&nocache=' + Math.random());
         var d = {
           inpimageId: newValue,
           command: 'GETSIZE'
@@ -276,6 +278,9 @@
     this.canvas.selectorButton.updateState((this.form && !this.form.readOnly) 
&& !this.disabled);
     return this.Super('setValue', arguments);
   },
+  isLoadedCurrentImage: function (imageId) {
+    return this.canvas.image && this.canvas.image.src && 
this.canvas.image.src.contains('ShowImage?id=' + imageId);
+  },
   refreshImage: function (imageId) {
     //If creating/replacing an image, the form is marked as modified
     //and the image id is set as the value of the item

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to