Author: Hugo Melo <hugo@riseup.net>
Merge branch 'master' of https://github.com/samasti/noosfero
plugins/suppliers/public/javascripts/views/consumer-box.tag.slim | 2 plugins/suppliers/public/javascripts/views/consumer-view.tag.slim | 12 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/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'); } 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() {