Merge pull request #387 from foodcoops/feature/boxfills
Add optional boxfill phase to orders (+ bootstrap buttons)
This commit is contained in:
commit
227ca0dd84
16 changed files with 271 additions and 76 deletions
|
|
@ -5,20 +5,20 @@
|
|||
//
|
||||
// Call setDecimalSeparator(char) to overwrite the default character "." with a localized value.
|
||||
|
||||
var modified = false // indicates if anything has been clicked on this page
|
||||
var groupBalance = 0; // available group money
|
||||
var minimumBalance = 0; // minimum group balance for the order to be succesful
|
||||
var modified = false; // indicates if anything has been clicked on this page
|
||||
var groupBalance = 0; // available group money
|
||||
var minimumBalance = 0; // minimum group balance for the order to be succesful
|
||||
var toleranceIsCostly = true; // default tolerance behaviour
|
||||
var isStockit = false; // Wheter the order is from stock oder normal supplier
|
||||
var isStockit = false; // Whether the order is from stock oder normal supplier
|
||||
|
||||
// Article data arrays:
|
||||
var price = new Array();
|
||||
var unit = new Array(); // items per order unit
|
||||
var itemTotal = new Array(); // total item price
|
||||
var unit = new Array(); // items per order unit
|
||||
var itemTotal = new Array(); // total item price
|
||||
var quantityOthers = new Array();
|
||||
var toleranceOthers = new Array();
|
||||
var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get
|
||||
var quantityAvailable = new Array(); // stock_order. how many items are currently in stock
|
||||
var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get
|
||||
var quantityAvailable = new Array(); // stock_order. how many items are currently in stock
|
||||
|
||||
function setToleranceBehaviour(value) {
|
||||
toleranceIsCostly = value;
|
||||
|
|
@ -48,27 +48,37 @@ function addData(orderArticleId, itemPrice, itemUnit, itemSubtotal, itemQuantity
|
|||
}
|
||||
|
||||
function increaseQuantity(item) {
|
||||
var value = Number($('#q_' + item).val()) + 1;
|
||||
var $el = $('#q_' + item),
|
||||
value = Number($el.val()) + 1,
|
||||
max = $el.data('max');
|
||||
if (value > max) { value = max; }
|
||||
if (!isStockit || (value <= (quantityAvailable[item] + itemsAllocated[item]))) {
|
||||
update(item, value, $('#t_' + item).val());
|
||||
}
|
||||
}
|
||||
|
||||
function decreaseQuantity(item) {
|
||||
var value = Number($('#q_' + item).val()) - 1;
|
||||
if (value >= 0) {
|
||||
var $el = $('#q_' + item),
|
||||
value = Number($el.val()) - 1,
|
||||
min = $el.data('min') || 0;
|
||||
if (value >= min) {
|
||||
update(item, value, $('#t_' + item).val());
|
||||
}
|
||||
}
|
||||
|
||||
function increaseTolerance(item) {
|
||||
var value = Number($('#t_' + item).val()) + 1;
|
||||
var $el = $('#t_' + item),
|
||||
value = Number($el.val()) + 1;
|
||||
max = $el.data('max');
|
||||
if (value > max) { value = max; }
|
||||
update(item, $('#q_' + item).val(), value);
|
||||
}
|
||||
|
||||
function decreaseTolerance(item) {
|
||||
var value = Number($('#t_' + item).val()) - 1;
|
||||
if (value >= 0) {
|
||||
var $el = $('#t_' + item),
|
||||
value = Number($el.val()) - 1,
|
||||
min = $el.data('min') || 0;
|
||||
if (value >= min) {
|
||||
update(item, $('#q_' + item).val(), value);
|
||||
}
|
||||
}
|
||||
|
|
@ -139,9 +149,8 @@ function update(item, quantity, tolerance) {
|
|||
.removeClass('missing-many missing-few missing-none')
|
||||
.addClass(missing_units_css);
|
||||
|
||||
|
||||
// update balance
|
||||
updateBalance();
|
||||
updateButtons($('#q_'+item).closest('tr'));
|
||||
}
|
||||
|
||||
function calcUnits(unitSize, quantity, tolerance) {
|
||||
|
|
@ -184,21 +193,43 @@ function updateBalance() {
|
|||
}
|
||||
}
|
||||
|
||||
function updateButtons($el) {
|
||||
// enable/disable buttons depending on min/max vs. value
|
||||
$el.find('a[data-increase_quantity]').each(function() {
|
||||
var $q = $el.find('#q_'+$(this).data('increase_quantity'));
|
||||
$(this).toggleClass('disabled', $q.val() >= $q.data('max'));
|
||||
});
|
||||
$el.find('a[data-decrease_quantity]').each(function() {
|
||||
var $q = $el.find('#q_'+$(this).data('decrease_quantity'));
|
||||
$(this).toggleClass('disabled', $q.val() <= ($q.data('min')||0));
|
||||
});
|
||||
$el.find('a[data-increase_tolerance]').each(function() {
|
||||
var $t = $el.find('#t_'+$(this).data('increase_tolerance'));
|
||||
$(this).toggleClass('disabled', $t.val() >= $t.data('max'));
|
||||
});
|
||||
$el.find('a[data-decrease_tolerance]').each(function() {
|
||||
var $t = $el.find('#t_'+$(this).data('decrease_tolerance'));
|
||||
$(this).toggleClass('disabled', $t.val() <= ($t.data('min')||0));
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('input[data-increase_quantity]').on('touchclick', function() {
|
||||
$('a[data-increase_quantity]').on('touchclick', function() {
|
||||
increaseQuantity($(this).data('increase_quantity'));
|
||||
});
|
||||
$('input[data-decrease_quantity]').on('touchclick', function() {
|
||||
$('a[data-decrease_quantity]').on('touchclick', function() {
|
||||
decreaseQuantity($(this).data('decrease_quantity'));
|
||||
});
|
||||
$('input[data-increase_tolerance]').on('touchclick', function() {
|
||||
$('a[data-increase_tolerance]').on('touchclick', function() {
|
||||
increaseTolerance($(this).data('increase_tolerance'));
|
||||
});
|
||||
$('input[data-decrease_tolerance]').on('touchclick', function() {
|
||||
$('a[data-decrease_tolerance]').on('touchclick', function() {
|
||||
decreaseTolerance($(this).data('decrease_tolerance'));
|
||||
});
|
||||
|
||||
$('a[data-confirm_switch_order]').on('touchclick', function() {
|
||||
return (!modified || confirm(I18n.t('js.ordering.confirm_change')));
|
||||
});
|
||||
|
||||
updateButtons($(document));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -197,10 +197,17 @@ table {
|
|||
}
|
||||
.unused {
|
||||
color: @articleUnusedColor;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
.partused {
|
||||
color: @articlePartusedColor;
|
||||
}
|
||||
.btn-ordering, .btn-group .btn-ordering {
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
padding: 4px 8px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
#order-footer, .article-info {
|
||||
text-align: left;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue