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

Start of API forms for stock item

This commit is contained in:
Oliver
2021-10-19 22:49:48 +11:00
parent 9fe1dd7be4
commit 4a0ed4b2a1
4 changed files with 112 additions and 3 deletions

View File

@ -179,6 +179,7 @@ function constructChangeForm(fields, options) {
// Request existing data from the API endpoint
$.ajax({
url: options.url,
data: options.params || {},
type: 'GET',
contentType: 'application/json',
dataType: 'json',
@ -194,6 +195,17 @@ function constructChangeForm(fields, options) {
fields[field].value = data[field];
}
}
// An optional function can be provided to process the returned results,
// before they are rendered to the form
if (options.processResults) {
var processed = options.processResults(data, fields, options);
// If the processResults function returns data, it will be stored
if (processed) {
data = processed;
}
}
// Store the entire data object
options.instance = data;