From 4319ba16af0fc9dfe96fa6322bc596fd21f5eea7 Mon Sep 17 00:00:00 2001 From: Matthias <matmair@live.de> Date: Wed, 26 May 2021 09:20:50 +0200 Subject: [PATCH] Settings to show import-button --- InvenTree/common/models.py | 7 +++++++ .../part/templates/part/category_navbar.html | 5 ++++- .../templates/InvenTree/settings/part.html | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 99712b2a93..30de70f6d9 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -211,6 +211,13 @@ class InvenTreeSetting(models.Model): 'validator': bool, }, + 'PART_SHOW_IMPORT': { + 'name': _('Show Import in Views'), + 'description': _('Display the import wizard in some part views'), + 'default': False, + 'validator': bool, + }, + 'REPORT_DEBUG_MODE': { 'name': _('Debug Mode'), 'description': _('Generate reports in debug mode (HTML output)'), diff --git a/InvenTree/part/templates/part/category_navbar.html b/InvenTree/part/templates/part/category_navbar.html index 553b03745b..f6d083b864 100644 --- a/InvenTree/part/templates/part/category_navbar.html +++ b/InvenTree/part/templates/part/category_navbar.html @@ -1,4 +1,7 @@ {% load i18n %} +{% load inventree_extras %} + +{% settings_value 'PART_SHOW_IMPORT' as show_import %} <ul class='list-group'> @@ -30,7 +33,7 @@ </a> </li> - {% if user.is_staff and roles.part.add %} + {% if show_import and user.is_staff and roles.part.add %} <li class='list-group-item {% if tab == "import" %}active{% endif %}' title='{% trans "Import Parts" %}'> <a href='{% url "part-import" %}'> <span class='fas fa-file-upload'></span> diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index e359acdfc2..c054ef7111 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -37,6 +37,22 @@ </tbody> </table> +<h4>{% trans "Part Import" %}</h4> + + <button class='btn btn-success' id='import-part'> + <span class='fas fa-plus-circle'></span> {% trans "Import Part" %} + </button> + + +<table class='table table-striped table-condensed'> + {% include "InvenTree/settings/header.html" %} + <tbody> + {% include "InvenTree/settings/setting.html" with key="PART_SHOW_IMPORT" icon="fa-file-upload" %} + </tbody> +</table> + + + <h4>{% trans "Part Parameter Templates" %}</h4> <div id='param-buttons'> @@ -121,4 +137,8 @@ }); }); + $("#import-part").click(function() { + launchModalForm("{% url 'part-import' %}", {}); + }); + {% endblock %} \ No newline at end of file