mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Pass column and index data through to each cell in the template
Allows for much more intelligent template rendering
This commit is contained in:
parent
0e95fb773f
commit
b77bfc74ea
3
.gitignore
vendored
3
.gitignore
vendored
@ -37,8 +37,9 @@ InvenTree/media
|
|||||||
# Key file
|
# Key file
|
||||||
secret_key.txt
|
secret_key.txt
|
||||||
|
|
||||||
# Ignore python IDE project configuration
|
# IDE / development files
|
||||||
.idea/
|
.idea/
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
# Coverage reports
|
# Coverage reports
|
||||||
.coverage
|
.coverage
|
||||||
|
@ -76,8 +76,8 @@
|
|||||||
<td>{{ forloop.counter }}</td>
|
<td>{{ forloop.counter }}</td>
|
||||||
{% for item in row.data %}
|
{% for item in row.data %}
|
||||||
<td>
|
<td>
|
||||||
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item }}'/>
|
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item.cell }}'/>
|
||||||
{{ item }}
|
{{ item.cell }}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "part/part_base.html" %}
|
{% extends "part/part_base.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% block details %}
|
{% block details %}
|
||||||
{% include "part/tabs.html" with tab="bom" %}
|
{% include "part/tabs.html" with tab="bom" %}
|
||||||
@ -23,7 +24,11 @@
|
|||||||
<th>Row</th>
|
<th>Row</th>
|
||||||
{% for col in bom_columns %}
|
{% for col in bom_columns %}
|
||||||
<th>
|
<th>
|
||||||
|
{% if col.guess %}
|
||||||
|
{{ col.guess }}
|
||||||
|
{% else %}
|
||||||
{{ col.name }}
|
{{ col.name }}
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
@ -37,12 +42,15 @@
|
|||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class='numberinput' type='number' min='1' value='{{ row.quantity }}'/>
|
|
||||||
</td>
|
</td>
|
||||||
<td>{{ forloop.counter }}</td>
|
<td>{% add row.index 1 %}</td>
|
||||||
{% for item in row.data %}
|
{% for item in row.data %}
|
||||||
<td>
|
<td>
|
||||||
{{ item }}
|
{% if item.column.guess == 'Quantity' %}
|
||||||
|
<input class='numberinput' type='number' min='1' value='{{ row.quantity }}'/>
|
||||||
|
{% else %}
|
||||||
|
{{ item.cell }}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -674,10 +674,33 @@ class BomUpload(FormView):
|
|||||||
|
|
||||||
ctx = super().get_context_data(*args, **kwargs)
|
ctx = super().get_context_data(*args, **kwargs)
|
||||||
|
|
||||||
|
# Give each row item access to the column it is in
|
||||||
|
# This provides for much simpler template rendering
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
for row in self.bom_rows:
|
||||||
|
row_data = row['data']
|
||||||
|
|
||||||
|
data = []
|
||||||
|
|
||||||
|
for idx, item in enumerate(row_data):
|
||||||
|
|
||||||
|
data.append({
|
||||||
|
'cell': item,
|
||||||
|
'idx': idx,
|
||||||
|
'column': self.bom_columns[idx]
|
||||||
|
})
|
||||||
|
|
||||||
|
rows.append({
|
||||||
|
'index': row.get('index', -1),
|
||||||
|
'data': data,
|
||||||
|
'quantity': row.get('quantity', None),
|
||||||
|
})
|
||||||
|
|
||||||
ctx['part'] = self.part
|
ctx['part'] = self.part
|
||||||
ctx['bom_headers'] = BomUploadManager.HEADERS
|
ctx['bom_headers'] = BomUploadManager.HEADERS
|
||||||
ctx['bom_columns'] = self.bom_columns
|
ctx['bom_columns'] = self.bom_columns
|
||||||
ctx['bom_rows'] = self.bom_rows
|
ctx['bom_rows'] = rows
|
||||||
ctx['missing_columns'] = self.missing_columns
|
ctx['missing_columns'] = self.missing_columns
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
Loading…
Reference in New Issue
Block a user