2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 12:40:57 +00:00

Model introspection

- Find the class registered to the model (or log an error)
- Pass the api_url through to the frontend
This commit is contained in:
Oliver
2022-05-12 17:28:55 +10:00
parent e112d555d4
commit a81ea01e8e
6 changed files with 84 additions and 9 deletions

View File

@ -71,9 +71,24 @@ function editSetting(key, options={}) {
help_text: response.description,
type: response.type,
choices: response.choices,
value: response.value,
}
};
// Foreign key lookup available!
if (response.type == 'related field') {
if (response.model_name && response.api_url) {
fields.value.type = 'related field';
fields.value.model = response.model_name.split('.').at(-1);
fields.value.api_url = response.api_url;
} else {
// Unknown / unsupported model type, default to 'text' field
fields.value.type = 'text';
console.warn(`Unsupported model type: '${response.model_name}' for setting '${response.key}'`);
}
}
constructChangeForm(fields, {
url: url,
method: 'PATCH',