2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-11 07:24:15 +00:00

Add ability to specify "source location" for stock allocations

- Defaults to build.take_from
- User-selectable at run-time
- Selected value affects select2 query
This commit is contained in:
Oliver
2021-10-05 10:38:18 +11:00
parent 76668b0d54
commit 563deb5ffa
4 changed files with 94 additions and 14 deletions

View File

@ -728,10 +728,17 @@ function updateFieldValues(fields, options) {
}
}
/*
* Update the value of a named field
*/
function updateFieldValue(name, value, field, options) {
var el = $(options.modal).find(`#id_${name}`);
if (!el) {
console.log(`WARNING: updateFieldValue could not find field '${name}'`);
return;
}
switch (field.type) {
case 'boolean':
el.prop('checked', value);
@ -1105,7 +1112,14 @@ function addClearCallbacks(fields, options) {
function addClearCallback(name, field, options) {
$(options.modal).find(`#clear_${name}`).click(function() {
var el = $(options.modal).find(`#clear_${name}`);
if (!el) {
console.log(`WARNING: addClearCallback could not find field '${name}'`);
return;
}
el.click(function() {
updateFieldValue(name, null, field, options);
});
}
@ -1332,6 +1346,11 @@ function initializeRelatedField(field, fields, options) {
query.search = params.term;
query.offset = offset;
query.limit = pageSize;
// Allow custom run-time filter augmentation
if ("adjustFilters" in field) {
query = field.adjustFilters(query);
}
return query;
},
@ -1453,7 +1472,6 @@ function initializeRelatedField(field, fields, options) {
}
}
});
}
}