mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +00:00
Bug fix for boolean settings (#3760)
* Fix for boolean settings - Ensure "user" attribute is provided - Fix for *all* boolean user settings * Refactor boolean setting into separate template * Fix order-of-operations * Fix settings for specific plugins
This commit is contained in:
parent
fbc99257bd
commit
cc68cd83a9
@ -23,9 +23,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if setting.is_bool %}
|
{% if setting.is_bool %}
|
||||||
<div class='form-check form-switch'>
|
{% include "InvenTree/settings/setting_boolean.html" %}
|
||||||
<input class='form-check-input boolean-setting' fieldname='{{ setting.key.upper }}' pk='{{ setting.pk }}' setting='{{ setting.key.upper }}' id='setting-value-{{ setting.pk }}-{{ setting.typ }}' type='checkbox' {% if setting.as_bool %}checked=''{% endif %}{{reference}}>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div id='setting-{{ setting.pk }}'>
|
<div id='setting-{{ setting.pk }}'>
|
||||||
<span id='setting-value-{{ setting.pk }}-{{ setting.typ }}' fieldname='{{ setting.key.upper }}'>
|
<span id='setting-value-{{ setting.pk }}-{{ setting.typ }}' fieldname='{{ setting.key.upper }}'>
|
||||||
@ -41,7 +39,18 @@
|
|||||||
</span>
|
</span>
|
||||||
{{ setting.units }}
|
{{ setting.units }}
|
||||||
<div class='btn-group float-right'>
|
<div class='btn-group float-right'>
|
||||||
<button class='btn btn-outline-secondary btn-small btn-edit-setting' pk='{{ setting.pk }}' setting='{{ setting.key.upper }}' title='{% trans "Edit setting" %}' {% if plugin %}plugin='{{ plugin.slug }}'{% endif %}{% if user_setting %}user='{{request.user.id}}'{% endif %}>
|
<button
|
||||||
|
class='btn btn-outline-secondary btn-small btn-edit-setting'
|
||||||
|
title='{% trans "Edit setting" %}'
|
||||||
|
pk='{{ setting.pk }}'
|
||||||
|
setting='{{ setting.key.upper }}'
|
||||||
|
{% if plugin %}plugin='{{ plugin.slug }}'{% endif %}
|
||||||
|
{% if user_setting or notification_setting %}user='{{request.user.id}}'{% endif %}
|
||||||
|
{% if notification_setting %}
|
||||||
|
notification=true
|
||||||
|
method='{{ setting.method }}'
|
||||||
|
{% endif %}
|
||||||
|
>
|
||||||
<span class='fas fa-edit icon-green'></span>
|
<span class='fas fa-edit icon-green'></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
18
InvenTree/templates/InvenTree/settings/setting_boolean.html
Normal file
18
InvenTree/templates/InvenTree/settings/setting_boolean.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<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.pk }}-{{ setting.typ }}'
|
||||||
|
type='checkbox'
|
||||||
|
{% if setting.as_bool %}checked=''{% endif %}
|
||||||
|
{{ reference }}
|
||||||
|
{% if plugin %}plugin='{{ plugin.slug }}'{% endif %}
|
||||||
|
{% if user_setting or notification_setting %}user='{{ request.user.pk }}'{% endif %}
|
||||||
|
{% if notification_setting %}
|
||||||
|
notification=true
|
||||||
|
method='{{ setting.method }}'
|
||||||
|
{% endif %}
|
||||||
|
>
|
||||||
|
</div>
|
@ -78,12 +78,12 @@ $('table').find('.boolean-setting').change(function() {
|
|||||||
// Global setting by default
|
// Global setting by default
|
||||||
var url = `/api/settings/global/${setting}/`;
|
var url = `/api/settings/global/${setting}/`;
|
||||||
|
|
||||||
if (plugin) {
|
if (notification) {
|
||||||
|
url = `/api/settings/notification/${pk}/`;
|
||||||
|
} else if (plugin) {
|
||||||
url = `/api/plugin/settings/${plugin}/${setting}/`;
|
url = `/api/plugin/settings/${plugin}/${setting}/`;
|
||||||
} else if (user) {
|
} else if (user) {
|
||||||
url = `/api/settings/user/${setting}/`;
|
url = `/api/settings/user/${setting}/`;
|
||||||
} else if (notification) {
|
|
||||||
url = `/api/settings/notification/${pk}/`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inventreePut(
|
inventreePut(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user