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
|
|
@ -1,26 +0,0 @@
|
|||
%table.table.table-hover.list
|
||||
%thead.list-heading
|
||||
%tr
|
||||
%th{:style => 'width:70%'}= t '.ordergroup'
|
||||
%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= t '.price'
|
||||
|
||||
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
|
||||
%tbody
|
||||
%tr
|
||||
%th.name{:colspan => "4"}
|
||||
= order_article.article.name
|
||||
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})"
|
||||
- for goa in order_article.group_order_articles.ordered
|
||||
%tr{:class => [cycle('even', 'odd', :name => 'groups'), if goa.result == 0 then 'unavailable' end]}
|
||||
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name
|
||||
%td= "#{goa.quantity} + #{goa.tolerance}"
|
||||
%td
|
||||
%b= goa.result
|
||||
%td= number_to_currency(order_article.price.fc_price * goa.result)
|
||||
%tr
|
||||
%td(colspan="4" )
|
||||
- reset_cycle('groups')
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
%table.table.table-hover.list
|
||||
%thead.list-heading
|
||||
%tr
|
||||
%th{:style => "width:40%"}= heading_helper Article, :name
|
||||
%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.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)
|
||||
- fc_price = goa.order_article.price.fc_price
|
||||
- subTotal = fc_price * goa.result
|
||||
- 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.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 => "7"}= t '.price_sum'
|
||||
%th= number_to_currency(total)
|
||||
%th
|
||||
%tr
|
||||
%th(colspan="9")
|
||||
- reset_cycle("articles")
|
||||
11
app/views/shared/articles_by/_article_single.html.haml
Normal file
11
app/views/shared/articles_by/_article_single.html.haml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%tbody{id: "oa_#{order_article.id}"}
|
||||
- if not defined?(heading) or heading
|
||||
%tr.list-heading
|
||||
%th.name{:colspan => "4"}>
|
||||
= order_article.article.name + ' '
|
||||
= "(#{order_article.article.unit}, #{number_to_currency order_article.price.fc_price}"
|
||||
- pkg_info = pkg_helper(order_article.price)
|
||||
= ", #{pkg_info}".html_safe unless pkg_info.blank?
|
||||
)
|
||||
- for goa in order_article.group_order_articles.ordered
|
||||
= render 'shared/articles_by/article_single_goa', goa: goa, edit: (edit rescue nil)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%tr{class: if goa.result == 0 then 'unavailable' end, id: "goa_#{goa.id}"}
|
||||
%td{:style => "width:70%"}= goa.group_order.ordergroup.name
|
||||
%td.center= "#{goa.quantity} + #{goa.tolerance}"
|
||||
%td.center.input-delta= (edit or true rescue true) ? group_order_article_edit_result(goa) : goa.result
|
||||
%td.price{data: {value: goa.total_price}}= number_to_currency(goa.total_price)
|
||||
14
app/views/shared/articles_by/_articles.html.haml
Normal file
14
app/views/shared/articles_by/_articles.html.haml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
%table.table.table-hover.list#articles_by_articles
|
||||
%thead.list-heading
|
||||
%tr
|
||||
%th{:style => 'width:70%'}= Ordergroup.model_name.human
|
||||
%th.center
|
||||
%acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered'
|
||||
%th.center
|
||||
%acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received'
|
||||
%th= t 'shared.articles_by.price'
|
||||
|
||||
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
|
||||
= render 'shared/articles_by/article_single', order_article: order_article, edit: (edit rescue nil)
|
||||
%tr
|
||||
%td{colspan: 4}
|
||||
30
app/views/shared/articles_by/_common.html.haml
Normal file
30
app/views/shared/articles_by/_common.html.haml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
-# common javascript for updating articles_by views
|
||||
-# include this in all pages that use articles_by views (directly or via ajax)
|
||||
= content_for :javascript do
|
||||
:javascript
|
||||
$(document).on('GroupOrderArticle#update', function(e) {
|
||||
|
||||
var el_goa = $('#goa_'+e.group_order_article_id);
|
||||
|
||||
// update total price of group_order_article
|
||||
// show localised value, store raw number in data attribute
|
||||
var el_price = $('.price', el_goa);
|
||||
var old_price = el_price.data('value');
|
||||
if (el_price.length) {
|
||||
el_price.text(I18n.l('currency', e.group_order_article_price));
|
||||
el_price.data('value', e.group_order_article_price);
|
||||
}
|
||||
|
||||
// group_order_article is greyed when result==0
|
||||
el_goa.toggleClass('unavailable', $('input#r_'+e.group_order_article_id, el_goa).val()==0);
|
||||
|
||||
// update total price of group_order, order_article and/or ordergroup, when present
|
||||
var el_sum = $('#group_order_'+e.group_order_id+', #single_ordergroup_total, #single_order_article_total');
|
||||
var el_price_sum = $('.price_sum', el_sum);
|
||||
if (el_price_sum.length) {
|
||||
var old_price_sum = el_price_sum.data('value');
|
||||
var new_price_sum = old_price_sum - old_price + e.group_order_article_price;
|
||||
el_price_sum.text(I18n.l('currency', new_price_sum));
|
||||
el_price_sum.data('value', new_price_sum);
|
||||
}
|
||||
});
|
||||
15
app/views/shared/articles_by/_group_single.html.haml
Normal file
15
app/views/shared/articles_by/_group_single.html.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%tbody{id: "group_order_#{group_order.id}"}
|
||||
- if not defined?(heading) or heading
|
||||
%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)
|
||||
- total += goa.total_price
|
||||
= render 'shared/articles_by/group_single_goa', goa: goa, edit: (edit rescue nil)
|
||||
%tr{class: cycle('even', 'odd', :name => 'articles')}
|
||||
%th{colspan: 7}= t 'shared.articles_by.price_sum'
|
||||
%th.price_sum{colspan: 2, data: {value: total}}= number_to_currency(total)
|
||||
%tr
|
||||
%th{colspan: 9}
|
||||
- reset_cycle("articles")
|
||||
11
app/views/shared/articles_by/_group_single_goa.html.haml
Normal file
11
app/views/shared/articles_by/_group_single_goa.html.haml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%tr{class: [cycle('even', 'odd', :name => 'articles'), if goa.result == 0 then 'unavailable' end], id: "goa_#{goa.id}"}
|
||||
%td.name= goa.order_article.article.name
|
||||
%td= goa.order_article.article.unit
|
||||
%td.center= "#{goa.quantity} + #{goa.tolerance}"
|
||||
%td.center.input-delta= (edit or true rescue true) ? group_order_article_edit_result(goa) : goa.result
|
||||
%td.symbol ×
|
||||
%td= number_to_currency(goa.order_article.price.fc_price)
|
||||
%td.symbol =
|
||||
%td.price{data: {value: goa.total_price}}= number_to_currency(goa.total_price)
|
||||
%td= pkg_helper goa.order_article.price
|
||||
|
||||
17
app/views/shared/articles_by/_groups.html.haml
Normal file
17
app/views/shared/articles_by/_groups.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
%table.table.table-hover.list#articles_by_groups
|
||||
%thead.list-heading
|
||||
%tr
|
||||
%th{:style => "width:40%"}= heading_helper Article, :name
|
||||
%th= heading_helper Article, :unit
|
||||
%th.center
|
||||
%acronym{:title => t('shared.articles.ordered_desc')}= t 'shared.articles.ordered'
|
||||
%th.center
|
||||
%acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received'
|
||||
%th.symbol
|
||||
%th= heading_helper Article, :fc_price, short: true
|
||||
%th.symbol
|
||||
%th= t 'shared.articles_by.price'
|
||||
%th= #heading_helper Article, :unit_quantity, short: true
|
||||
|
||||
- for group_order in order.group_orders.ordered
|
||||
= render 'shared/articles_by/group_single', group_order: group_order, edit: (edit rescue nil)
|
||||
Loading…
Add table
Add a link
Reference in a new issue