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:
@ -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',
|
||||
|
Reference in New Issue
Block a user