mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Update placeholders for serial numbers when creating a new stock item
This commit is contained in:
parent
ef7a9b5152
commit
ad6e34953b
@ -28,6 +28,7 @@
|
|||||||
disableFormInput,
|
disableFormInput,
|
||||||
enableFormInput,
|
enableFormInput,
|
||||||
hideFormInput,
|
hideFormInput,
|
||||||
|
setFormInputPlaceholder,
|
||||||
setFormGroupVisibility,
|
setFormGroupVisibility,
|
||||||
showFormInput,
|
showFormInput,
|
||||||
*/
|
*/
|
||||||
@ -1276,6 +1277,11 @@ function initializeGroups(fields, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the placeholder value for a field
|
||||||
|
function setFormInputPlaceholder(name, placeholder, options) {
|
||||||
|
$(options.modal).find(`#id_${name}`).attr('placeholder', placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
// Clear a form input
|
// Clear a form input
|
||||||
function clearFormInput(name, options) {
|
function clearFormInput(name, options) {
|
||||||
updateFieldValue(name, null, {}, options);
|
updateFieldValue(name, null, {}, options);
|
||||||
|
@ -158,10 +158,26 @@ function stockItemFields(options={}) {
|
|||||||
// If a "trackable" part is selected, enable serial number field
|
// If a "trackable" part is selected, enable serial number field
|
||||||
if (data.trackable) {
|
if (data.trackable) {
|
||||||
enableFormInput('serial_numbers', opts);
|
enableFormInput('serial_numbers', opts);
|
||||||
// showFormInput('serial_numbers', opts);
|
|
||||||
|
// Request part serial number information from the server
|
||||||
|
inventreeGet(`/api/part/${data.pk}/serial-numbers/`, {}, {
|
||||||
|
success: function(data) {
|
||||||
|
var placeholder = '';
|
||||||
|
if (data.next) {
|
||||||
|
placeholder = `{% trans "Next available serial number" %}: ${data.next}`;
|
||||||
|
} else if (data.latest) {
|
||||||
|
placeholder = `{% trans "Latest serial number" %}: ${data.latest}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFormInputPlaceholder('serial_numbers', placeholder, opts);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clearFormInput('serial_numbers', opts);
|
clearFormInput('serial_numbers', opts);
|
||||||
disableFormInput('serial_numbers', opts);
|
disableFormInput('serial_numbers', opts);
|
||||||
|
|
||||||
|
setFormInputPlaceholder('serial_numbers', '{% trans "This part cannot be serialized" %}', opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable / disable fields based on purchaseable status
|
// Enable / disable fields based on purchaseable status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user