From 21dd893c01ad2f4b703387d142e6dbfc95b211b7 Mon Sep 17 00:00:00 2001
From: Oliver Walters
Date: Sun, 26 May 2019 00:29:17 +1000
Subject: [PATCH] Display templated parts as italic in the part list
---
InvenTree/part/forms.py | 1 +
InvenTree/part/serializers.py | 2 ++
InvenTree/part/templates/part/part_base.html | 2 ++
InvenTree/static/script/inventree/part.js | 13 +++++++++++++
4 files changed, 18 insertions(+)
diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py
index e069df6ed6..4b91d3bc22 100644
--- a/InvenTree/part/forms.py
+++ b/InvenTree/part/forms.py
@@ -93,6 +93,7 @@ class EditPartForm(HelperForm):
'name',
'IPN',
'variant',
+ 'is_template',
'description',
'keywords',
'URL',
diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py
index 445a10601a..540f754765 100644
--- a/InvenTree/part/serializers.py
+++ b/InvenTree/part/serializers.py
@@ -85,6 +85,8 @@ class PartSerializer(serializers.ModelSerializer):
'full_name',
'name',
'IPN',
+ 'is_template',
+ 'variant_of',
'variant',
'description',
'keywords',
diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html
index 748303df35..f91c5ac1e2 100644
--- a/InvenTree/part/templates/part/part_base.html
+++ b/InvenTree/part/templates/part/part_base.html
@@ -47,10 +47,12 @@
+ {% if part.is_template == False %}
{% include "qr_button.html" %}
+ {% endif %}
diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js
index 51d86f1c7a..1001ef11a1 100644
--- a/InvenTree/static/script/inventree/part.js
+++ b/InvenTree/static/script/inventree/part.js
@@ -124,7 +124,12 @@ function loadPartTable(table, url, options={}) {
sortable: true,
formatter: function(value, row, index, field) {
+ if (row.is_template) {
+ value = '' + value + '';
+ }
+
var display = imageHoverIcon(row.image_url) + renderLink(value, row.url);
+
if (!row.active) {
display = display + "INACTIVE";
}
@@ -135,6 +140,14 @@ function loadPartTable(table, url, options={}) {
sortable: true,
field: 'description',
title: 'Description',
+ formatter: function(value, row, index, field) {
+
+ if (row.is_template) {
+ value = '' + value + '';
+ }
+
+ return value;
+ }
},
{
sortable: true,