mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds front-end javascript code to implement new serializer features
This commit is contained in:
parent
73484192a5
commit
9e0120599f
@ -1976,7 +1976,7 @@ function constructField(name, parameters, options) {
|
|||||||
html += `<div class='controls'>`;
|
html += `<div class='controls'>`;
|
||||||
|
|
||||||
// Does this input deserve "extra" decorators?
|
// Does this input deserve "extra" decorators?
|
||||||
var extra = parameters.prefix != null;
|
var extra = (parameters.icon != null) || (parameters.prefix != null) || (parameters.prefixRaw != null);
|
||||||
|
|
||||||
// Some fields can have 'clear' inputs associated with them
|
// Some fields can have 'clear' inputs associated with them
|
||||||
if (!parameters.required && !parameters.read_only) {
|
if (!parameters.required && !parameters.read_only) {
|
||||||
@ -2001,6 +2001,10 @@ function constructField(name, parameters, options) {
|
|||||||
|
|
||||||
if (parameters.prefix) {
|
if (parameters.prefix) {
|
||||||
html += `<span class='input-group-text'>${parameters.prefix}</span>`;
|
html += `<span class='input-group-text'>${parameters.prefix}</span>`;
|
||||||
|
} else if (parameters.prefixRaw) {
|
||||||
|
html += parameters.prefixRaw;
|
||||||
|
} else if (parameters.icon) {
|
||||||
|
html += `<span class='input-group-text'><span class='fas ${parameters.icon}'></span></span>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2147,6 +2151,10 @@ function constructInputOptions(name, classes, type, parameters, options={}) {
|
|||||||
|
|
||||||
opts.push(`type='${type}'`);
|
opts.push(`type='${type}'`);
|
||||||
|
|
||||||
|
if (parameters.title || parameters.help_text) {
|
||||||
|
opts.push(`title='${parameters.title || parameters.help_text}'`);
|
||||||
|
}
|
||||||
|
|
||||||
// Read only?
|
// Read only?
|
||||||
if (parameters.read_only) {
|
if (parameters.read_only) {
|
||||||
opts.push(`readonly=''`);
|
opts.push(`readonly=''`);
|
||||||
@ -2192,11 +2200,6 @@ function constructInputOptions(name, classes, type, parameters, options={}) {
|
|||||||
opts.push(`required=''`);
|
opts.push(`required=''`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom mouseover title?
|
|
||||||
if (parameters.title != null) {
|
|
||||||
opts.push(`title='${parameters.title}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Placeholder?
|
// Placeholder?
|
||||||
if (parameters.placeholder != null) {
|
if (parameters.placeholder != null) {
|
||||||
opts.push(`placeholder='${parameters.placeholder}'`);
|
opts.push(`placeholder='${parameters.placeholder}'`);
|
||||||
|
@ -476,6 +476,25 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
|||||||
quantity = 0;
|
quantity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepend toggles to the quantity input
|
||||||
|
var toggle_batch = `
|
||||||
|
<span class='input-group-text' title='{% trans "Add batch code" %}' data-bs-toggle='collapse' href='#div-batch-${pk}'>
|
||||||
|
<span class='fas fa-layer-group'></span>
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
var toggle_serials = `
|
||||||
|
<span class='input-group-text' title='{% trans "Add serial numbers" %}' data-bs-toggle='collapse' href='#div-serials-${pk}'>
|
||||||
|
<span class='fas fa-hashtag'></span>
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
var prefix_buttons = toggle_batch;
|
||||||
|
|
||||||
|
if (line_item.part_detail.trackable) {
|
||||||
|
prefix_buttons += toggle_serials;
|
||||||
|
}
|
||||||
|
|
||||||
// Quantity to Receive
|
// Quantity to Receive
|
||||||
var quantity_input = constructField(
|
var quantity_input = constructField(
|
||||||
`items_quantity_${pk}`,
|
`items_quantity_${pk}`,
|
||||||
@ -485,12 +504,49 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
|||||||
value: quantity,
|
value: quantity,
|
||||||
title: '{% trans "Quantity to receive" %}',
|
title: '{% trans "Quantity to receive" %}',
|
||||||
required: true,
|
required: true,
|
||||||
|
prefixRaw: prefix_buttons,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hideLabels: true,
|
hideLabels: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add in options for "batch code" and "serial numbers"
|
||||||
|
var batch_input = constructField(
|
||||||
|
`items_batch_code_${pk}`,
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
label: '{% trans "Batch Code" %}',
|
||||||
|
help_text: '{% trans "Enter batch code for incoming stock items" %}',
|
||||||
|
prefixRaw: toggle_batch,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hideLabels: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var sn_input = constructField(
|
||||||
|
`items_serial_numbers_${pk}`,
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
label: '{% trans "Serial Numbers" %}',
|
||||||
|
help_text: '{% trans "Enter serial numbers for incoming stock items" %}',
|
||||||
|
prefixRaw: toggle_serials,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hideLabels: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Hidden inputs below the "quantity" field
|
||||||
|
var quantity_input_group = `${quantity_input}<div class='collapse' id='div-batch-${pk}'>${batch_input}</div>`;
|
||||||
|
|
||||||
|
if (line_item.part_detail.trackable) {
|
||||||
|
quantity_input_group += `<div class='collapse' id='div-serials-${pk}'>${sn_input}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct list of StockItem status codes
|
// Construct list of StockItem status codes
|
||||||
var choices = [];
|
var choices = [];
|
||||||
|
|
||||||
@ -554,7 +610,7 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
|||||||
${line_item.received}
|
${line_item.received}
|
||||||
</td>
|
</td>
|
||||||
<td id='quantity_${pk}'>
|
<td id='quantity_${pk}'>
|
||||||
${quantity_input}
|
${quantity_input_group}
|
||||||
</td>
|
</td>
|
||||||
<td id='status_${pk}'>
|
<td id='status_${pk}'>
|
||||||
${status_input}
|
${status_input}
|
||||||
@ -678,13 +734,23 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) {
|
|||||||
var location = getFormFieldValue(`items_location_${pk}`, {}, opts);
|
var location = getFormFieldValue(`items_location_${pk}`, {}, opts);
|
||||||
|
|
||||||
if (quantity != null) {
|
if (quantity != null) {
|
||||||
data.items.push({
|
|
||||||
|
var line = {
|
||||||
line_item: pk,
|
line_item: pk,
|
||||||
quantity: quantity,
|
quantity: quantity,
|
||||||
status: status,
|
status: status,
|
||||||
location: location,
|
location: location,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (getFormFieldElement(`items_batch_code_${pk}`).exists()) {
|
||||||
|
line.batch_code = getFormFieldValue(`items_batch_code_${pk}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getFormFieldElement(`items_serial_numbers_${pk}`).exists()) {
|
||||||
|
line.serial_numbers = getFormFieldValue(`items_serial_numbers_${pk}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.items.push(line);
|
||||||
item_pk_values.push(pk);
|
item_pk_values.push(pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user