Add ability to remove individual rows from BOM uploader

This commit is contained in:
Oliver Walters 2019-07-02 19:45:26 +10:00
parent fc5682f565
commit c959e8f62c
2 changed files with 39 additions and 2 deletions

View File

@ -32,13 +32,14 @@
<table class='table table-striped'>
<thead>
<tr>
<th></th>
<th>Row</th>
{% for col in bom_columns %}
<th>
<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 }}' title='Remove column'>
<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>
</div>
@ -65,7 +66,12 @@
</tr>
{% for row in bom_rows %}
<tr>
<td>{% add forloop.counter 1 %}</td>
<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>
</td>
<td>{{ forloop.counter }}</td>
{% for item in row.data %}
<td>
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item }}'/>

View File

@ -12,6 +12,37 @@ function reloadBomTable(table, options) {
}
function removeRowFromBomWizard(e) {
/* Remove a row from BOM upload wizard
*/
e = e || window.event;
var src = e.target || e.srcElement;
var table = $(src).closest('table');
// Which column was clicked?
var row = $(src).closest('tr');
row.remove();
var rowNum = 1;
var colNum = 0;
table.find('tr').each(function() {
colNum++;
if (colNum >= 3) {
var cell = $(this).find('td:eq(1)');
cell.text(rowNum++);
console.log("Row: " + rowNum);
}
});
}
function removeColFromBomWizard(e) {
/* Remove a column from BOM upload wizard
*/