Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -11,13 +11,14 @@ module Admin::ConfigsHelper
|
|||
# @todo find way to pass current value to time_zone input without using default
|
||||
def config_input(form, key, options = {}, &block)
|
||||
return unless @cfg.allowed_key? key
|
||||
|
||||
options[:label] ||= config_input_label(form, key)
|
||||
options[:required] ||= false
|
||||
options[:input_html] ||= {}
|
||||
config_input_field_options form, key, options[:input_html]
|
||||
config_input_tooltip_options form, key, options[:input_html]
|
||||
if options[:as] == :boolean
|
||||
options[:input_html][:checked] = 'checked' if v=options[:input_html].delete(:value) && v!='false'
|
||||
options[:input_html][:checked] = 'checked' if v = options[:input_html].delete(:value) && v != 'false'
|
||||
options[:checked_value] = 'true' if options[:checked_value].nil?
|
||||
options[:unchecked_value] = 'false' if options[:unchecked_value].nil?
|
||||
elsif options[:collection] || options[:as] == :select
|
||||
|
|
@ -47,13 +48,14 @@ module Admin::ConfigsHelper
|
|||
# @todo find out how to pass +checked_value+ and +unchecked_value+ to +input_field+
|
||||
def config_input_field(form, key, options = {})
|
||||
return unless @cfg.allowed_key? :key
|
||||
|
||||
options[:required] ||= false
|
||||
config_input_field_options form, key, options
|
||||
config_input_tooltip_options form, key, options
|
||||
if options[:as] == :boolean
|
||||
checked_value = options.delete(:checked_value) || 'true'
|
||||
unchecked_value = options.delete(:unchecked_value) || 'false'
|
||||
options[:checked] = 'checked' if v=options.delete(:value) && v!='false'
|
||||
options[:checked] = 'checked' if v = options.delete(:value) && v != 'false'
|
||||
# different key for hidden field so that allow clocking on label focuses the control
|
||||
form.hidden_field(key, id: "#{key}_", value: unchecked_value, as: :hidden) + form.check_box(key, options, checked_value, false)
|
||||
elsif options[:as] == :select_recurring
|
||||
|
|
@ -73,13 +75,13 @@ module Admin::ConfigsHelper
|
|||
# @option options [String] :label Label to show
|
||||
def config_use_heading(form, key, options = {})
|
||||
head = content_tag :label do
|
||||
lbl = options[:label] || config_input_label(form, key)
|
||||
field = config_input_field(form, key, as: :boolean, boolean_style: :inline,
|
||||
data: {toggle: 'collapse', target: "##{key}-fields"})
|
||||
content_tag :h4 do
|
||||
# put in span to keep space for tooltip at right
|
||||
content_tag :span, (lbl + field).html_safe, config_input_tooltip_options(form, key, {})
|
||||
end
|
||||
lbl = options[:label] || config_input_label(form, key)
|
||||
field = config_input_field(form, key, as: :boolean, boolean_style: :inline,
|
||||
data: { toggle: 'collapse', target: "##{key}-fields" })
|
||||
content_tag :h4 do
|
||||
# put in span to keep space for tooltip at right
|
||||
content_tag :span, (lbl + field).html_safe, config_input_tooltip_options(form, key, {})
|
||||
end
|
||||
end
|
||||
fields = content_tag(:fieldset, id: "#{key}-fields", class: "collapse#{' in' if @cfg[key]}") do
|
||||
yield
|
||||
|
|
@ -99,12 +101,12 @@ module Admin::ConfigsHelper
|
|||
'(protected)'
|
||||
elsif value.is_a? Hash
|
||||
content_tag :ul do
|
||||
value.map do |k,v|
|
||||
value.map do |k, v|
|
||||
content_tag :li, content_tag(:tt, "#{k}: ") + show_config_value(k, v).to_s
|
||||
end.join.html_safe
|
||||
end
|
||||
elsif value.is_a? Enumerable
|
||||
content_tag :ul, value.map {|v| content_tag :li, h(v)}.join.html_safe
|
||||
content_tag :ul, value.map { |v| content_tag :li, h(v) }.join.html_safe
|
||||
elsif key =~ /url|website|www|homepage/
|
||||
link_to(value, value.to_s).html_safe
|
||||
else
|
||||
|
|
@ -115,7 +117,7 @@ module Admin::ConfigsHelper
|
|||
# @return [String] Tooltip element (span)
|
||||
# @param form [ActionView::Helpers::FormBuilder] Form object.
|
||||
# @param key [Symbol, String] Configuration key of a boolean (e.g. +use_messages+).
|
||||
def config_tooltip(form, key, options={}, &block)
|
||||
def config_tooltip(form, key, options = {}, &block)
|
||||
content_tag :span, config_input_tooltip_options(form, key, options), &block
|
||||
end
|
||||
|
||||
|
|
@ -139,7 +141,7 @@ module Admin::ConfigsHelper
|
|||
# set current value
|
||||
unless options.has_key?(:value)
|
||||
value = @cfg
|
||||
cfg_path.each {|n| value = value[n] if value.respond_to? :[] }
|
||||
cfg_path.each { |n| value = value[n] if value.respond_to? :[] }
|
||||
options[:value] = value
|
||||
end
|
||||
options
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
#
|
||||
# Methods added to this helper will be available to all templates in the application.
|
||||
module ApplicationHelper
|
||||
|
|
@ -27,14 +26,14 @@ module ApplicationHelper
|
|||
|
||||
# Splits an IBAN into groups of 4 digits displayed with margins in between
|
||||
def format_iban(iban)
|
||||
iban.scan(/..?.?.?/).map{ |item| content_tag(:span, item, style: "margin-right: 0.5em;") }.join.html_safe
|
||||
iban.scan(/..?.?.?/).map { |item| content_tag(:span, item, style: "margin-right: 0.5em;") }.join.html_safe
|
||||
end
|
||||
|
||||
# Creates ajax-controlled-links for pagination
|
||||
def pagination_links_remote(collection, options = {})
|
||||
per_page = options[:per_page] || @per_page
|
||||
params = options[:params] || {}
|
||||
params = params.merge({:per_page => per_page})
|
||||
params = params.merge({ :per_page => per_page })
|
||||
paginate collection, :params => params, :remote => true
|
||||
end
|
||||
|
||||
|
|
@ -45,7 +44,7 @@ module ApplicationHelper
|
|||
params = params || {}
|
||||
|
||||
links = per_page_options.map do |per_page|
|
||||
params.merge!({:per_page => per_page})
|
||||
params.merge!({ :per_page => per_page })
|
||||
link_class = 'btn'
|
||||
link_class << ' disabled' if per_page == current
|
||||
link_to(per_page, params, :remote => true, class: link_class)
|
||||
|
|
@ -58,33 +57,31 @@ module ApplicationHelper
|
|||
links.join.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def sort_link_helper(text, key, options = {})
|
||||
# Hmtl options
|
||||
remote = options[:remote].nil? ? true : options[:remote]
|
||||
class_name = case params[:sort]
|
||||
when key then
|
||||
'sortup'
|
||||
when key + '_reverse' then
|
||||
'sortdown'
|
||||
else
|
||||
nil
|
||||
when key then
|
||||
'sortup'
|
||||
when key + '_reverse' then
|
||||
'sortdown'
|
||||
else
|
||||
nil
|
||||
end
|
||||
html_options = {
|
||||
:title => I18n.t('helpers.application.sort_by', text: text),
|
||||
:remote => remote,
|
||||
:class => class_name
|
||||
:title => I18n.t('helpers.application.sort_by', text: text),
|
||||
:remote => remote,
|
||||
:class => class_name
|
||||
}
|
||||
|
||||
|
||||
# Url options
|
||||
key += "_reverse" if params[:sort] == key
|
||||
per_page = options[:per_page] || @per_page
|
||||
url_options = params.merge(per_page: per_page, sort: key)
|
||||
url_options.merge!({page: params[:page]}) if params[:page]
|
||||
url_options.merge!({query: params[:query]}) if params[:query]
|
||||
url_options.merge!({ page: params[:page] }) if params[:page]
|
||||
url_options.merge!({ query: params[:query] }) if params[:query]
|
||||
|
||||
link_to(text, url_for(url_options), html_options)
|
||||
end
|
||||
|
|
@ -98,13 +95,13 @@ module ApplicationHelper
|
|||
# be overridden by the option 'desc'.
|
||||
# Other options are passed through to I18n.
|
||||
def heading_helper(model, attribute, options = {})
|
||||
i18nopts = {count: 2}.merge(options.select {|a| !['short', 'desc'].include?(a) })
|
||||
i18nopts = { count: 2 }.merge(options.select { |a| !['short', 'desc'].include?(a) })
|
||||
s = model.human_attribute_name(attribute, i18nopts)
|
||||
if options[:short]
|
||||
desc = options[:desc]
|
||||
desc ||= model.human_attribute_name("#{attribute}_desc".to_sym, options.merge({fallback: true, default: '', count: 2}))
|
||||
desc ||= model.human_attribute_name("#{attribute}_desc".to_sym, options.merge({ fallback: true, default: '', count: 2 }))
|
||||
desc.blank? && desc = s
|
||||
sshort = model.human_attribute_name("#{attribute}_short".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 "<abbr title='#{desc}'>#{sshort}</abbr>" unless sshort.blank?
|
||||
end
|
||||
s
|
||||
|
|
@ -134,24 +131,24 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def tab_is_active?(tab)
|
||||
tab[:active].detect {|c| controller.controller_path.match(c) }
|
||||
tab[:active].detect { |c| controller.controller_path.match(c) }
|
||||
end
|
||||
|
||||
def icon(name, options={})
|
||||
def icon(name, options = {})
|
||||
icons = {
|
||||
:delete => { :file => 'b_drop.png', :alt => I18n.t('ui.delete')},
|
||||
:edit => { :file => 'b_edit.png', :alt => I18n.t('ui.edit')},
|
||||
:members => { :file => 'b_users.png', :alt => I18n.t('helpers.application.edit_user')}
|
||||
:delete => { :file => 'b_drop.png', :alt => I18n.t('ui.delete') },
|
||||
:edit => { :file => 'b_edit.png', :alt => I18n.t('ui.edit') },
|
||||
:members => { :file => 'b_users.png', :alt => I18n.t('helpers.application.edit_user') }
|
||||
}
|
||||
options[:alt] ||= icons[name][:alt]
|
||||
options[:title] ||= icons[name][:title]
|
||||
options.merge!({:size => '16x16',:border => "0"})
|
||||
options.merge!({ :size => '16x16', :border => "0" })
|
||||
|
||||
image_tag icons[name][:file], options
|
||||
end
|
||||
|
||||
# Remote links with default 'loader'.gif during request
|
||||
def remote_link_to(text, options={})
|
||||
def remote_link_to(text, options = {})
|
||||
remote_options = {
|
||||
:before => "Element.show('loader')",
|
||||
:success => "Element.hide('loader')",
|
||||
|
|
@ -160,20 +157,20 @@ module ApplicationHelper
|
|||
link_to(text, options[:url], remote_options.merge(options))
|
||||
end
|
||||
|
||||
def format_roles(record, icon=false)
|
||||
def format_roles(record, icon = false)
|
||||
roles = %w(suppliers article_meta orders pickups finance invoices admin)
|
||||
roles.select! {|role| record.send "role_#{role}?"}
|
||||
names = Hash[roles.map{|r| [r, I18n.t("helpers.application.role_#{r}")]}]
|
||||
roles.select! { |role| record.send "role_#{role}?" }
|
||||
names = Hash[roles.map { |r| [r, I18n.t("helpers.application.role_#{r}")] }]
|
||||
if icon
|
||||
roles.map{|r| image_tag("role-#{r}.png", size: '22x22', border: 0, alt: names[r], title: names[r])}.join(' ').html_safe
|
||||
roles.map { |r| image_tag("role-#{r}.png", size: '22x22', border: 0, alt: names[r], title: names[r]) }.join(' ').html_safe
|
||||
else
|
||||
roles.map{|r| names[r]}.join(', ')
|
||||
roles.map { |r| names[r] }.join(', ')
|
||||
end
|
||||
end
|
||||
|
||||
def link_to_gmaps(address)
|
||||
link_to h(address), "http://maps.google.com/?q=#{h(address)}", :title => I18n.t('helpers.application.show_google_maps'),
|
||||
:target => "_blank"
|
||||
:target => "_blank"
|
||||
end
|
||||
|
||||
# Returns flash messages html.
|
||||
|
|
@ -200,12 +197,13 @@ module ApplicationHelper
|
|||
# http://railsapps.github.io/twitter-bootstrap-rails.html
|
||||
def base_errors resource
|
||||
return '' if resource.errors.empty? || resource.errors[:base].empty?
|
||||
|
||||
messages = resource.errors[:base].map { |msg| content_tag(:li, msg) }.join
|
||||
render :partial => 'shared/base_errors', :locals => {:error_messages => messages}
|
||||
render :partial => 'shared/base_errors', :locals => { :error_messages => messages }
|
||||
end
|
||||
|
||||
# show a user, depending on settings
|
||||
def show_user(user=@current_user, options = {})
|
||||
def show_user(user = @current_user, options = {})
|
||||
if user.nil?
|
||||
"?"
|
||||
elsif FoodsoftConfig[:use_nick]
|
||||
|
|
@ -223,13 +221,14 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
# render user presentation linking to default action (plugins can override this)
|
||||
def show_user_link(user=@current_user)
|
||||
def show_user_link(user = @current_user)
|
||||
show_user user
|
||||
end
|
||||
|
||||
# allow truncate to add title when tooltip option is given
|
||||
def truncate(text, options={}, &block)
|
||||
def truncate(text, options = {}, &block)
|
||||
return text if !text || text.length <= (options[:length] || 30)
|
||||
|
||||
text_truncated = super(text, options, &block)
|
||||
if options[:tooltip]
|
||||
content_tag :span, text_truncated, title: text
|
||||
|
|
@ -240,29 +239,28 @@ module ApplicationHelper
|
|||
|
||||
# Expand variables in text
|
||||
# @see Foodsoft::ExpansionVariables#expand
|
||||
def expand(text, options={})
|
||||
def expand(text, options = {})
|
||||
Foodsoft::ExpansionVariables.expand(text, options)
|
||||
end
|
||||
|
||||
# @param dismiss [String, Symbol] Bootstrap dismiss value (modal, alert)
|
||||
# @return [String] HTML for close button dismissing
|
||||
def close_button(dismiss)
|
||||
content_tag :button, type: 'button', class: 'close', data: {dismiss: dismiss} do
|
||||
content_tag :button, type: 'button', class: 'close', data: { dismiss: dismiss } do
|
||||
I18n.t('ui.marks.close').html_safe
|
||||
end
|
||||
end
|
||||
|
||||
# @return [String] path to foodcoop CSS style (with MD5 parameter for caching)
|
||||
def foodcoop_css_path(options={})
|
||||
super(options.merge({md5: Digest::MD5.hexdigest(FoodsoftConfig[:custom_css].to_s)}))
|
||||
def foodcoop_css_path(options = {})
|
||||
super(options.merge({ md5: Digest::MD5.hexdigest(FoodsoftConfig[:custom_css].to_s) }))
|
||||
end
|
||||
|
||||
# @return [String] stylesheet tag for foodcoop CSS style (+custom_css+ foodcoop config)
|
||||
# @see #foodcoop_css_path
|
||||
def foodcoop_css_tag(options={})
|
||||
def foodcoop_css_tag(options = {})
|
||||
unless FoodsoftConfig[:custom_css].blank?
|
||||
stylesheet_link_tag foodcoop_css_path, media: 'all'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
module ArticlesHelper
|
||||
|
||||
# useful for highlighting attributes, when synchronizing articles
|
||||
def highlight_new(unequal_attributes, attribute)
|
||||
return unless unequal_attributes
|
||||
|
||||
unequal_attributes.has_key?(attribute) ? "background-color: yellow" : ""
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,32 @@
|
|||
module DeliveriesHelper
|
||||
|
||||
def link_to_invoice(delivery)
|
||||
if delivery.invoice
|
||||
link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice],
|
||||
title: I18n.t('helpers.deliveries.show_invoice')
|
||||
title: I18n.t('helpers.deliveries.show_invoice')
|
||||
else
|
||||
link_to I18n.t('helpers.deliveries.new_invoice'), new_finance_invoice_path(supplier_id: delivery.supplier.id, delivery_id: delivery.id),
|
||||
class: 'btn btn-mini'
|
||||
class: 'btn btn-mini'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def articles_for_select2(articles, except = [], &block)
|
||||
articles = articles.reorder('articles.name ASC')
|
||||
articles = articles.reject {|a| not except.index(a.id).nil? } if except
|
||||
block_given? or block = Proc.new {|a| "#{a.name} (#{number_to_currency a.price}/#{a.unit})" }
|
||||
articles = articles.reject { |a| not except.index(a.id).nil? } if except
|
||||
block_given? or block = Proc.new { |a| "#{a.name} (#{number_to_currency a.price}/#{a.unit})" }
|
||||
articles.map do |a|
|
||||
{:id => a.id, :text => block.call(a)}
|
||||
end.unshift({:id => '', :text => ''})
|
||||
{ :id => a.id, :text => block.call(a) }
|
||||
end.unshift({ :id => '', :text => '' })
|
||||
end
|
||||
|
||||
|
||||
def articles_for_table(articles)
|
||||
articles.undeleted.reorder('articles.name ASC')
|
||||
end
|
||||
|
||||
|
||||
def stock_change_remove_link(stock_change_form)
|
||||
return link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'remove_new_stock_change btn btn-small' if stock_change_form.object.new_record?
|
||||
|
||||
output = stock_change_form.hidden_field :_destroy
|
||||
output += link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'destroy_stock_change btn btn-small'
|
||||
return output.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ module Finance::BalancingHelper
|
|||
def balancing_view_partial
|
||||
view = params[:view] || 'edit_results'
|
||||
case view
|
||||
when 'edit_results' then
|
||||
'edit_results_by_articles'
|
||||
when 'groups_overview' then
|
||||
'shared/articles_by/groups'
|
||||
when 'articles_overview' then
|
||||
'shared/articles_by/articles'
|
||||
when 'edit_results' then
|
||||
'edit_results_by_articles'
|
||||
when 'groups_overview' then
|
||||
'shared/articles_by/groups'
|
||||
when 'articles_overview' then
|
||||
'shared/articles_by/articles'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ module Finance::InvoicesHelper
|
|||
def format_delivery_item delivery
|
||||
format_date(delivery.date)
|
||||
end
|
||||
|
||||
def format_order_item order
|
||||
"#{format_date(order.ends)} (#{number_to_currency(order.sum)})"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
module GroupOrderArticlesHelper
|
||||
|
||||
# return an edit field for a GroupOrderArticle result
|
||||
def group_order_article_edit_result(goa)
|
||||
result = number_with_precision goa.result, strip_insignificant_zeros: true
|
||||
unless goa.group_order.order.finished? && current_user.role_finance?
|
||||
result
|
||||
else
|
||||
simple_form_for goa, remote: true, html: {'data-submit-onchange' => 'changed', class: 'delta-input'} do |f|
|
||||
f.input_field :result, as: :delta, class: 'input-nano', data: {min: 0}, id: "r_#{goa.id}", value: result
|
||||
simple_form_for goa, remote: true, html: { 'data-submit-onchange' => 'changed', class: 'delta-input' } do |f|
|
||||
f.input_field :result, as: :delta, class: 'input-nano', data: { min: 0 }, id: "r_#{goa.id}", value: result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ module GroupOrdersHelper
|
|||
def link_to_ordering(order, options = {}, &block)
|
||||
group_order = order.group_order(current_user.ordergroup)
|
||||
path = if options[:show] && group_order
|
||||
group_order_path(group_order)
|
||||
elsif group_order
|
||||
edit_group_order_path(group_order, :order_id => order.id)
|
||||
else
|
||||
new_group_order_path(:order_id => order.id)
|
||||
end
|
||||
group_order_path(group_order)
|
||||
elsif group_order
|
||||
edit_group_order_path(group_order, :order_id => order.id)
|
||||
else
|
||||
new_group_order_path(:order_id => order.id)
|
||||
end
|
||||
options.delete(:show)
|
||||
name = block_given? ? capture(&block) : order.name
|
||||
path ? link_to(name, path, options) : name
|
||||
|
|
@ -36,18 +36,18 @@ module GroupOrdersHelper
|
|||
def get_order_results(order_article, group_order_id)
|
||||
goa = order_article.group_order_articles.detect { |goa| goa.group_order_id == group_order_id }
|
||||
quantity, tolerance, result, sub_total = if goa.present?
|
||||
[goa.quantity, goa.tolerance, goa.result, goa.total_price(order_article)]
|
||||
else
|
||||
[0, 0, 0, 0]
|
||||
end
|
||||
[goa.quantity, goa.tolerance, goa.result, goa.total_price(order_article)]
|
||||
else
|
||||
[0, 0, 0, 0]
|
||||
end
|
||||
|
||||
{group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total}
|
||||
{ group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total }
|
||||
end
|
||||
|
||||
def get_missing_units_css_class(quantity_missing)
|
||||
if ( quantity_missing == 1 )
|
||||
if (quantity_missing == 1)
|
||||
return 'missing-few';
|
||||
elsif ( quantity_missing == 0 )
|
||||
elsif (quantity_missing == 0)
|
||||
return ''
|
||||
else
|
||||
return 'missing-many'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
module OrderArticlesHelper
|
||||
|
||||
def article_label_with_unit(article)
|
||||
pkg_info = pkg_helper(article, plain: true)
|
||||
"#{article.name} (#{[article.unit, pkg_info].reject(&:blank?).join(' ')})"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module PathHelper
|
||||
|
||||
def finance_group_transactions_path(ordergroup)
|
||||
if ordergroup
|
||||
finance_ordergroup_transactions_path(ordergroup)
|
||||
|
|
@ -7,5 +6,4 @@ module PathHelper
|
|||
finance_foodcoop_financial_transactions_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
module SharedHelper
|
||||
|
||||
# provide input_html for password autocompletion
|
||||
def autocomplete_flag_to_password_html(password_autocomplete)
|
||||
case password_autocomplete
|
||||
when true then {autocomplete: 'on'}
|
||||
when false then {autocomplete: 'off'}
|
||||
when 'store-only' then {autocomplete: 'off', data: {store: 'on'}}
|
||||
else {}
|
||||
when true then { autocomplete: 'on' }
|
||||
when false then { autocomplete: 'off' }
|
||||
when 'store-only' then { autocomplete: 'off', data: { store: 'on' } }
|
||||
else {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ module StockitHelper
|
|||
def stock_article_price_hint(stock_article)
|
||||
t('simple_form.hints.stock_article.edit_stock_article.price',
|
||||
:stock_article_copy_link => link_to(t('stockit.form.copy_stock_article'),
|
||||
stock_article_copy_path(stock_article),
|
||||
:remote => true
|
||||
)
|
||||
)
|
||||
stock_article_copy_path(stock_article),
|
||||
:remote => true))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module SuppliersHelper
|
||||
|
||||
def associated_supplier_names(shared_supplier)
|
||||
"(#{shared_supplier.suppliers.map(&:name).join(', ')})"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module TasksHelper
|
||||
|
||||
def task_assignments(task)
|
||||
task.assignments.map do |ass|
|
||||
content_tag :span, show_user(ass.user), :class => (ass.accepted? ? 'accepted' : 'unaccepted')
|
||||
|
|
@ -10,7 +9,7 @@ module TasksHelper
|
|||
def highlighted_required_users(task)
|
||||
unless task.enough_users_assigned?
|
||||
content_tag :span, task.still_required_users, class: 'badge badge-important',
|
||||
title: I18n.t('helpers.tasks.required_users', :count => task.still_required_users)
|
||||
title: I18n.t('helpers.tasks.required_users', :count => task.still_required_users)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue