mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
Make editing a bill into a modal
This commit is contained in:
parent
04c375e2e7
commit
37b099ab79
2 changed files with 31 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
{% block title %} - {{ g.project.name }}{% endblock %}
|
||||
{% block js %}
|
||||
{% if add_bill %} $('#new-bill > a').click(); {% endif %}
|
||||
{% if edit_bill is not none %} $('#edit-bill > a').click(); {% endif %}
|
||||
|
||||
// ask for confirmation before removing an user
|
||||
$('.action.delete').each(function(){
|
||||
|
@ -86,6 +87,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if edit_bill is not none %}
|
||||
<div id="bill-edit-form" class="modal fade show" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">{{ _('Edit this bill') }}</h3>
|
||||
<a href="#" class="close" data-dismiss="modal">×</a>
|
||||
</div>
|
||||
<form action="{{ url_for(".edit_bill", bill_id=edit_bill) }}" method="post" class="modal-body container">
|
||||
{{ forms.add_bill(bill_edit_form, edit=True, title=False) }}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span id="edit-bill" class="hidden">
|
||||
<a href="#" data-toggle="modal" data-keyboard="false" data-target="#bill-edit-form"></a>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex flex-wrap w-100 pt-2 mt-2" id="bill-toolbar">
|
||||
{% if bills.pages > 1 %}
|
||||
<ul class="pagination mr-2 mb-0 pb-2 flex-wrap" id="pagination-top">
|
||||
|
@ -143,7 +163,7 @@
|
|||
</span>
|
||||
</td>
|
||||
<td class="bill-actions d-flex align-items-center">
|
||||
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a>
|
||||
<a class="edit" href="{{ url_for(".list_bills", edit_bill=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a>
|
||||
<form class="delete-bill" action="{{ url_for(".delete_bill", bill_id=bill.id) }}" method="POST">
|
||||
{{ csrf_form.csrf_token }}
|
||||
<button class="action delete" type="submit" title="{{ _("delete") }}"></button>
|
||||
|
|
|
@ -649,6 +649,14 @@ def list_bills():
|
|||
if "last_selected_payer" in session:
|
||||
bill_form.payer.data = session["last_selected_payer"]
|
||||
|
||||
edit_bill = request.values.get("edit_bill", type=int)
|
||||
bill_edit_form = get_billform_for(g.project)
|
||||
if edit_bill is not None:
|
||||
bill = Bill.query.get(g.project, edit_bill)
|
||||
if not bill:
|
||||
raise NotFound()
|
||||
bill_edit_form.fill(bill, g.project)
|
||||
|
||||
# Each item will be a (weight_sum, Bill) tuple.
|
||||
# TODO: improve this awkward result using column_property:
|
||||
# https://docs.sqlalchemy.org/en/14/orm/mapped_sql_expr.html.
|
||||
|
@ -661,6 +669,8 @@ def list_bills():
|
|||
bills=weighted_bills,
|
||||
member_form=MemberForm(g.project),
|
||||
bill_form=bill_form,
|
||||
edit_bill=edit_bill,
|
||||
bill_edit_form=bill_edit_form,
|
||||
csrf_form=csrf_form,
|
||||
add_bill=request.values.get("add_bill", False),
|
||||
current_view="list_bills",
|
||||
|
|
Loading…
Reference in a new issue