From 1d67b4cdaaf4fd9cb6af748416af8a24464d751f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 18 Jun 2019 19:24:10 +1000 Subject: [PATCH] Sliders now update the part options via AJAX --- InvenTree/part/serializers.py | 2 + InvenTree/part/templates/part/detail.html | 81 +++++++++++++++++------ InvenTree/templates/slide.html | 2 +- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 36be5de6db..eaea7ecebc 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -100,8 +100,10 @@ class PartSerializer(InvenTreeModelSerializer): 'assembly', 'component', 'trackable', + 'purchaseable', 'salable', 'active', + 'virtual', ] diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 63a79bc0c7..97c5d97c42 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -13,16 +13,16 @@ @@ -102,40 +102,59 @@

Part Type

- - - - - - - + + {% if part.virtual %} + + {% else %} + + {% endif %} - - + + {% if part.assembly %} + + {% else %} + + {% endif %} - - + + {% if part.component %} + + {% else %} + + {% endif %} - - + + {% if part.trackable %} + + {% else %} + + {% endif %} - + + {% if part.purchaseable %} + + {% else %} + {% endif %} - - + + {% if part.salable %} + + {% else %} + + {% endif %}
Template{% include "slide.html" with state=part.is_template %}Part is used as a template for other parts
Virtual{% include "slide.html" with state=part.virtual %}Part is virtual (not a physical part){% include "slide.html" with state=part.virtual field='virtual' %}Part is virtual (not a physical part)Part is not a virtual part
Assembly{% include "slide.html" with state=part.assembly %}Part can be assembled from other parts{% include "slide.html" with state=part.assembly field='assembly' %}Part can be assembled from other partsPart cannot be assembled from other parts
Component{% include "slide.html" with state=part.component %}Part can be used in assemblies{% include "slide.html" with state=part.component field='component' %}Part can be used in assembliesPart cannot be used in assemblies
Trackable{% include "slide.html" with state=part.trackable %}Part stock will be tracked by (serial or batch){% include "slide.html" with state=part.trackable field='trackable' %}Part stock will be tracked by (serial or batch)Part stock will not be tracked by
Purchaseable{% include "slide.html" with state=part.purchaseable %}{% include "slide.html" with state=part.purchaseable field='purchaseable' %}Part can be purchased from external suppliers
Sellable{% include "slide.html" with state=part.salable %}Part can be sold to customers{% include "slide.html" with state=part.salable field='salable' %}Part can be sold to customersPart cannot be sold to customers
@@ -156,6 +175,24 @@ {% block js_ready %} {{ block.super }} + + $(".slidey").change(function() { + var field = $(this).attr('field'); + + var checked = $(this).prop('checked'); + + var data = {}; + + data[field] = checked; + + // Update the particular field + inventreePut('/api/part/{{ part.id }}/', + data, + { + method: 'PATCH', + }, + ); + }); $("#duplicate-part").click(function() { launchModalForm( diff --git a/InvenTree/templates/slide.html b/InvenTree/templates/slide.html index 2d77ead769..d929f1491c 100644 --- a/InvenTree/templates/slide.html +++ b/InvenTree/templates/slide.html @@ -1,3 +1,3 @@
- +
\ No newline at end of file