mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Merge pull request #2882 from SchrodingersGat/allocation-display
Simplify allocation display for part page
This commit is contained in:
commit
bdf7fd5275
@ -211,44 +211,18 @@
|
|||||||
{% if part.component %}
|
{% if part.component %}
|
||||||
{% if required_build_order_quantity > 0 %}
|
{% if required_build_order_quantity > 0 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-clipboard-list'></span></td>
|
<td><span class='fas fa-tools'></span></td>
|
||||||
<td>{% trans "Required for Build Orders" %}</td>
|
|
||||||
<td>{% decimal required_build_order_quantity %}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-dolly'></span></td>
|
|
||||||
<td>{% trans "Allocated to Build Orders" %}</td>
|
<td>{% trans "Allocated to Build Orders" %}</td>
|
||||||
<td>
|
<td>{% progress_bar allocated_build_order_quantity required_build_order_quantity id='build-order-allocated' max_width='150px' %}</td>
|
||||||
{% decimal allocated_build_order_quantity %}
|
|
||||||
{% if allocated_build_order_quantity < required_build_order_quantity %}
|
|
||||||
<span class='fas fa-times-circle icon-red float-right' title='{% trans "Required quantity has not been allocated" %}'></span>
|
|
||||||
{% else %}
|
|
||||||
<span class='fas fa-check-circle icon-green float-right' title='{% trans "Required quantity has been allocated" %}'></span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.salable %}
|
{% if part.salable %}
|
||||||
{% if required_sales_order_quantity > 0 %}
|
{% if required_sales_order_quantity > 0 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-clipboard-list'></span></td>
|
<td><span class='fas fa-truck'></span></td>
|
||||||
<td>{% trans "Required for Sales Orders" %}</td>
|
|
||||||
<td>
|
|
||||||
{% decimal required_sales_order_quantity %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><span class='fas fa-dolly'></span></td>
|
|
||||||
<td>{% trans "Allocated to Sales Orders" %}</td>
|
<td>{% trans "Allocated to Sales Orders" %}</td>
|
||||||
<td>
|
<td>{% progress_bar allocated_sales_order_quantity required_sales_order_quantity id='sales-order-allocated' max_width='150px' %}</td>
|
||||||
{% decimal allocated_sales_order_quantity %}
|
|
||||||
{% if allocated_sales_order_quantity < required_sales_order_quantity %}
|
|
||||||
<span class='fas fa-times-circle icon-red float-right' title='{% trans "Required quantity has not been allocated" %}'></span>
|
|
||||||
{% else %}
|
|
||||||
<span class='fas fa-check-circle icon-green float-right' title='{% trans "Required quantity has been allocated" %}'></span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -352,21 +352,24 @@ def visible_global_settings(*args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def progress_bar(val, max, *args, **kwargs):
|
def progress_bar(val, max_val, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Render a progress bar element
|
Render a progress bar element
|
||||||
"""
|
"""
|
||||||
|
|
||||||
item_id = kwargs.get('id', 'progress-bar')
|
item_id = kwargs.get('id', 'progress-bar')
|
||||||
|
|
||||||
if val > max:
|
val = InvenTree.helpers.normalize(val)
|
||||||
|
max_val = InvenTree.helpers.normalize(max_val)
|
||||||
|
|
||||||
|
if val > max_val:
|
||||||
style = 'progress-bar-over'
|
style = 'progress-bar-over'
|
||||||
elif val < max:
|
elif val < max_val:
|
||||||
style = 'progress-bar-under'
|
style = 'progress-bar-under'
|
||||||
else:
|
else:
|
||||||
style = ''
|
style = ''
|
||||||
|
|
||||||
percent = float(val / max) * 100
|
percent = float(val / max_val) * 100
|
||||||
|
|
||||||
if percent > 100:
|
if percent > 100:
|
||||||
percent = 100
|
percent = 100
|
||||||
@ -383,7 +386,7 @@ def progress_bar(val, max, *args, **kwargs):
|
|||||||
html = f"""
|
html = f"""
|
||||||
<div id='{item_id}' class='progress' style='{" ".join(style_tags)}'>
|
<div id='{item_id}' class='progress' style='{" ".join(style_tags)}'>
|
||||||
<div class='progress-bar {style}' role='progressbar' aria-valuemin='0' aria-valuemax='100' style='width:{percent}%'></div>
|
<div class='progress-bar {style}' role='progressbar' aria-valuemin='0' aria-valuemax='100' style='width:{percent}%'></div>
|
||||||
<div class='progress-value'>{val} / {max}</div>
|
<div class='progress-value'>{val} / {max_val}</div>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user