mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Transform the bill addition form, using a popup. See #53
This commit is contained in:
parent
8570e79170
commit
f75bf39307
2 changed files with 17 additions and 32 deletions
|
@ -72,10 +72,10 @@
|
|||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro add_bill(form, edit=False) %}
|
||||
{% macro add_bill(form, edit=False, title=True) %}
|
||||
|
||||
<fieldset>
|
||||
<legend>{% if edit %}{{ _("Edit this bill") }} {% else %}{{ _("Add a bill") }} {% endif %}</legend>
|
||||
{% if title %}<legend>{% if edit %}{{ _("Edit this bill") }} {% else %}{{ _("Add a bill") }} {% endif %}</legend>{% endif %}
|
||||
{% include "display_errors.html" %}
|
||||
{{ form.hidden_tag() }}
|
||||
{{ input(form.date, class="datepicker") }}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% block title %}- {{ g.project.name }}{% endblock %}
|
||||
{% block head %}
|
||||
<script src="{{ url_for("static", filename="js/jquery-ui.js") }}"></script>
|
||||
<script src="{{ url_for("static", filename="js/bootstrap-modal.js") }}"></script>
|
||||
{% if g.lang != "en" %}
|
||||
<script src="{{ url_for("static", filename="js/i18n/jquery.ui.datepicker-%s.js" % g.lang ) }}"></script>
|
||||
{% endif %}
|
||||
|
@ -17,26 +18,9 @@
|
|||
$("#table_overflow").height( $("#sidebar").height()-120 );
|
||||
});
|
||||
|
||||
// display the form when clicking on the "add bill" button
|
||||
var show_form = function(){
|
||||
$('#bill-form').slideDown(100);
|
||||
$("#hide-bill-form").show();
|
||||
$("#new-bill").hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
// and provide a mechanism to hide it back
|
||||
var hide_form = function(){
|
||||
$("#bill-form").slideUp(100);
|
||||
$("#new-bill").show();
|
||||
$("#hide-bill-form").hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#new-bill').click(show_form);
|
||||
$('#empty-new-bill').click(show_form);
|
||||
$('#hide-bill-form').click(hide_form);
|
||||
$('#cancel-form').click(hide_form);
|
||||
$('#cancel-form').click(function(){
|
||||
$('#bill-form').modal('hide');
|
||||
});
|
||||
|
||||
// ask for confirmation before removing an user
|
||||
$('.action').each(function(){
|
||||
|
@ -111,12 +95,17 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="identifier">{{ _("The project identifier is") }} <a href="{{ url_for(".list_bills") }}">{{ g.project.id }}</a>, {{ _("remember it!") }}</div>
|
||||
<a id="new-bill" href="{{ url_for(".add_bill") }}" class="btn primary">{{ _("Add a new bill") }}</a>
|
||||
<a id="new-bill" href="{{ url_for(".add_bill") }}" class="btn primary" data-controls-modal="bill-form" data-backdrop="true" data-keyboard="true">{{ _("Add a new bill") }}</a>
|
||||
|
||||
<form id="bill-form" action="{{ url_for(".add_bill") }}" method="post" style="display: none">
|
||||
<a class="btn primary" id="hide-bill-form" href="#">{{ _("hide this form") }}</a>
|
||||
{{ forms.add_bill(bill_form) }}
|
||||
<div id="bill-form" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<a href="#" class="close">×</a>
|
||||
<h3>{{ _('Add a bill') }}</h3>
|
||||
</div>
|
||||
<form action="{{ url_for(".add_bill") }}" method="post" >
|
||||
{{ forms.add_bill(bill_form, title=False) }}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if bills.count() > 0 %}
|
||||
<table id="bill_table" class="list_bills common-table zebra-striped">
|
||||
|
@ -130,12 +119,8 @@
|
|||
<td>{{ bill.owers|join(', ', 'name') }} </td>
|
||||
<td>{{ "%0.2f"|format(bill.amount) }} ({{ "%0.2f"|format(bill.pay_each()) }} {{ _("each") }})</td>
|
||||
<td class="bill-actions">
|
||||
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">
|
||||
<img src="{{ url_for("static", filename="edit.png") }}" />
|
||||
</a>
|
||||
<a class="delete" href="{{ url_for(".delete_bill", bill_id=bill.id) }}" title="{{ _("delete") }}">
|
||||
<img src="{{ url_for("static", filename="delete.png") }}" />
|
||||
</a>
|
||||
<a class="edit" href="{{ url_for(".edit_bill", bill_id=bill.id) }}" title="{{ _("edit") }}">{{ _('edit') }}</a>
|
||||
<a class="delete" href="{{ url_for(".delete_bill", bill_id=bill.id) }}" title="{{ _("delete") }}">{{ _('delete') }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue