mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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,
|
||||
enableFormInput,
|
||||
hideFormInput,
|
||||
setFormInputPlaceholder,
|
||||
setFormGroupVisibility,
|
||||
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
|
||||
function clearFormInput(name, options) {
|
||||
updateFieldValue(name, null, {}, options);
|
||||
|
@ -158,10 +158,26 @@ function stockItemFields(options={}) {
|
||||
// If a "trackable" part is selected, enable serial number field
|
||||
if (data.trackable) {
|
||||
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 {
|
||||
clearFormInput('serial_numbers', opts);
|
||||
disableFormInput('serial_numbers', opts);
|
||||
|
||||
setFormInputPlaceholder('serial_numbers', '{% trans "This part cannot be serialized" %}', opts);
|
||||
}
|
||||
|
||||
// Enable / disable fields based on purchaseable status
|
||||
|
Loading…
Reference in New Issue
Block a user