Add tooltip for article prices

This commit is contained in:
Julius 2013-06-26 19:57:38 +02:00
parent 2ee7f716ae
commit 8a79dfd167
9 changed files with 41 additions and 15 deletions

View file

@ -61,6 +61,8 @@
return true;
}
});
enablePriceTooltips();
});
function mark_article_for_delivery(stock_article_id) {
@ -78,6 +80,14 @@
return ( 0 == $('#stock_change_stock_article_' + stock_article_id).length );
}
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left'
});
}
= simple_form_for [@supplier, @delivery], validate: true do |f|
= f.error_notification
= base_errors f.object

View file

@ -1,7 +1,7 @@
- css_class = ( @delivery and @delivery.includes_article? article ) ? ( 'unavailable' ) : ( false )
%tr{:id => "stock_article_#{article.id}", :class => css_class}
%td.sort-by-name= article.name
%td #{number_to_currency article.price}/#{article.unit}
%td{:data => {:toggle => :tooltip, :title => render(:partial => 'shared/article_price_info', :locals => {:article => article})}} #{number_to_currency article.price}/#{article.unit}
%td.sort-by-category= article.article_category.name
%td
.btn-group

View file

@ -4,6 +4,6 @@
%td.sort-by-name
%span.stock_article_name= stock_change.stock_article.name
= f.association :stock_article, :as => :hidden
%td.price-per-unit #{number_to_currency stock_article.price}/#{stock_change.stock_article.unit}
%td.price-per-unit{:data => {:toggle => :tooltip, :title => render(:partial => 'shared/article_price_info', :locals => {:article => stock_article})}} #{number_to_currency stock_article.price}/#{stock_change.stock_article.unit}
%td= f.input :quantity, :wrapper => :intable, :input_html => {:class => 'stock-change-quantity', :autocomplete => :off}
%td= stock_change_remove_link f

View file

@ -8,6 +8,7 @@
var stock_change = $(
'<%= j(render(:partial => 'stock_change', :locals => {:stock_change => @stock_change})) %>'
).addClass('success');
enablePriceTooltips(stock_change);
$('#stock_changes').append(stock_change);
mark_article_for_delivery(<%= @stock_change.stock_article.id %>);

View file

@ -2,13 +2,16 @@ $('div.container-fluid').prepend(
'<%= j(render(:partial => 'shared/alert_success', :locals => {:alert_message => t('.notice', :name => @stock_article.name)})) %>'
);
(function() {
$('#stock_articles_for_adding tr').removeClass('success');
$('#stock_articles_for_adding tbody').append(
$(
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
).addClass('success')
);
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
$('#stock_articles_for_adding tbody').append(stock_article_for_adding);
updateSort('#stock_articles_for_adding');
})();
$('#modalContainer').modal('hide');

View file

@ -7,18 +7,15 @@ $('div.container-fluid').prepend(
$('#stock_articles_for_adding tr').removeClass('success');
var old_entry = $('#stock_article_<%= @stock_article.id %>');
var unavailable = old_entry.hasClass('unavailable');
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article, :delivery => @delivery})) %>'
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
old_entry.replaceWith(stock_article_for_adding);
$('#stock_article_<%= @stock_article.id %>').replaceWith(stock_article_for_adding);
updateSort('#stock_articles_for_adding');
if(unavailable) {
mark_article_unavailable_for_delivery(<%= @stock_article.id %>);
}
mark_article_for_delivery(<%= @stock_article.id %>);
// update entry in stock_changes table

View file

@ -0,0 +1,13 @@
%table.table.table-condensed
%tr
%th= t 'activerecord.attributes.article.price'
%td.numeric= number_to_currency article.price
%tr
%th= t 'activerecord.attributes.article.deposit'
%td.numeric= number_to_currency article.deposit
%tr
%th= t 'activerecord.attributes.article.tax'
%td.numeric= number_to_percentage article.tax
%tr
%th= t 'activerecord.attributes.article.fc_price'
%td.numeric= number_to_currency article.fc_price

View file

@ -39,6 +39,7 @@ de:
article_category: Kategorie
availability: Artikel ist verfügbar?
deposit: Pfand
fc_price: Endpreis
gross_price: Bruttopreis
price: Nettopreis
tax: MwSt

View file

@ -39,6 +39,7 @@ en:
article_category: article category
availability: Is article available?
deposit: deposit
fc_price: FC price
gross_price: gross price
price: price
tax: VAT