2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Include API endpoints in OPTIONS metadata

This commit is contained in:
Oliver
2021-06-25 00:36:22 +10:00
parent 04374c71c2
commit 970a5d5eed
2 changed files with 55 additions and 14 deletions

View File

@ -213,6 +213,8 @@ function constructFormBody(url, fields, options={}) {
}
}
// Render selected fields
for (var idx = 0; idx < field_names.length; idx++) {
var name = field_names[idx];
@ -242,6 +244,7 @@ function constructFormBody(url, fields, options={}) {
modalSetTitle(modal, title);
// Insert generated form content
$(modal).find('.modal-form-content').html(html);
$(modal).modal('show');
@ -434,8 +437,8 @@ function constructInput(name, parameters, options={}) {
case 'choice':
func = constructChoiceInput;
break;
case 'field':
// TODO: foreign key field!
case 'related field':
func = constructRelatedFieldInput;
break;
default:
// Unsupported field type!
@ -597,6 +600,22 @@ function constructChoiceInput(name, parameters, options={}) {
}
/*
* Construct a "related field" input.
* This will create a "select" input which will then, (after form is loaded),
* be converted into a select2 input.
* This will then be served custom data from the API (as required)...
*/
function constructRelatedFieldInput(name, parameters, options={}) {
var html = `<select id='id_${name}' class='select form-control' name='${name}'></select>`;
// Don't load any options - they will be filled via an AJAX request
return html;
}
/*
* Construct a 'help text' div based on the field parameters
*