cirandas.net

commit 9dc3e90ea7ec52a1c40bc0abef3f952b27ceb9dd

Author: Hugo Melo <hugo@riseup.net>

Fix consumers elements and inputs not being updated on update()

 plugins/suppliers/public/javascripts/views/consumer-box.tag.slim | 2 
 plugins/suppliers/public/javascripts/views/consumer-view.tag.slim | 12 


diff --git a/plugins/suppliers/public/javascripts/views/consumer-box.tag.slim b/plugins/suppliers/public/javascripts/views/consumer-box.tag.slim
index 543c50c9f8a679bc15c4c47f6600eb172ee70693..7f9ec36fedb09ddd44b31883cfdb349f763ce162 100644
--- a/plugins/suppliers/public/javascripts/views/consumer-box.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/consumer-box.tag.slim
@@ -19,7 +19,7 @@               |{t('views.consumer.index.active')}
             .state if="{!consumer.active}"
               |{t('views.consumer.index.inactive')}
       div.col-xs-3
-        button 
+        button
           |{t('views.consumer.index.detail')}
 
   javascript:




diff --git a/plugins/suppliers/public/javascripts/views/consumer-view.tag.slim b/plugins/suppliers/public/javascripts/views/consumer-view.tag.slim
index 9c10b5c03023b4f8df93016d91354a3d6092492b..096bef66dbe38f52983e4632a87c65e88f396e9c 100644
--- a/plugins/suppliers/public/javascripts/views/consumer-view.tag.slim
+++ b/plugins/suppliers/public/javascripts/views/consumer-view.tag.slim
@@ -13,9 +13,9 @@                 h1
                   |{consumer.name}
                   span if="{consumer.name != consumer.profile_name}"
                     |  ({consumer.profile_name})
-              a.cs-button href="" onclick='{remove}' 
+              a.cs-button href="" onclick='{remove}'
                 |{cs.t("views.consumer.index.remove")}
-              a.cs-button href="" onclick='{toggle}' if="{consumer.active}" 
+              a.cs-button href="" onclick='{toggle}' if="{consumer.active}"
                 |{cs.t("views.consumer.index.disable")}
               a.cs-button href="" onclick='{toggle}' if="{!consumer.active}"
                 |{cs.t("views.consumer.index.enable")}
@@ -143,6 +143,12 @@       this.consumerUrl = Routes.profile_path({profile: this.consumer.identifier})
       if (this.consumer.purchases == undefined)
         this.consumer.purchases = {}
       this.purchases = this.consumer.purchases
+      $(this.root).find('input,textarea').each(function (i,el) {
+        el.value = el.getAttribute('value')
+      })
+      $(this.root).find('select').each(function (i,el) {
+        $(el).val(this.consumer[$(el).attr("name")])
+      }.bind(this))
     }
     this.setConsumer(opts.consumer)
 
@@ -186,7 +192,7 @@         var self = this
         $.get(purchasesUrl, {}, function(purchases) {
           purchases.forEach(function(p) {
             self.consumer.purchases.push(p);
-          }) 
+          })
           self.update();
         }, 'json');
       }