From 5b6d1a66a6177a5590a923fcb68e83b6ed7db038 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 17 Jan 2014 14:25:06 +0100 Subject: [PATCH] complete show order i18n Conflicts: app/helpers/orders_helper.rb --- app/helpers/orders_helper.rb | 19 +++++++++++ app/views/orders/show.html.haml | 60 ++++++++++++++++++--------------- config/locales/en.yml | 6 +++- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb index 7eb822ab..886e7bda 100644 --- a/app/helpers/orders_helper.rb +++ b/app/helpers/orders_helper.rb @@ -79,4 +79,23 @@ module OrdersHelper input_html.html_safe end + + def ordergroup_count(order) + group_orders = order.group_orders.includes(:ordergroup) + txt = "#{group_orders.count} #{Ordergroup.model_name.human count: group_orders.count}" + if group_orders.count == 0 + return txt + else + desc = group_orders.all.map {|g| g.ordergroup.name}.join(', ') + content_tag(:abbr, txt, title: desc).html_safe + end + end + + def supplier_link(order_or_supplier) + if order_or_supplier.kind_of?(Order) and order_or_supplier.stockit? + link_to(order_or_supplier.name, stock_articles_path).html_safe + else + link_to(@order.supplier.name, supplier_path(@order.supplier)).html_safe + end + end end diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml index fa0b315f..e4505661 100644 --- a/app/views/orders/show.html.haml +++ b/app/views/orders/show.html.haml @@ -1,37 +1,20 @@ - title t('.title', name: @order.name) -- content_for :javascript do - :javascript - function activate_search(view, placeholder) { - new List(document.body, { - valueNames: ['name'], - engine: 'unlist', - plugins: [ - ['reset', {highlightClass: 'btn-primary'}], - ['delay', {delayedSearchTime: 500}], - ], - // make large pages work too (as we don't have paging) - page: 10000, - indexAsync: true - }); - $('#query').attr('placeholder', placeholder); - } - $(function() { - activate_search('default', '#{j t('.search_placeholder.default')}'); - }); - .well %button{type: "button", class: "close", data: {dismiss: 'alert'}}= t('ui.marks.close').html_safe %p - #{@order.state.capitalize} order from - #{link_to @order.supplier.name, supplier_path(@order.supplier)} - created by #{show_user_link @order.created_by}, - open from #{format_time @order.starts} until #{format_time @order.ends}. + = raw t '.description1', + state: t("orders.state.#{@order.state}").capitalize, + supplier: supplier_link(@order), + who: show_user_link(@order.created_by), + starts: format_time(@order.starts), + ends: format_time(@order.ends) %br - %abbr{title: @order.group_orders.includes(:ordergroup).all.map {|g| g.ordergroup.name}.join(', ')} - #{@order.group_orders.count} #{Ordergroup.model_name.human count: @order.group_orders.count} - ordered #{@order.order_articles.ordered.count} articles with a total value of - #{number_to_currency(@order.sum(:net))} / #{number_to_currency(@order.sum(:gross))} (net / gross). + = raw t '.description2', + ordergroups: ordergroup_count(@order), + article_count: @order.order_articles.ordered.count, + net_sum: number_to_currency(@order.sum(:net)), + gross_sum: number_to_currency(@order.sum(:gross)) - if @note.present? %p @@ -98,3 +81,24 @@ = render partial: 'shared/comments', locals: { comments: @order.comments } #new_comment= render partial: 'order_comments/form', locals: { order_comment: @order.comments.build(user: current_user)} = link_to_top + + +- content_for :javascript do + :javascript + function activate_search(view, placeholder) { + new List(document.body, { + valueNames: ['name'], + engine: 'unlist', + plugins: [ + ['reset', {highlightClass: 'btn-primary'}], + ['delay', {delayedSearchTime: 500}], + ], + // make large pages work too (as we don't have paging) + page: 10000, + indexAsync: true + }); + $('#query').attr('placeholder', placeholder); + } + $(function() { + activate_search('default', '#{j t('.search_placeholder.default')}'); + }); diff --git a/config/locales/en.yml b/config/locales/en.yml index f1b9a06d..8cb16c3e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -184,7 +184,9 @@ en: order: Order order_article: Order article order_comment: Order comment - ordergroup: Ordergroup + ordergroup: + one: Ordergroup + other: Ordergroups stock_article: Stock article stock_taking: Stock taking supplier: Supplier @@ -1169,6 +1171,8 @@ en: confirm_end: ! 'Do you really want to close the order %{order}? There is no going back.' + description1: ! '%{state} order from %{supplier} created by %{who}, open from %{starts} until %{ends}.' + description2: ! '%{ordergroups} ordered %{article_count} articles, with a total value of %{net_sum} / %{gross_sum} (net / gross).' download: article_pdf: Article PDF download_file: Download file