give partially unused order articles a distinct colour

This commit is contained in:
wvengen 2014-06-04 10:05:18 +02:00
parent fee0cfbdc7
commit 2bf13dbefa
4 changed files with 15 additions and 4 deletions

View file

@ -119,7 +119,7 @@ function update(item, quantity, tolerance) {
// update missing units // update missing units
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item]) var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item])
if (missing_units < 0) { if (missing_units < 0 || missing_units == unit[item]) {
missing_units = 0; missing_units = 0;
} }
$('#missing_units_' + item).html(String(missing_units)); $('#missing_units_' + item).html(String(missing_units));

View file

@ -38,6 +38,7 @@ body {
// article status // article status
@articleUsedColor: green; @articleUsedColor: green;
@articlePartusedColor: #d50;
@articleUnusedColor: red; @articleUnusedColor: red;
@articleUnavailColor: #999; @articleUnavailColor: #999;
@articleUpdatedColor: #468847; @articleUpdatedColor: #468847;
@ -158,6 +159,9 @@ table {
.unused { .unused {
color: @articleUnusedColor; color: @articleUnusedColor;
} }
.partused {
color: @articlePartusedColor;
}
#order-footer, .article-info { #order-footer, .article-info {
text-align: left; text-align: left;
@ -253,6 +257,7 @@ td.symbol, th.symbol {
.symbol { color: tint(@textColor, @nonessentialDim); } .symbol { color: tint(@textColor, @nonessentialDim); }
.used .symbol { color: tint(@articleUsedColor, @nonessentialDim); } .used .symbol { color: tint(@articleUsedColor, @nonessentialDim); }
.unused .symbol { color: tint(@articleUnusedColor, @nonessentialDim); } .unused .symbol { color: tint(@articleUnusedColor, @nonessentialDim); }
.partused .symbol { color: tint(@articlePartusedColor, @nonessentialDim); }
.unavailable .symbol { color: @articleUnavailColor; } .unavailable .symbol { color: @articleUnavailColor; }
// hide symbols completely on small screens to save space // hide symbols completely on small screens to save space
@ -359,6 +364,7 @@ i.package.icon-only {
.package { color: tint(@textColor, @nonessentialDim); } .package { color: tint(@textColor, @nonessentialDim); }
.used .package { color: tint(@articleUsedColor, @nonessentialDim); } .used .package { color: tint(@articleUsedColor, @nonessentialDim); }
.unused .package { color: tint(@articleUnusedColor, @nonessentialDim); } .unused .package { color: tint(@articleUnusedColor, @nonessentialDim); }
.partused .package { color: tint(@articlePartusedColor, @nonessentialDim); }
.unavailable .package { color: @articleUnavailColor; } .unavailable .package { color: @articleUnavailColor; }
// very small inputs - need !important for responsive selectors // very small inputs - need !important for responsive selectors

View file

@ -125,10 +125,14 @@ module OrdersHelper
end end
# @param order_article [OrderArticle] # @param order_article [OrderArticle]
# @return [String] CSS class for +OrderArticle+ in table for admins # @return [String] CSS class for +OrderArticle+ in table for admins (+used+, +partused+, +unused+ or +unavailable+).
def order_article_class(order_article) def order_article_class(order_article)
if order_article.units > 0 if order_article.units > 0
'used' if order_article.missing_units == 0
'used'
else
'partused'
end
elsif order_article.quantity > 0 elsif order_article.quantity > 0
'unused' 'unused'
else else

View file

@ -184,10 +184,11 @@ class OrderArticle < ActiveRecord::Base
@update_global_price = (value == true or value == '1') ? true : false @update_global_price = (value == true or value == '1') ? true : false
end end
# Units missing for the next full unit_quantity of the article # @return [Number] Units missing for the last +unit_quantity+ of the article.
def missing_units def missing_units
units = article.unit_quantity - ((quantity % article.unit_quantity) + tolerance) units = article.unit_quantity - ((quantity % article.unit_quantity) + tolerance)
units = 0 if units < 0 units = 0 if units < 0
units = 0 if units == article.unit_quantity
units units
end end