mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Set quantity input parameters based on action
This commit is contained in:
parent
9e4bc274cf
commit
ca5d3a57de
@ -1482,21 +1482,21 @@ function constructInputOptions(name, classes, type, parameters) {
|
|||||||
opts.push(`readonly=''`);
|
opts.push(`readonly=''`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.value) {
|
if (parameters.value != null) {
|
||||||
// Existing value?
|
// Existing value?
|
||||||
opts.push(`value='${parameters.value}'`);
|
opts.push(`value='${parameters.value}'`);
|
||||||
} else if (parameters.default) {
|
} else if (parameters.default != null) {
|
||||||
// Otherwise, a defualt value?
|
// Otherwise, a defualt value?
|
||||||
opts.push(`value='${parameters.default}'`);
|
opts.push(`value='${parameters.default}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum input length
|
// Maximum input length
|
||||||
if (parameters.max_length) {
|
if (parameters.max_length != null) {
|
||||||
opts.push(`maxlength='${parameters.max_length}'`);
|
opts.push(`maxlength='${parameters.max_length}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum input length
|
// Minimum input length
|
||||||
if (parameters.min_length) {
|
if (parameters.min_length != null) {
|
||||||
opts.push(`minlength='${parameters.min_length}'`);
|
opts.push(`minlength='${parameters.min_length}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,7 +1516,7 @@ function constructInputOptions(name, classes, type, parameters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Placeholder?
|
// Placeholder?
|
||||||
if (parameters.placeholder) {
|
if (parameters.placeholder != null) {
|
||||||
opts.push(`placeholder='${parameters.placeholder}'`);
|
opts.push(`placeholder='${parameters.placeholder}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,33 @@ function adjustStock(items, options={}) {
|
|||||||
|
|
||||||
var pk = item.pk;
|
var pk = item.pk;
|
||||||
|
|
||||||
|
var readonly = (item.serial != null);
|
||||||
|
var minValue = null;
|
||||||
|
var maxValue = null;
|
||||||
|
var value = null;
|
||||||
|
|
||||||
|
switch (options.action) {
|
||||||
|
case 'move':
|
||||||
|
minValue = 0;
|
||||||
|
maxValue = item.quantity;
|
||||||
|
value = item.quantity;
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
minValue = 0;
|
||||||
|
value = 0;
|
||||||
|
break;
|
||||||
|
case 'take':
|
||||||
|
minValue = 0;
|
||||||
|
value = 0;
|
||||||
|
break;
|
||||||
|
case 'count':
|
||||||
|
minValue = 0;
|
||||||
|
value = item.quantity;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
var image = item.part_detail.thumbnail || item.part_detail.image || blankImage();
|
var image = item.part_detail.thumbnail || item.part_detail.image || blankImage();
|
||||||
|
|
||||||
var status = stockStatusDisplay(item.status, {
|
var status = stockStatusDisplay(item.status, {
|
||||||
@ -94,8 +121,10 @@ function adjustStock(items, options={}) {
|
|||||||
actionInput = constructNumberInput(
|
actionInput = constructNumberInput(
|
||||||
item.pk,
|
item.pk,
|
||||||
{
|
{
|
||||||
value: item.quantity,
|
value: value,
|
||||||
min_value: 0,
|
min_value: minValue,
|
||||||
|
max_value: maxValue,
|
||||||
|
readonly: readonly,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user