From 8842d50c723f219285b951394551fd5106addc52 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 18 Jun 2019 22:49:43 +1000 Subject: [PATCH 1/4] Replace a whole bunch o' drop-down options with pretty buttons --- InvenTree/part/templates/part/detail.html | 61 +------------------- InvenTree/part/templates/part/part_base.html | 58 ++++++++++++++++++- 2 files changed, 56 insertions(+), 63 deletions(-) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index fe07954a5a..ef47e70515 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -4,31 +4,6 @@ {% include 'part/tabs.html' with tab='detail' %} -
-
-
-
-
- - -
-
-
-

Part Details

@@ -194,31 +169,6 @@ }, ); }); - - $("#duplicate-part").click(function() { - launchModalForm( - "{% url 'part-duplicate' part.id %}", - { - follow: true, - } - ); - }); - - $("#order-part").click(function() { - launchModalForm("/order/purchase-order/order-parts/", { - data: { - part: {{ part.id }}, - }, - }); - }); - - $("#edit-part").click(function() { - launchModalForm( - "{% url 'part-edit' part.id %}", - { - reload: true, - }); - }); $('#activate-part').click(function() { showQuestionDialog( @@ -264,14 +214,5 @@ } ); }); - - - $('#delete-part').click(function() { - launchModalForm( - "{% url 'part-delete' part.id %}", - { - redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %} - }); - }); - + {% endblock %} diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 92dccbcae1..3377c730a5 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -46,9 +46,27 @@ {% if part.is_template == False %} {% include "qr_button.html" %} + {% if part.active %} + {% if part.purchaseable %} + + {% endif %} + {% endif %} + {% endif %} + + + {% if not part.active %} + {% endif %}

@@ -170,9 +188,6 @@ }); }); - $('#toggle-starred').click(function() { - }); - $("#part-thumb").click(function() { launchModalForm( "{% url 'part-image' part.id %}", @@ -182,4 +197,41 @@ ); }); + $("#part-edit").click(function() { + launchModalForm( + "{% url 'part-edit' part.id %}", + { + reload: true, + } + ); + }); + + $("#part-order").click(function() { + launchModalForm("/order/purchase-order/order-parts/", { + data: { + part: {{ part.id }}, + }, + }); + }); + + $("#part-duplicate").click(function() { + launchModalForm( + "{% url 'part-duplicate' part.id %}", + { + follow: true, + } + ); + }); + + {% if not part.active %} + $("#part-delete").click(function() { + launchModalForm( + "{% url 'part-delete' part.id %}", + { + redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %} + } + ); + }); + {% endif %} + {% endblock %} \ No newline at end of file From 0285d3ee833bd8f0317972925c23e6489af4d9b3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 18 Jun 2019 22:54:32 +1000 Subject: [PATCH 2/4] Improved button mechanics --- InvenTree/part/forms.py | 1 + InvenTree/part/views.py | 1 + 2 files changed, 2 insertions(+) diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 6430ac922b..e268c2a167 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -102,6 +102,7 @@ class EditPartForm(HelperForm): 'units', 'minimum_stock', 'notes', + 'active', ] diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 1224d1de22..135a216218 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -446,6 +446,7 @@ class PartDetail(DetailView): part = self.get_object() context['starred'] = part.isStarredBy(self.request.user) + context['disabled'] = not part.active context['OrderStatus'] = OrderStatus From 3dddb10f5d248304c1416864bde769d30fcf9e6a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 18 Jun 2019 23:12:13 +1000 Subject: [PATCH 3/4] Pretty toggle buttons in modal forms --- InvenTree/static/script/inventree/modals.js | 17 +++++++++++++++++ InvenTree/templates/slide.html | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/InvenTree/static/script/inventree/modals.js b/InvenTree/static/script/inventree/modals.js index 7d55d02865..31c2233f8d 100644 --- a/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/static/script/inventree/modals.js @@ -43,6 +43,22 @@ function partialMatcher(params, data) { } +function attachToggle(modal) { + /* Attach 'bootstrap-toggle' functionality to any checkbox in the modal. + * This is simple for visual improvement, + * and also larger toggle style buttons are easier to press! + */ + + $(modal).find("input[type='checkbox']").each(function(x) { + $(this).bootstrapToggle({ + size: 'small', + onstyle: 'success', + offstyle: 'warning', + }); + }); +} + + function attachSelect(modal) { /* Attach 'select2' functionality to any drop-down list in the modal. * Provides search filtering for dropdown items @@ -351,6 +367,7 @@ function injectModalForm(modal, form_html) { */ $(modal).find('.modal-form-content').html(form_html); attachSelect(modal); + attachToggle(modal); } diff --git a/InvenTree/templates/slide.html b/InvenTree/templates/slide.html index d929f1491c..14afc4aa04 100644 --- a/InvenTree/templates/slide.html +++ b/InvenTree/templates/slide.html @@ -1,3 +1,3 @@
- +
\ No newline at end of file From fe4bc15c8e6b4763d096f9157c2b0a13dfc419bf Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 18 Jun 2019 23:18:48 +1000 Subject: [PATCH 4/4] Improved button layout for purchase order page --- InvenTree/order/templates/order/purchase_order_detail.html | 6 +++--- InvenTree/order/views.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 68370c9c22..a0b780408c 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -61,12 +61,12 @@ InvenTree | {{ order }}
-
+
{% if order.status == OrderStatus.PENDING and order.lines.count > 0 %} {% elif order.status == OrderStatus.PLACED %} - + {% endif %}
@@ -77,7 +77,7 @@ InvenTree | {{ order }} {% endif %} - +
diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index b5b9540fed..ae27a0bcc4 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -158,7 +158,11 @@ class PurchaseOrderExport(AjaxView): export_format = request.GET.get('format', 'csv') - filename = str(order) + '.' + export_format + filename = '{order} - {company}.{fmt}'.format( + order=str(order), + company=order.supplier.name, + fmt=export_format + ) filedata = order.export_to_file(format=export_format)
Line