allow to edit GroupOrderArticle result from orders screen
Conflicts: app/assets/javascripts/application.js
This commit is contained in:
parent
f9d2c20aaa
commit
60826ceedc
34 changed files with 393 additions and 220 deletions
|
|
@ -83,12 +83,14 @@ module ApplicationHelper
|
|||
# be overridden by the option 'desc'.
|
||||
# Other options are passed through to I18n.
|
||||
def heading_helper(model, attribute, options = {})
|
||||
i18nopts = options.select {|a| !['short', 'desc'].include?(a) }.merge({count: 2})
|
||||
i18nopts = {count: 2}.merge(options.select {|a| !['short', 'desc'].include?(a) })
|
||||
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})))
|
||||
desc = options[:desc]
|
||||
desc ||= model.human_attribute_name("#{attribute}_desc".to_sym, options.merge({fallback: true, default: '', count: 2}))
|
||||
desc.blank? and desc = s
|
||||
sshort = model.human_attribute_name("#{attribute}_short".to_sym, options.merge({fallback: true, default: '', count: 2}))
|
||||
s = raw "<abbr title='#{desc or s}'>#{sshort}</abbr>" unless sshort.blank?
|
||||
s = raw "<abbr title='#{desc}'>#{sshort}</abbr>" unless sshort.blank?
|
||||
end
|
||||
s
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ module Finance::BalancingHelper
|
|||
when 'edit_results' then
|
||||
'edit_results_by_articles'
|
||||
when 'groups_overview' then
|
||||
'shared/articles_by_groups'
|
||||
'shared/articles_by/groups'
|
||||
when 'articles_overview' then
|
||||
'shared/articles_by_articles'
|
||||
'shared/articles_by/articles'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
14
app/helpers/group_order_articles_helper.rb
Normal file
14
app/helpers/group_order_articles_helper.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
module GroupOrderArticlesHelper
|
||||
|
||||
# return an edit field for a GroupOrderArticle result
|
||||
def group_order_article_edit_result(goa)
|
||||
unless goa.group_order.order.finished? and current_user.role_finance?
|
||||
goa.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}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -18,7 +18,7 @@ module OrdersHelper
|
|||
options_for_select(options)
|
||||
end
|
||||
|
||||
# "1 ordered units, 2 billed, 2 received"
|
||||
# "1×2 ordered, 2×2 billed, 2×2 received"
|
||||
def units_history_line(order_article, options={})
|
||||
if order_article.order.open?
|
||||
nil
|
||||
|
|
@ -26,10 +26,9 @@ module OrdersHelper
|
|||
units_info = []
|
||||
[:units_to_order, :units_billed, :units_received].map do |unit|
|
||||
if n = order_article.send(unit)
|
||||
i18nkey = if units_info.empty? and options[:plain] then unit else "#{unit}_short" end
|
||||
line = n.to_s + ' '
|
||||
line += pkg_helper(order_article.price) + ' ' unless options[:plain] or n == 0
|
||||
line += OrderArticle.human_attribute_name(i18nkey, count: n)
|
||||
line += pkg_helper(order_article.price, options) + ' ' unless n == 0
|
||||
line += OrderArticle.human_attribute_name("#{unit}_short", count: n)
|
||||
units_info << line
|
||||
end
|
||||
end
|
||||
|
|
@ -39,13 +38,16 @@ module OrdersHelper
|
|||
|
||||
# can be article or article_price
|
||||
# icon: `false` to not show the icon
|
||||
# plain: `true` to not use html (implies icon: false)
|
||||
# soft_uq: `true` to hide unit quantity specifier on small screens
|
||||
# sensible in tables with multiple columns calling `pkg_helper`
|
||||
def pkg_helper(article, options={})
|
||||
return '' if not article or article.unit_quantity == 1
|
||||
uq_text = "× #{article.unit_quantity}".html_safe
|
||||
uq_text = "× #{article.unit_quantity}"
|
||||
uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
|
||||
if options[:icon].nil? or options[:icon]
|
||||
if options[:plain]
|
||||
uq_text
|
||||
elsif options[:icon].nil? or options[:icon]
|
||||
pkg_helper_icon(uq_text)
|
||||
else
|
||||
pkg_helper_icon(uq_text, tag: :span)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue