Added a very basic modal on part info page for changing part instock

Related to issue #201
This commit is contained in:
Jan Böhmer 2023-01-01 13:21:50 +01:00
parent 0e020dab74
commit ba4085d882
7 changed files with 488 additions and 4 deletions

View file

@ -1,6 +1,8 @@
{% import "helper.twig" as helper %}
{% import "LabelSystem/dropdown_macro.html.twig" as dropdown %}
{% include "Parts/info/_withdraw_modal.html.twig" %}
<table class="table table-striped table-hover table-responsive-sm">
<thead>
<tr>
@ -8,6 +10,7 @@
<th>{% trans %}part_lots.storage_location{% endtrans %}</th>
<th>{% trans %}part_lots.amount{% endtrans %}</th>
<th></th> {# Tags row #}
<th></th>
<th></th> {# Button row #}
</tr>
</thead>
@ -57,6 +60,26 @@
{% endif %}
</h6>
</td>
<td>
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#withdraw-modal"
data-action="add" data-lot-id="{{ lot.id }}" data-lot-amount="{{ lot.amount }}"
{% if lot.storageLocation and lot.storageLocation.full %}disabled{% endif %}
>
<i class="fa-solid fa-plus fa-fw"></i>
</button>
<button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#withdraw-modal"
data-action="remove" data-lot-id="{{ lot.id }}" data-lot-amount="{{ lot.amount }}"
>
<i class="fa-solid fa-minus fa-fw"></i>
</button>
<button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#withdraw-modal"
data-action="move" data-lot-id="{{ lot.id }}" data-lot-amount="{{ lot.amount }}"
>
<i class="fa-solid fa-right-left fa-fw"></i>
</button>
</div>
</td>
<td>
{{ dropdown.profile_dropdown('part_lot', lot.id, false) }}
</td>

View file

@ -0,0 +1,56 @@
<div class="modal fade" id="withdraw-modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" {{ stimulus_controller('pages/part_withdraw_modal') }}>
<form method="post" action="{{ path('part_add_withdraw', {"id": part.id}) }}">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{# non visible form elements #}
<input type="hidden" name="lot_id" value="">
<input type="hidden" name="action" value="">
<input type="hidden" name="_csfr" value="{{ csrf_token('part_withraw' ~ part.iD) }}">
<input type="hidden" name="_redirect" value="{{ app.request.requestUri }}">
<div class="row mb-2">
<label class="col-form-label col-sm-3">
Amount
</label>
<div class="col-sm-9">
<input type="number" required class="form-control" min="0" step="{{ (part.partUnit and not part.partUnit.integer) ? 'any' : '1' }}" name="amount" value="">
</div>
</div>
<div class="row mb-2">
<label class="col-form-label col-sm-3">Move to</label>
<div class="col-sm-9">
{% for lots in part.partLots|filter(l => l.instockUnknown == false) %}
<div class="form-check">
<input class="form-check-input" type="radio" name="target_id" value="{{ lots.iD }}" id="modal_target_radio_{{ lots.iD }}" {% if lots.storageLocation and lots.storageLocation.full %}disabled{% endif %} required>
<label class="form-check-label" for="modal_target_radio_{{ lots.iD }}">
{{ (lots.storageLocation) ? lots.storageLocation.fullPath : ("Lot " ~ loop.index) }}{% if lots.name is not empty %} ({{ lots.name }}){% endif %}: <b>{{ lots.amount | format_amount(part.partUnit) }}</b>
</label>
</div>
{% endfor %}
</div>
</div>
<div class="row mb-2">
<label class="col-form-label col-sm-3">
Comment
</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="comment" value="">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</form>
</div>