mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1 from matmair/fix-eeintech
Looks good, thanks @matmair !
This commit is contained in:
commit
6857964c17
@ -195,7 +195,7 @@ class FileManagementFormView(MultiStepFormView):
|
||||
def get_context_data(self, form, **kwargs):
|
||||
context = super().get_context_data(form=form, **kwargs)
|
||||
|
||||
if self.steps.current == 'fields' or self.steps.current == 'items':
|
||||
if self.steps.current in ('fields', 'items'):
|
||||
|
||||
# Get columns and row data
|
||||
self.columns = self.file_manager.columns()
|
||||
@ -333,20 +333,34 @@ class FileManagementFormView(MultiStepFormView):
|
||||
'errors': {},
|
||||
})
|
||||
else:
|
||||
if self.column_names:
|
||||
rows_shown = []
|
||||
|
||||
# Update the row data
|
||||
for row in self.rows:
|
||||
row_data = row['data']
|
||||
|
||||
data = []
|
||||
show_data = []
|
||||
|
||||
for idx, item in enumerate(row_data):
|
||||
data.append({
|
||||
column_data = {
|
||||
'cell': item,
|
||||
'idx': idx,
|
||||
'column': self.columns[idx],
|
||||
})
|
||||
}
|
||||
data.append(column_data)
|
||||
if not self.column_names or self.columns[idx]['name'] in self.column_names:
|
||||
show_data.append(column_data)
|
||||
|
||||
row['data'] = data
|
||||
if self.column_names:
|
||||
current_row = row
|
||||
current_row['data'] = show_data
|
||||
rows_shown.append(current_row)
|
||||
|
||||
if self.column_names and self.get_step_index() == 3:
|
||||
self.rows = rows_shown
|
||||
|
||||
# In the item selection step: update row data to contain fields
|
||||
if form and self.steps.current == 'items':
|
||||
@ -435,7 +449,7 @@ class FileManagementFormView(MultiStepFormView):
|
||||
}
|
||||
|
||||
# Data validation
|
||||
valid = len(self.extra_context_data.get('missing_columns', [])) == 0 and not self.extra_context_data.get('duplicates', [])
|
||||
valid = not missing_columns and not duplicates
|
||||
|
||||
return valid
|
||||
|
||||
@ -452,7 +466,7 @@ class FileManagementFormView(MultiStepFormView):
|
||||
valid = self.check_field_selection(form)
|
||||
|
||||
if not valid:
|
||||
form.add_error(None, 'Fields matching failed')
|
||||
form.add_error(None, _('Fields matching failed'))
|
||||
|
||||
elif step == 'items':
|
||||
pass
|
||||
|
@ -63,16 +63,16 @@
|
||||
{% for item in row.data %}
|
||||
<td>
|
||||
{% if item.column.guess == 'Quantity' %}
|
||||
{% for field in form.visible_fields %}
|
||||
{% if field.name == row.quantity_select %}
|
||||
{{ field }}
|
||||
{% for field in form.visible_fields %}
|
||||
{% if field.name == row.quantity_select %}
|
||||
{{ field }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if row.errors.quantity %}
|
||||
<p class='help-inline'>{{ row.errors.quantity }}</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if row.errors.quantity %}
|
||||
<p class='help-inline'>{{ row.errors.quantity }}</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ item.cell }}
|
||||
{{ item.cell }}
|
||||
{% endif %}
|
||||
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item.cell }}'/>
|
||||
</td>
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
{% block details %}
|
||||
|
||||
<p>{% trans "Step" %} {{ wizard.steps.step1 }} {% trans "of" %} {{ wizard.steps.count }}
|
||||
<p>{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %}
|
||||
{% if description %}- {{ description }}{% endif %}</p>
|
||||
|
||||
{% block form_alert %}
|
||||
|
Loading…
Reference in New Issue
Block a user