mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-04 01:09:33 +00:00
Added the possibility to edit/create/delete part lots.
This commit is contained in:
parent
6a0adae8f3
commit
813e7dc85b
11 changed files with 226 additions and 43 deletions
60
templates/Parts/edit/_lots.html.twig
Normal file
60
templates/Parts/edit/_lots.html.twig
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{% set delete_btn %}
|
||||
<button type="button" class="btn btn-danger lot_btn_delete" onclick="delete_lot_entry(this);">
|
||||
<i class="fas fa-trash-alt fa-fw"></i>
|
||||
{% trans %}part_lot.delete{% endtrans %}
|
||||
</button>
|
||||
{% endset %}
|
||||
|
||||
|
||||
<table class="table table-striped" id="lots_table" data-prototype="{{ form_widget(form.partLots.vars.prototype)|e('html_attr') }}">
|
||||
<tbody>
|
||||
{% for lot in form.partLots %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ form_widget(lot) }}
|
||||
</td>
|
||||
<td>
|
||||
{{ delete_btn }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<button type="button" class="btn btn-success" onclick="create_lot_entry(this)">
|
||||
<i class="fas fa-plus-square fa-fw"></i>
|
||||
{% trans %}part_lot.create{% endtrans %}
|
||||
</button>
|
||||
|
||||
<script>
|
||||
function delete_lot_entry(btn) {
|
||||
window.bootbox.confirm('{% trans %}part_lot.edit.delete.confirm{% endtrans %}', function (result) {
|
||||
if(result) {
|
||||
$(btn).parents("tr").remove();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function create_lot_entry(btn) {
|
||||
//Determine the table, so we can determine, how many entries there are already.
|
||||
$holder = $("#lots_table");
|
||||
|
||||
var index = $holder.find(":input").length;
|
||||
var newForm = $holder.data("prototype");
|
||||
|
||||
//Increase the index
|
||||
newForm = newForm.replace(/__name__/g, index);
|
||||
newForm = '<td>' + newForm + '</td>';
|
||||
$newFormRow = $('<tr></tr>').html(newForm);
|
||||
|
||||
//Add delete button
|
||||
$btn = '<td>' + '{{ delete_btn|e('js') }}' + '</td>';
|
||||
$newFormRow.append($btn);
|
||||
|
||||
$holder.append($newFormRow);
|
||||
|
||||
//Reinit the selectpickers
|
||||
$(".selectpicker").selectpicker();
|
||||
|
||||
}
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue