Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
Always update images from the product data This is to avoid stale/cached previews when sequentially opening instances of a modal after uploading a image Still, the more correct thing to do was to teardown the component after we finished dealing with it. And even more to remove riot completely of this, as it behaves completely different from other plugins and it has a incomplete lifecycle inside the current project structure (it mounts some components, but it never tear them down, etc).
plugins/suppliers/public/javascripts/views/product-modal.tag.slim | 10 +
diff --git a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim index 1e04164031022de016ae7e82fde21d7c1845aaa1..1c6a7ccf7522f71858b0d8d0335a6937e277dd9f 100644 --- a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim +++ b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim @@ -120,6 +120,16 @@ this.parent.typeaheadUnitInit($('#p-unit_id'), this.setUnit) }) updateFormValues() { + var self = this + + $(this.root).find('img').each(function(index, element) { + if (self.product.image_big) { + element.src = self.product.image_big + } else { + element.src = "" + } + }) + $(this.root).find('input,textarea').each(function (i,el) { el.value = el.getAttribute('value') })