From f9d2c20aaa4ca2c0d47ed00dabbf1b9f209a94d3 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 21 Jan 2014 11:55:26 +0100 Subject: [PATCH] cleanup articles sorted in groups --- .../bootstrap_and_overrides.css.less | 18 +++++++++- app/helpers/application_helper.rb | 9 +++-- .../shared/_articles_by_groups.html.haml | 35 ++++++++++--------- config/locales/de.yml | 4 +-- config/locales/en.yml | 4 +-- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index b87d7185..73cb5a87 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -104,7 +104,7 @@ table { content: ' \25B2'; } - tr.article-category { + tr.list-heading { background-color: #efefef; td:first-child { text-align: left; @@ -126,6 +126,10 @@ table { } } +.center, td.center, th.center { + text-align: center; +} + // Tasks .. .accepted { color: #468847; @@ -238,6 +242,18 @@ tr.unavailable { min-width: 3.5em; } +// small cells with just a 'x' or '=' +td.symbol, th.symbol { + padding-left: 0; + padding-right: 0; + text-align: center; +} +.symbol { color: tint(@textColor, @nonessentialDim); } +.used .symbol { color: tint(@articleUsedColor, @nonessentialDim); } +.unused .symbol { color: tint(@articleUnusedColor, @nonessentialDim); } +.unavailable .symbol { color: @articleUnavailColor; } + + // ********* Tweaks & fixes // Fix bootstrap dropdown menu on mobile diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4a266ece..290bf5e1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,14 +78,17 @@ module ApplicationHelper # When the 'short' option is true, abbreviations will be used: # When there is a non-empty model attribute 'foo', it looks for # the model attribute translation 'foo_short' and use that as - # heading, with an abbreviation title of 'foo'. + # heading, with an abbreviation title of 'foo'. If a translation + # 'foo_desc' is present, that is used instead, but that can be + # be overridden by the option 'desc'. # Other options are passed through to I18n. def heading_helper(model, attribute, options = {}) - i18nopts = options.select {|a| !['short'].include?(a) }.merge({count: 2}) + i18nopts = options.select {|a| !['short', 'desc'].include?(a) }.merge({count: 2}) s = model.human_attribute_name(attribute, i18nopts) if options[:short] + desc = (options[:desc] or model.human_attribute_name("#{attribute}_desc".to_sym, options.merge({fallback: true, default: '', count: 2}))) sshort = model.human_attribute_name("#{attribute}_short".to_sym, options.merge({fallback: true, default: '', count: 2})) - s = raw "#{sshort}" unless sshort.blank? + s = raw "#{sshort}" unless sshort.blank? end s end diff --git a/app/views/shared/_articles_by_groups.html.haml b/app/views/shared/_articles_by_groups.html.haml index e117dcc3..2c0ddf8c 100644 --- a/app/views/shared/_articles_by_groups.html.haml +++ b/app/views/shared/_articles_by_groups.html.haml @@ -2,21 +2,19 @@ %thead.list-heading %tr %th{:style => "width:40%"}= heading_helper Article, :name - %th - %acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered' - %th - %acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received' - %th - %acronym{:title => t('.fc_price_desc')}= t '.fc_price' - %th - %acronym{:title => t('.unit_quantity_desc')}= t '.unit_quantity' %th= heading_helper Article, :unit + %th.center + %acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered' + %th.center{colspan: 2} + %acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received' + %th{colspan: 2}= heading_helper Article, :fc_price, short: true %th= t '.price' + %th= #heading_helper Article, :unit_quantity, short: true - for group_order in order.group_orders.ordered %tbody - %tr - %th{:colspan => "7"} + %tr.list-heading + %th{:colspan => "9"} %h4.name= group_order.ordergroup.name - total = 0 - for goa in group_order.group_order_articles.ordered.all(:include => :order_article) @@ -25,16 +23,19 @@ - total += subTotal %tr{:class => [cycle('even', 'odd', :name => 'articles'), if goa.result == 0 then 'unavailable' end]} %td.name{:style => "width:40%"}=h goa.order_article.article.name - %td= "#{goa.quantity} + #{goa.tolerance}" - %td - %b= goa.result - %td= number_to_currency(fc_price) - %td= goa.order_article.price.unit_quantity %td= goa.order_article.article.unit + %td.center= "#{goa.quantity} + #{goa.tolerance}" + %td.center + %b= goa.result + %td.symbol × + %td= number_to_currency(fc_price) + %td.symbol = %td= number_to_currency(subTotal) + %td= pkg_helper goa.order_article.price %tr{:class => cycle('even', 'odd', :name => 'articles')} - %th{:colspan => "6"} Summe + %th{:colspan => "7"}= t '.price_sum' %th= number_to_currency(total) + %th %tr - %th(colspan="7") + %th(colspan="9") - reset_cycle("articles") diff --git a/config/locales/de.yml b/config/locales/de.yml index cefa289f..3d522af0 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -7,6 +7,7 @@ de: availability_short: verf. deposit: Pfand fc_price: Endpreis + fc_price_desc: Preis incl. MwSt, Pfand und Foodcoop-Aufschlag fc_price_short: FC-Preis fc_share: FoodCoop-Aufschlag fc_share_short: FC-Aufschlag @@ -1285,9 +1286,8 @@ de: ordergroup: Bestellgruppe price: Gesamtpreis articles_by_groups: - fc_price: FC-Preis - fc_price_desc: Preis incl. MwSt, Pfand und Foodcoop-Aufschlag price: Gesamtpreis + price_sum: Summe unit_quantity: GebGr unit_quantity_desc: Gebindegröße group: diff --git a/config/locales/en.yml b/config/locales/en.yml index 7403cbaf..a305d464 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -7,6 +7,7 @@ en: availability_short: avail. deposit: Deposit fc_price: FoodCoop price + fc_price_desc: Price including taxes, deposit and Foodcoop-charge fc_price_short: FC price fc_share: FoodCoop margin fc_share_short: FC margin @@ -1297,9 +1298,8 @@ en: ordergroup: Ordergroup price: Total price articles_by_groups: - fc_price: FC-Price - fc_price_desc: Price including taxes, deposit and Foodcoop-charge price: Total price + price_sum: Sum unit_quantity: Lot quantity unit_quantity_desc: How many units per lot. group: