From 57240865e8cc183f81b39659f7f3c6ebeb5e9758 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 30 Oct 2021 00:05:32 +1100 Subject: [PATCH] More tweaking --- InvenTree/InvenTree/static/css/inventree.css | 3 + .../build/templates/build/build_base.html | 2 +- InvenTree/build/templates/build/detail.html | 3 +- .../templates/company/company_base.html | 2 +- .../company/templates/company/detail.html | 17 +++-- InvenTree/part/templates/part/bom.html | 3 - InvenTree/part/templates/part/detail.html | 63 ++++++++++++++----- InvenTree/part/templates/part/part_thumb.html | 26 ++++---- .../part/templatetags/inventree_extras.py | 38 +++++++++++ InvenTree/templates/js/translated/build.js | 7 ++- InvenTree/templates/js/translated/helpers.js | 8 ++- InvenTree/templates/js/translated/part.js | 8 +-- 12 files changed, 131 insertions(+), 49 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index ab65d5d460..28ee31a46e 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -94,6 +94,9 @@ width: 100%; margin-bottom: 0px; background: #eeeef5; + font-size: 75%; + height: 1.25rem; + border-radius: 10px; } .progress-bar { diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index fb91771d88..826baf13ea 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -146,7 +146,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Completed" %} - {{ build.completed }} / {{ build.quantity }} + {% progress_bar build.completed build.quantity id='build-completed' max_width='150px' %} {% if build.parent %} diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 556c54f35c..c299c7e1b9 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -1,6 +1,7 @@ {% extends "build/build_base.html" %} {% load static %} {% load i18n %} +{% load inventree_extras %} {% load status_codes %} {% load markdownify %} @@ -65,7 +66,7 @@ {% trans "Completed" %} - {{ build.completed }} / {{ build.quantity }} + {% progress_bar build.completed build.quantity id='build-completed-2' max_width='150px' %} {% if build.active and build.has_untracked_bom_items %} diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 86797231b4..b9cd650395 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -44,7 +44,7 @@ src="{% static 'img/blank_image.png' %}" {% endif %}/>
-
+
{% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} {% if allow_download %} diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index 6aec397e47..14bc79b277 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -60,18 +60,23 @@
-

{% trans "Manufacturer Parts" %}

+
+

{% trans "Manufacturer Parts" %}

+ {% include "spacer.html" %} +
+ {% if roles.purchase_order.add %} + + {% endif %} +
+
{% if roles.purchase_order.change %}
- {% if roles.purchase_order.add %} - - {% endif %}
- {% endif %}
diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index d26915a628..6b097f2043 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -109,14 +109,21 @@
-

{% trans "Part Test Templates" %}

+
+

{% trans "Part Test Templates" %}

+ {% include "spacer.html" %} +
+
+ +
+
+
-
- -
@@ -214,17 +221,22 @@
-

{% trans "Part Variants" %}

+
+

{% trans "Part Variants" %}

+ {% include "spacer.html" %} +
+ {% if part.is_template and part.active %} + + {% endif %} +
+
- {% if part.is_template and part.active %} - - {% endif %}
@@ -330,7 +342,17 @@
-

{% trans "Bill of Materials" %}

+
+

{% trans "Bill of Materials" %}

+ {% include "spacer.html" %} +
+ {% if roles.part.change %} + + {% endif %} +
+
{% include "part/bom.html" with part=part %} @@ -355,16 +377,23 @@
-

{% trans "Part Builds" %}

+
+

{% trans "Part Builds" %}

+ {% include "spacer.html" %} +
+ {% if part.active %} + {% if roles.build.add %} + + {% endif %} + {% endif %} +
+
- {% if part.active %} - {% if roles.build.add %} - - {% endif %} - {% endif %}
diff --git a/InvenTree/part/templates/part/part_thumb.html b/InvenTree/part/templates/part/part_thumb.html index e93b71c825..0d437c4fb2 100644 --- a/InvenTree/part/templates/part/part_thumb.html +++ b/InvenTree/part/templates/part/part_thumb.html @@ -4,22 +4,22 @@ {% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} -
+
+ {% if roles.part.change %} +
+
+ + + {% if allow_download %} + + {% endif %} +
+
+ {% endif %} -
-{% if roles.part.change %} -
-
- - - {% if allow_download %} - - {% endif %} -
-
-{% endif %} \ No newline at end of file +
\ No newline at end of file diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index dab7be6eb9..b66bcd030d 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -244,6 +244,44 @@ def global_settings(*args, **kwargs): return InvenTreeSetting.allValues() +@register.simple_tag() +def progress_bar(val, max, *args, **kwargs): + """ + Render a progress bar element + """ + + id = kwargs.get('id', 'progress-bar') + + if val > max: + style = 'progress-bar-over' + elif val < max: + style = 'progress-bar-under' + else: + style = '' + + percent = float(val/max) * 100 + + if percent > 100: + percent = 100 + elif percent < 0: + percent = 0 + + style_tags = [] + + max_width = kwargs.get('max_width', None) + + if max_width: + style_tags.append(f'max-width: {max_width};') + + html = f""" +
+
+
{val} / {max}
+
+ """ + + return mark_safe(html) + @register.simple_tag() def get_color_theme_css(username): diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index b6c98fc49e..dec9a4aaf7 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -34,8 +34,8 @@ function buildFormFields() { reference: { prefix: global_settings.BUILDORDER_REFERENCE_PREFIX, }, - title: {}, part: {}, + title: {}, quantity: {}, parent: { filters: { @@ -937,7 +937,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { var progress = makeProgressBar( allocatedLines, - totalLines + totalLines, + { + max_width: '150px', + } ); build_progress.html(progress); diff --git a/InvenTree/templates/js/translated/helpers.js b/InvenTree/templates/js/translated/helpers.js index af28110b42..a1679a25b9 100644 --- a/InvenTree/templates/js/translated/helpers.js +++ b/InvenTree/templates/js/translated/helpers.js @@ -182,8 +182,14 @@ function makeProgressBar(value, maximum, opts={}) { var id = options.id || 'progress-bar'; + var style = ''; + + if (opts.max_width) { + style += `max-width: ${options.max_width}; `; + } + return ` -
+
${text}
diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index 2d18033c23..816a0b19b4 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -943,20 +943,20 @@ function loadPartTable(table, url, options={}) { // Is stock "low" (below the 'minimum_stock' quantity)? if (row.minimum_stock && row.minimum_stock > value) { - value += `{% trans "Low stock" %}`; + value += `{% trans "Low stock" %}`; } } else if (row.on_order) { // There is no stock available, but stock is on order - value = `0{% trans "On Order" %}: ${row.on_order}`; + value = `0{% trans "On Order" %}: ${row.on_order}`; link = '?display=purchase-orders'; } else if (row.building) { // There is no stock available, but stock is being built - value = `0{% trans "Building" %}: ${row.building}`; + value = `0{% trans "Building" %}: ${row.building}`; link = '?display=build-orders'; } else { // There is no stock available - value = `0{% trans "No Stock" %}`; + value = `0{% trans "No Stock" %}`; } return renderLink(value, `/part/${row.pk}/${link}`);