Commit 8c66d3773b03b2f7cd97ec61aeca220bef0a098e
1 parent
e2854d1b
Exists in
master
and in
22 other branches
Fixed problem with NaN on progressbar
Showing
6 changed files
with
25 additions
and
27 deletions
Show diff stats
app/controllers/my_profile/manage_products_controller.rb
| @@ -138,7 +138,7 @@ class ManageProductsController < ApplicationController | @@ -138,7 +138,7 @@ class ManageProductsController < ApplicationController | ||
| 138 | 138 | ||
| 139 | def display_inputs_cost | 139 | def display_inputs_cost |
| 140 | @product = @profile.products.find(params[:id]) | 140 | @product = @profile.products.find(params[:id]) |
| 141 | - render :partial => 'inputs_cost' | 141 | + render :inline => "<%= float_to_currency(@product.inputs_cost) %>" |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | def destroy | 144 | def destroy |
app/views/manage_products/_display_price_details.rhtml
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | <li> | 5 | <li> |
| 6 | <div class='price-detail-name'><%= _('Inputs:') %></div> | 6 | <div class='price-detail-name'><%= _('Inputs:') %></div> |
| 7 | <div class='price-detail-price inputs-cost'> | 7 | <div class='price-detail-price inputs-cost'> |
| 8 | - <%= render :partial => 'inputs_cost' %> | 8 | + <span><%= float_to_currency(@product.inputs_cost) %></span> |
| 9 | </div> | 9 | </div> |
| 10 | </li> | 10 | </li> |
| 11 | <% @product.price_details.each do |price_detail| %> | 11 | <% @product.price_details.each do |price_detail| %> |
app/views/manage_products/_inputs_cost.rhtml
app/views/manage_products/_manage_product_details.rhtml
| @@ -7,8 +7,12 @@ | @@ -7,8 +7,12 @@ | ||
| 7 | <table id='display-product-price-details'> | 7 | <table id='display-product-price-details'> |
| 8 | <tr> | 8 | <tr> |
| 9 | <td><%= _('Inputs') %></td> | 9 | <td><%= _('Inputs') %></td> |
| 10 | - <td class='inputs-cost'><%= float_to_currency(@product.inputs_cost) %></td> | ||
| 11 | - <td><small><%= _('This value is composed by the total value of registered inputs') %></small></td> | 10 | + <td class='inputs-cost'> |
| 11 | + <span><%= float_to_currency(@product.inputs_cost) %></span> | ||
| 12 | + </td> | ||
| 13 | + <td> | ||
| 14 | + <small><%= _('This value is composed by the total value of registered inputs') %></small> | ||
| 15 | + </td> | ||
| 12 | </tr> | 16 | </tr> |
| 13 | <%= render :partial => 'edit_price_details', :locals => {:price_details => @product.price_details} %> | 17 | <%= render :partial => 'edit_price_details', :locals => {:price_details => @product.price_details} %> |
| 14 | </table> | 18 | </table> |
app/views/manage_products/_price_composition_bar.rhtml
| @@ -17,7 +17,6 @@ | @@ -17,7 +17,6 @@ | ||
| 17 | <%= price_composition_progressbar_text(@product) %> | 17 | <%= price_composition_progressbar_text(@product) %> |
| 18 | </div> | 18 | </div> |
| 19 | </div> | 19 | </div> |
| 20 | - <div id='progressbar-icon' class='ui-icon ui-icon-info'></div> | ||
| 21 | - <span id='price-not-described-message' style='display:none'><%= _("The production cost of your product is not described yet. If you want to display the price composition, please add all the costs") %></span> | ||
| 22 | - <span id='price-described-message' style='display:none'><%= _("The production cost of your product is fully described and will be displayed on your product's page") %></span> | 20 | + <div id='progressbar-icon' class='ui-icon ui-icon-info' data-price-not-described-message='<%= _("The production cost of your product is not described yet. If you want to display the price composition, please add all the costs") %>' data-price-described-message='<%= _("The production cost of your product is fully described and will be displayed on your product's page") %>' data-price-described-notice='<%= _("Congratulations! Now the price is open to the public") %>'> |
| 21 | +</div> | ||
| 23 | </div> | 22 | </div> |
public/javascripts/manage-products.js
| @@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
| 32 | $("#manage-product-details-button").show(); | 32 | $("#manage-product-details-button").show(); |
| 33 | }); | 33 | }); |
| 34 | if ($('#progressbar-icon').hasClass('ui-icon-check')) { | 34 | if ($('#progressbar-icon').hasClass('ui-icon-check')) { |
| 35 | - display_notice($('#price-described-notice').show()); | 35 | + display_notice($('#progressbar-icon').attr('data-price-described-notice')); |
| 36 | } | 36 | } |
| 37 | return false; | 37 | return false; |
| 38 | }); | 38 | }); |
| @@ -55,11 +55,11 @@ | @@ -55,11 +55,11 @@ | ||
| 55 | 55 | ||
| 56 | $("form.edit_input").live('submit', function(data) { | 56 | $("form.edit_input").live('submit', function(data) { |
| 57 | var form = this; | 57 | var form = this; |
| 58 | - updatePriceCompositionBar(form); | ||
| 59 | inputs_cost_update_url = $(form).find('#inputs-cost-update-url').val(); | 58 | inputs_cost_update_url = $(form).find('#inputs-cost-update-url').val(); |
| 60 | $.get(inputs_cost_update_url, function(data){ | 59 | $.get(inputs_cost_update_url, function(data){ |
| 61 | $(".inputs-cost span").html(data); | 60 | $(".inputs-cost span").html(data); |
| 62 | }); | 61 | }); |
| 62 | + updatePriceCompositionBar(form); | ||
| 63 | return false; | 63 | return false; |
| 64 | }); | 64 | }); |
| 65 | 65 | ||
| @@ -71,18 +71,18 @@ | @@ -71,18 +71,18 @@ | ||
| 71 | $("#display-manage-price-details").html(''); | 71 | $("#display-manage-price-details").html(''); |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | - function updatePriceCompositionBar(form) { | ||
| 75 | - bar_url = $(form).find('.bar-update-url').val(); | ||
| 76 | - $.get(bar_url, function(data){ | ||
| 77 | - $("#price-composition-bar").html(data); | ||
| 78 | - $('form #product_price').val(currencyToFloat($('#progressbar-text .product_price').html(), currency_format.separator, currency_format.delimiter)); | ||
| 79 | - $('form #product_inputs_cost').val(currencyToFloat($('#display-product-price-details .inputs-cost span').html(), currency_format.separator, currency_format.delimiter, currency_format.unit)); | ||
| 80 | - calculateValuesForBar(); | ||
| 81 | - }); | ||
| 82 | - }; | ||
| 83 | - | ||
| 84 | })(jQuery); | 74 | })(jQuery); |
| 85 | 75 | ||
| 76 | +function updatePriceCompositionBar(form) { | ||
| 77 | + bar_url = jQuery(form).find('.bar-update-url').val(); | ||
| 78 | + jQuery.get(bar_url, function(data){ | ||
| 79 | + jQuery("#price-composition-bar").html(data); | ||
| 80 | + jQuery('form #product_price').val(currencyToFloat(jQuery('#progressbar-text .product_price').html(), currency_format.separator, currency_format.delimiter)); | ||
| 81 | + jQuery('form #product_inputs_cost').val(currencyToFloat(jQuery('#display-product-price-details .inputs-cost span').html(), currency_format.separator, currency_format.delimiter, currency_format.unit)); | ||
| 82 | + calculateValuesForBar(); | ||
| 83 | + }); | ||
| 84 | +}; | ||
| 85 | + | ||
| 86 | function enablePriceDetailSubmit() { | 86 | function enablePriceDetailSubmit() { |
| 87 | jQuery('#manage-product-details-form input.submit').removeAttr("disabled").removeClass('disabled'); | 87 | jQuery('#manage-product-details-form input.submit').removeAttr("disabled").removeClass('disabled'); |
| 88 | } | 88 | } |
| @@ -125,7 +125,7 @@ function floatToCurrency(value, sep, del, cur) { | @@ -125,7 +125,7 @@ function floatToCurrency(value, sep, del, cur) { | ||
| 125 | 125 | ||
| 126 | function currencyToFloat(value, sep, del, cur) { | 126 | function currencyToFloat(value, sep, del, cur) { |
| 127 | var val = value; | 127 | var val = value; |
| 128 | - if (cur) val.replace(cur + ' ', ''); | 128 | + if (cur) val = val.replace(cur + ' ', ''); |
| 129 | if (!sep) sep = '.'; | 129 | if (!sep) sep = '.'; |
| 130 | if (!del) del = ','; | 130 | if (!del) del = ','; |
| 131 | return parseFloat(val.replace(del, '').replace(sep, '.')); | 131 | return parseFloat(val.replace(del, '').replace(sep, '.')); |
| @@ -166,11 +166,11 @@ function priceCompositionBar(value, described, total_cost, price) { | @@ -166,11 +166,11 @@ function priceCompositionBar(value, described, total_cost, price) { | ||
| 166 | $(bar_area).find('.product_price').html(floatToCurrency(price, currency_format.separator, currency_format.delimiter)); | 166 | $(bar_area).find('.product_price').html(floatToCurrency(price, currency_format.separator, currency_format.delimiter)); |
| 167 | if (described) { | 167 | if (described) { |
| 168 | $(bar_area).find('#progressbar-icon').addClass('ui-icon-check'); | 168 | $(bar_area).find('#progressbar-icon').addClass('ui-icon-check'); |
| 169 | - $(bar_area).find('#progressbar-icon').attr('title', $('#price-described-message').html()); | 169 | + $(bar_area).find('#progressbar-icon').attr('title', $('#progressbar-icon').attr('data-price-described-message')); |
| 170 | $(bar_area).find('div.ui-progressbar-value').addClass('price-described'); | 170 | $(bar_area).find('div.ui-progressbar-value').addClass('price-described'); |
| 171 | } else { | 171 | } else { |
| 172 | $(bar_area).find('#progressbar-icon').removeClass('ui-icon-check'); | 172 | $(bar_area).find('#progressbar-icon').removeClass('ui-icon-check'); |
| 173 | - $(bar_area).find('#progressbar-icon').attr('title', $('#price-not-described-message').html()); | 173 | + $(bar_area).find('#progressbar-icon').attr('title', $('#progressbar-icon').attr('data-price-not-described-message')); |
| 174 | $(bar_area).find('div.ui-progressbar-value').removeClass('price-described'); | 174 | $(bar_area).find('div.ui-progressbar-value').removeClass('price-described'); |
| 175 | 175 | ||
| 176 | } | 176 | } |