Make this setting a per-user setting

This commit is contained in:
Oliver 2021-10-06 22:22:20 +11:00
parent 166af3592d
commit d9fddf64f1
7 changed files with 40 additions and 11 deletions

View File

@ -244,8 +244,9 @@
.label-form { .label-form {
margin: 2px; margin: 2px;
padding-left: 4px; padding: 3px;
padding-right: 4px; padding-left: 10px;
padding-right: 10px;
border-radius: 5px; border-radius: 5px;
} }

View File

@ -648,13 +648,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'validator': bool, 'validator': bool,
}, },
'PART_SHOW_QUANTITY_IN_FORMS': {
'name': _('Show Quantity in Forms'),
'description': _('Display available part quantity in some forms'),
'default': True,
'validator': bool,
},
'PART_SHOW_IMPORT': { 'PART_SHOW_IMPORT': {
'name': _('Show Import in Views'), 'name': _('Show Import in Views'),
'description': _('Display the import wizard in some part views'), 'description': _('Display the import wizard in some part views'),
@ -969,6 +962,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'default': 10, 'default': 10,
'validator': [int, MinValueValidator(1)] 'validator': [int, MinValueValidator(1)]
}, },
'PART_SHOW_QUANTITY_IN_FORMS': {
'name': _('Show Quantity in Forms'),
'description': _('Display available part quantity in some forms'),
'default': True,
'validator': bool,
},
} }
class Meta: class Meta:

View File

@ -42,6 +42,12 @@
</a> </a>
</li> </li>
<li class='list-group-item' title='{% trans "Forms" %}'>
<a href='#' class='nav-toggle' id='select-user-forms'>
<span class='fas fa-table'></span>{% trans "Forms" %}
</a>
</li>
<!-- <!--
<li class='list-group-item' title='{% trans "Settings" %}'> <li class='list-group-item' title='{% trans "Settings" %}'>
<a href='#' class='nav-toggle' id='select-user-settings'> <a href='#' class='nav-toggle' id='select-user-settings'>

View File

@ -17,7 +17,6 @@
{% include "InvenTree/settings/setting.html" with key="PART_IPN_REGEX" %} {% include "InvenTree/settings/setting.html" with key="PART_IPN_REGEX" %}
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %} {% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %}
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %} {% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %}
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" %}
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_FORMS" icon="fa-dollar-sign" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_FORMS" icon="fa-dollar-sign" %}
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_RELATED" icon="fa-random" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_RELATED" icon="fa-random" %}
{% include "InvenTree/settings/setting.html" with key="PART_CREATE_INITIAL" icon="fa-boxes" %} {% include "InvenTree/settings/setting.html" with key="PART_CREATE_INITIAL" icon="fa-boxes" %}

View File

@ -20,6 +20,7 @@
{% include "InvenTree/settings/user_search.html" %} {% include "InvenTree/settings/user_search.html" %}
{% include "InvenTree/settings/user_labels.html" %} {% include "InvenTree/settings/user_labels.html" %}
{% include "InvenTree/settings/user_reports.html" %} {% include "InvenTree/settings/user_reports.html" %}
{% include "InvenTree/settings/user_forms.html" %}
{% if user.is_staff %} {% if user.is_staff %}

View File

@ -0,0 +1,22 @@
{% extends "panel.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block label %}user-forms{% endblock %}
{% block heading %}
{% trans "Form Settings" %}
{% endblock %}
{% block content %}
<div class='row'>
<table class='table table-striped table-condensed'>
<tbody>
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" user_setting=True %}
</tbody>
</table>
</div>
{% endblock %}

View File

@ -162,7 +162,7 @@ function renderPart(name, data, parameters, options) {
var stock = ''; var stock = '';
// Display available part quantity // Display available part quantity
if (global_settings.PART_SHOW_QUANTITY_IN_FORMS) { if (user_settings.PART_SHOW_QUANTITY_IN_FORMS) {
if (data.in_stock == 0) { if (data.in_stock == 0) {
stock = `<span class='label-form label-red'>{% trans "No Stock" %}</span>`; stock = `<span class='label-form label-red'>{% trans "No Stock" %}</span>`;
} else { } else {