mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #440 from SchrodingersGat/form-button-fixes
Form button fixes
This commit is contained in:
commit
eb645ee42b
@ -4,7 +4,7 @@ Provides information on the current InvenTree version
|
||||
|
||||
import subprocess
|
||||
|
||||
INVENTREE_SW_VERSION = "0.0.2"
|
||||
INVENTREE_SW_VERSION = "0.0.3"
|
||||
|
||||
|
||||
def inventreeVersion():
|
||||
|
@ -36,8 +36,8 @@
|
||||
{{ part.full_name }} <small><i>{{ part.description }}</i></small>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-default btn-create' id='new_supplier_part_{{ part.id }}' title='Create new supplier part for {{ part }}' type='button'>
|
||||
<span part-id='{{ part.id }}' onClick='newSupplierPartFromOrderWizard()' class='glyphicon glyphicon-small glyphicon-plus'></span>
|
||||
<button class='btn btn-default btn-create' onClick='newSupplierPartFromOrderWizard()' id='new_supplier_part_{{ part.id }}' title='Create new supplier part for {{ part }}' type='button'>
|
||||
<span part-id='{{ part.id }}' class='glyphicon glyphicon-small glyphicon-plus'></span>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
@ -63,8 +63,8 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' id='del_item_{{ part.id }}' title='Remove part' type='button'>
|
||||
<span row='part_row_{{ part.id }}' onclick='removeOrderRowFromOrderWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onclick='removeOrderRowFromOrderWizard()' id='del_item_{{ part.id }}' title='Remove part' type='button'>
|
||||
<span row='part_row_{{ part.id }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -41,8 +41,9 @@
|
||||
class='btn btn-default btn-create'
|
||||
id='new_po_{{ supplier.id }}'
|
||||
title='Create new purchase order for {{ supplier.name }}'
|
||||
type='button'>
|
||||
<span supplier-id='{{ supplier.id }}' onclick='newPurchaseOrderFromOrderWizard()' class='glyphicon glyphicon-small glyphicon-plus'></span>
|
||||
type='button'
|
||||
onclick='newPurchaseOrderFromOrderWizard()'>
|
||||
<span supplier-id='{{ supplier.id }}' class='glyphicon glyphicon-small glyphicon-plus'></span>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -57,8 +57,8 @@ Receive outstanding parts for <b>{{ order }}</b> - <i>{{ order.description }}</i
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' id='del_item_{{ line.id }}' title='Remove line' type='button'>
|
||||
<span row='line_row_{{ line.id }}' onClick="removeOrderRowFromOrderWizard()" class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onClick="removeOrderRowFromOrderWizard()" id='del_item_{{ line.id }}' title='Remove line' type='button'>
|
||||
<span row='line_row_{{ line.id }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -149,9 +149,7 @@ class BomUploadManager:
|
||||
return len(self.data.headers)
|
||||
|
||||
def row_count(self):
|
||||
""" Return the number of rows in the file.
|
||||
Ignored the top rows as indicated by 'starting row'
|
||||
"""
|
||||
""" Return the number of rows in the file. """
|
||||
|
||||
if self.data is None:
|
||||
return 0
|
||||
|
@ -8,7 +8,6 @@ from __future__ import unicode_literals
|
||||
from InvenTree.forms import HelperForm
|
||||
|
||||
from django import forms
|
||||
from django.core.validators import MinValueValidator
|
||||
|
||||
from .models import Part, PartCategory, PartAttachment
|
||||
from .models import BomItem
|
||||
@ -51,18 +50,6 @@ class BomUploadSelectFile(HelperForm):
|
||||
]
|
||||
|
||||
|
||||
class BomUploadSelectFields(HelperForm):
|
||||
""" Form for selecting BOM fields """
|
||||
|
||||
starting_row = forms.IntegerField(required=True, initial=2, help_text='Index of starting row', validators=[MinValueValidator(1)])
|
||||
|
||||
class Meta:
|
||||
model = Part
|
||||
fields = [
|
||||
'starting_row',
|
||||
]
|
||||
|
||||
|
||||
class EditPartAttachmentForm(HelperForm):
|
||||
""" Form for editing a PartAttachment object """
|
||||
|
||||
|
@ -24,9 +24,6 @@
|
||||
<form method="post" action='' class='js-modal-form' enctype="multipart/form-data">
|
||||
<button type="submit" class="save btn btn-default">Submit Selections</button>
|
||||
{% csrf_token %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% crispy form %}
|
||||
|
||||
<input type='hidden' name='form_step' value='select_fields'/>
|
||||
|
||||
@ -40,8 +37,8 @@
|
||||
<div>
|
||||
<input type='hidden' name='col_name_{{ forloop.counter0 }}' value='{{ col.name }}'/>
|
||||
{{ col.name }}
|
||||
<button class='btn btn-default btn-remove' id='del_col_{{ forloop.counter0 }}' style='display: inline; float: right;' title='Remove column'>
|
||||
<span col_id='{{ forloop.counter0 }}' onClick='removeColFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onClick='removeColFromBomWizard()' id='del_col_{{ forloop.counter0 }}' style='display: inline; float: right;' title='Remove column'>
|
||||
<span col_id='{{ forloop.counter0 }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</div>
|
||||
</th>
|
||||
@ -69,8 +66,8 @@
|
||||
{% for row in bom_rows %}
|
||||
<tr>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
|
||||
<span row_id='{{ forloop.counter }}' onClick='removeRowFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
|
||||
<span row_id='{{ forloop.counter }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</td>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
|
@ -47,8 +47,8 @@
|
||||
{% for row in bom_rows %}
|
||||
<tr {% if row.errors %} style='background: #ffeaea;'{% endif %} part-name='{{ row.part_name }}' part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
|
||||
<span row_id='{{ forloop.counter }}' onClick='removeRowFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
|
||||
<span row_id='{{ forloop.counter }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
@ -57,8 +57,8 @@
|
||||
{% for item in row.data %}
|
||||
<td>
|
||||
{% if item.column.guess == 'Part' %}
|
||||
<button class='btn btn-default btn-create' id='new_part_row_{{ row.index }}' title='Create new part' type='button'>
|
||||
<span row_id='{{ row.index }}' class='glyphicon glyphicon-small glyphicon-plus' onClick='newPartFromBomWizard()'/>
|
||||
<button class='btn btn-default btn-create' onClick='newPartFromBomWizard()' id='new_part_row_{{ row.index }}' title='Create new part' type='button'>
|
||||
<span row_id='{{ row.index }}' class='glyphicon glyphicon-small glyphicon-plus'/>
|
||||
</button>
|
||||
|
||||
<select class='select bomselect' id='select_part_{{ row.index }}' name='part_{{ row.index }}'>
|
||||
|
@ -46,8 +46,8 @@
|
||||
{{ part.category.pathstring }}
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-default btn-remove' title='Remove part' type='button'>
|
||||
<span row='part_row_{{ part.id }}' onClick='removeRowFromModalForm()' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
<button class='btn btn-default btn-remove' onClick='removeRowFromModalForm()' title='Remove part' type='button'>
|
||||
<span row='part_row_{{ part.id }}' class='glyphicon glyphicon-small glyphicon-remove'></span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -671,13 +671,8 @@ class BomUpload(FormView):
|
||||
|
||||
def get_form_class(self):
|
||||
|
||||
form_step = self.request.POST.get('form_step', None)
|
||||
|
||||
if form_step == 'select_fields':
|
||||
return part_forms.BomUploadSelectFields
|
||||
else:
|
||||
# Default form is the starting point
|
||||
return part_forms.BomUploadSelectFile
|
||||
# Default form is the starting point
|
||||
return part_forms.BomUploadSelectFile
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
|
||||
@ -776,7 +771,7 @@ class BomUpload(FormView):
|
||||
|
||||
if bom_file_valid:
|
||||
# BOM file is valid? Proceed to the next step!
|
||||
form = part_forms.BomUploadSelectFields
|
||||
form = None
|
||||
self.template_name = 'part/bom_upload/select_fields.html'
|
||||
|
||||
self.extractDataFromFile(manager)
|
||||
@ -983,18 +978,15 @@ class BomUpload(FormView):
|
||||
self.getTableDataFromPost()
|
||||
|
||||
valid = len(self.missing_columns) == 0 and not self.duplicates
|
||||
|
||||
form = part_forms.BomUploadSelectFields
|
||||
|
||||
if valid:
|
||||
# Try to extract meaningful data
|
||||
self.preFillSelections()
|
||||
form = None
|
||||
self.template_name = 'part/bom_upload/select_parts.html'
|
||||
else:
|
||||
self.template_name = 'part/bom_upload/select_fields.html'
|
||||
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
return self.render_to_response(self.get_context_data(form=None))
|
||||
|
||||
def handlePartSelection(self):
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
<br><span class='help-inline'>{{ item.error }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><button class='btn btn-default btn-remove' id='del-{{ item.id }}' title='Remove item' type='button'><span row='stock-row-{{ item.id }}' onclick='removeStockRow()' class='glyphicon glyphicon-small glyphicon-remove'></span></button></td>
|
||||
<td><button class='btn btn-default btn-remove' onclick='removeStockRow()' id='del-{{ item.id }}' title='Remove item' type='button'><span row='stock-row-{{ item.id }}' class='glyphicon glyphicon-small glyphicon-remove'></span></button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user