cirandas.net

commit 7a305b9dda8a0313e263428a96d89072fb00c0cf

Author: Hugo Melo <hugo@riseup.net>

Fix add product form not being updated with new values

 plugins/suppliers/public/javascripts/views/product-modal.tag.slim | 11 
 plugins/suppliers/public/javascripts/views/product-page.tag.slim | 6 


diff --git a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
index f9533cf1b9f259d0755330637a403d41fc993306..c2ff7a7d3cde63a06741174cfaa6bb021885ee97 100644
--- a/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-modal.tag.slim
@@ -31,7 +31,8 @@                 label for="p-name"
                   |{t("views.product.product_name")}
                 small.title if="{product.id}"
                   |{t("views.product.name_change_warning")}
-                input type="text" value="{product.name}" id="p-name"
+                input type="text" value="{product.name}" id="p-name" name='name'
+
                 small.supplier_product_name show="{product.supplier_product_name != product.name && product.supplier_product_name != undefined}"
                   strong
                     |{t("views.product.supplier_product_name")}
@@ -44,7 +45,7 @@
               .form-group
                 label for="p-description"
                   |{t("views.product.description")}
-                textarea value="{product.description}" id="p-description"
+                textarea value="{product.description}" id="p-description" name='description'
 
               .form-group
                 label for="p-product_category_id"
@@ -116,6 +117,12 @@     this.on('mount', function () {
       this.parent.typeaheadCategoryInit($('#p-product_category_id'), this.setCategory)
       this.parent.typeaheadUnitInit($('#p-unit_id'), this.setUnit)
     })
+
+    updateFormValues() {
+      $(this.root).find('input,textarea').each(function (i,el) {
+        el.value = el.getAttribute('value')
+      })
+    }
 
     setCategory(e, item) {
       this.product.product_category_id             = item.id




diff --git a/plugins/suppliers/public/javascripts/views/product-page.tag.slim b/plugins/suppliers/public/javascripts/views/product-page.tag.slim
index 8c3f4bbbd3c98247e55f893e3a8f677d4c7fd967..928445c04965b1c7dca2682d4ac47ff603b0596b 100644
--- a/plugins/suppliers/public/javascripts/views/product-page.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/product-page.tag.slim
@@ -251,8 +251,7 @@     completeEdition(product, productItem) {
       this.tags['product-modal'].product = product
       this.tags['product-modal'].productItem = productItem
       this.tags['product-modal'].update()
-      // riot is buggy!!
-      $("#p-description").val(this.tags['product-modal'].product.description)
+      this.tags['product-modal'].updateFormValues()
     }
 
     typeaheadCategoryInit (input, selected) {
@@ -286,6 +285,9 @@         { displayKey: 'name', source: source.ttAdapter() }
       )
 
       input.on('typeahead:selected', selected)
+    }
+
+    import() {
     }
 
     add() {