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
|
||||
secret_key.txt
|
||||
|
||||
# Ignore python IDE project configuration
|
||||
# IDE / development files
|
||||
.idea/
|
||||
*.code-workspace
|
||||
|
||||
# Coverage reports
|
||||
.coverage
|
||||
|
@ -76,8 +76,8 @@
|
||||
<td>{{ forloop.counter }}</td>
|
||||
{% for item in row.data %}
|
||||
<td>
|
||||
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item }}'/>
|
||||
{{ item }}
|
||||
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item.cell }}'/>
|
||||
{{ item.cell }}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block details %}
|
||||
{% include "part/tabs.html" with tab="bom" %}
|
||||
@ -23,7 +24,11 @@
|
||||
<th>Row</th>
|
||||
{% for col in bom_columns %}
|
||||
<th>
|
||||
{% if col.guess %}
|
||||
{{ col.guess }}
|
||||
{% else %}
|
||||
{{ col.name }}
|
||||
{% endif %}
|
||||
</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
@ -37,12 +42,15 @@
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<input class='numberinput' type='number' min='1' value='{{ row.quantity }}'/>
|
||||
</td>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{% add row.index 1 %}</td>
|
||||
{% for item in row.data %}
|
||||
<td>
|
||||
{{ item }}
|
||||
{% if item.column.guess == 'Quantity' %}
|
||||
<input class='numberinput' type='number' min='1' value='{{ row.quantity }}'/>
|
||||
{% else %}
|
||||
{{ item.cell }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
@ -674,10 +674,33 @@ class BomUpload(FormView):
|
||||
|
||||
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['bom_headers'] = BomUploadManager.HEADERS
|
||||
ctx['bom_columns'] = self.bom_columns
|
||||
ctx['bom_rows'] = self.bom_rows
|
||||
ctx['bom_rows'] = rows
|
||||
ctx['missing_columns'] = self.missing_columns
|
||||
|
||||
return ctx
|
||||
|
Loading…
Reference in New Issue
Block a user