mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +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:
@ -22,9 +22,6 @@
|
||||
{{ setting.description }}
|
||||
</td>
|
||||
<td>
|
||||
{% if setting.model_name %}
|
||||
<b>Model name: {{ setting.model_name }}</b>
|
||||
{% endif %}
|
||||
{% if setting.is_bool %}
|
||||
<div class='form-check form-switch'>
|
||||
<input class='form-check-input boolean-setting' fieldname='{{ setting.key.upper }}' pk='{{ setting.pk }}' setting='{{ setting.key.upper }}' id='setting-value-{{ setting.key.upper }}' type='checkbox' {% if setting.as_bool %}checked=''{% endif %} {% if plugin %}plugin='{{ plugin.slug }}'{% endif %}{% if user_setting %}user='{{request.user.id}}'{% endif %}{% if notification_setting %}notification='{{request.user.id}}'{% endif %}>
|
||||
|
@ -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