Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In edit order form: Mark yellow all articles, that have free tolerance… #870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function update(item, quantity, tolerance) {

if (missing_units <= 0 || missing_units == unit[item]) {
missing_units = 0;
if (units > 0) {
if (quantity > 0) {
missing_units_css = 'missing-none';
} else {
missing_units_css = '';
Expand Down
16 changes: 16 additions & 0 deletions app/assets/stylesheets/list.missing.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
.list .has-free-tolerance td, .list .has-free-tolerance:hover td {
/* Class `has-free-tolerance` is set by backend code iff and only if
** no items are ordered by this group and there is free tolerance.
** It only comes to function, if it is not shadowed by one of the
** classes `m̀issing-*` below.
**
** It is set to yellow here, because it fits well with the
** semantics "You get it, if you order one more item" of
** class `missing-few`. However, unlike for `missing-few`,
** "If you order one more, one more package will be completed" is
** not true here, so you may consider another color more appropriate here.
*/
background-color: #ffee75;
}

.list .missing-many td, .list .missing-many:hover td {
background-color: #ebbebe;
}
Expand All @@ -9,3 +24,4 @@
.list .missing-none td, .list .missing-none:hover td {
background-color: #E4EED6;
}

10 changes: 8 additions & 2 deletions app/helpers/group_orders_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ def get_order_results(order_article, group_order_id)
{ group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total }
end

def get_missing_units_css_class(quantity_missing)
def get_missing_units_css_class(ordering_data)
quantity_missing = ordering_data[:missing_units]
if (quantity_missing == 1)
return 'missing-few';
elsif (quantity_missing == 0)
return ''
if ( ordering_data[:others_tolerance] > 0 and ordering_data[:quantity] == 0 )
# see comment in file list.missing.css
return 'has-free-tolerance'
else
return ''
end
else
return 'missing-many'
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/group_orders/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
%i.icon-tag
%td{colspan: "9"}
- order_articles.each do |order_article|
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top"}
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id])}", valign: "top"}
%td.name= order_article.article.name
- if @order.stockit?
%td= truncate order_article.article.supplier.name, length: 15
Expand Down