Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -1,8 +1,6 @@
# encoding: utf-8
module OrdersHelper
def update_articles_link(order, text, view, options={})
options = {remote: true, id: "view_#{view}_btn", class: ''}.merge(options)
def update_articles_link(order, text, view, options = {})
options = { remote: true, id: "view_#{view}_btn", class: '' }.merge(options)
options[:class] += ' active' if view.to_s == @view.to_s
link_to text, order_path(order, view: view), options
end
@ -13,20 +11,20 @@ module OrdersHelper
# @param options [Hash] Options passed to +link_to+
# @return [String] Link to order document
# @see OrdersController#show
def order_pdf(order, document, text, options={})
def order_pdf(order, document, text, options = {})
options = options.merge(title: I18n.t('helpers.orders.order_pdf'))
link_to text, order_path(order, document: document, format: :pdf), options
end
def options_for_suppliers_to_select
options = [[I18n.t('helpers.orders.option_choose')]]
options += Supplier.map {|s| [ s.name, url_for(action: "new", supplier_id: s.id)] }
options += Supplier.map { |s| [s.name, url_for(action: "new", supplier_id: s.id)] }
options += [[I18n.t('helpers.orders.option_stock'), url_for(action: 'new', supplier_id: nil)]]
options_for_select(options)
end
# "1×2 ordered, 2×2 billed, 2×2 received"
def units_history_line(order_article, options={})
def units_history_line(order_article, options = {})
if order_article.order.open?
nil
else
@ -49,8 +47,9 @@ module OrdersHelper
# @option options [String] :soft_uq +true+ to hide unit quantity specifier on small screens.
# Sensible in tables with multiple columns.
# @return [String] Text showing unit and unit quantity when applicable.
def pkg_helper(article, options={})
def pkg_helper(article, options = {})
return '' if !article || article.unit_quantity == 1
uq_text = "× #{article.unit_quantity}"
uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
if options[:plain]
@ -61,11 +60,12 @@ module OrdersHelper
pkg_helper_icon(uq_text, tag: :span)
end
end
# @param c [Symbol, String] Tag to use
# @option options [String] :class CSS class(es) (in addition to +package+)
# @return [String] Icon used for displaying the unit quantity
def pkg_helper_icon(c=nil, options={})
options = {tag: 'i', class: ''}.merge(options)
def pkg_helper_icon(c = nil, options = {})
options = { tag: 'i', class: '' }.merge(options)
if c.nil?
c = " ".html_safe
options[:class] += " icon-only"
@ -73,8 +73,9 @@ module OrdersHelper
content_tag(options[:tag], c, class: "package #{options[:class]}").html_safe
end
def article_price_change_hint(order_article, gross=false)
def article_price_change_hint(order_article, gross = false)
return nil if order_article.article.price == order_article.price.price
title = "#{t('helpers.orders.old_price')}: #{number_to_currency order_article.article.price}"
title += " / #{number_to_currency order_article.article.gross_price}" if gross
content_tag(:i, nil, class: 'icon-asterisk', title: j(title)).html_safe
@ -83,14 +84,14 @@ module OrdersHelper
def receive_input_field(form)
order_article = form.object
units_expected = (order_article.units_billed || order_article.units_to_order) *
1.0 * order_article.article.unit_quantity / order_article.article_price.unit_quantity
1.0 * order_article.article.unit_quantity / order_article.article_price.unit_quantity
input_classes = 'input input-nano units_received'
input_classes += ' package' unless order_article.article_price.unit_quantity == 1
input_html = form.text_field :units_received, class: input_classes,
data: {'units-expected' => units_expected},
disabled: order_article.result_manually_changed?,
autocomplete: 'off'
data: { 'units-expected' => units_expected },
disabled: order_article.result_manually_changed?,
autocomplete: 'off'
if order_article.result_manually_changed?
input_html = content_tag(:span, class: 'input-prepend intable', title: t('orders.edit_amount.field_locked_title', default: '')) {
@ -111,7 +112,7 @@ module OrdersHelper
if group_orders.count == 0
return txt
else
desc = group_orders.includes(:ordergroup).map {|g| g.ordergroup_name}.join(', ')
desc = group_orders.includes(:ordergroup).map { |g| g.ordergroup_name }.join(', ')
content_tag(:abbr, txt, title: desc).html_safe
end
end
@ -147,7 +148,7 @@ module OrdersHelper
# @param order [Order]
# @option options [String] :class Classes added to the button's class attribute.
# @return [String] Order receive button.
def receive_button(order, options={})
def receive_button(order, options = {})
if order.stockit?
content_tag :div, t('orders.index.action_receive'), class: "btn disabled #{options[:class]}"
else