From 7d60bee0ef5a38e6765b9bb51ae7e200157591a0 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Sun, 21 Aug 2011 01:42:10 +0200 Subject: Re-design (Fixes #19) --- budget/templates/add_bill.html | 10 ++-- budget/templates/authenticate.html | 6 +-- budget/templates/edit_bill.html | 2 +- budget/templates/forms.html | 52 +++++++++++++------- budget/templates/layout.html | 82 +++++++++++++++++++++++--------- budget/templates/list_bills.html | 97 ++++++++++++++++++++------------------ 6 files changed, 152 insertions(+), 97 deletions(-) (limited to 'budget/templates') diff --git a/budget/templates/add_bill.html b/budget/templates/add_bill.html index 5b3a768..ec60f43 100644 --- a/budget/templates/add_bill.html +++ b/budget/templates/add_bill.html @@ -5,11 +5,9 @@ {% endblock %} {% block content %} -

Add a new bill

+

{% if edit %}Edit a{% else %}Add a new{% endif %} bill

-
-
- {{ forms.add_bill(form) }} -
-
+
+ {{ forms.add_bill(form) }} +
{% endblock %} diff --git a/budget/templates/authenticate.html b/budget/templates/authenticate.html index d4f7df6..0ad8815 100644 --- a/budget/templates/authenticate.html +++ b/budget/templates/authenticate.html @@ -12,10 +12,6 @@ to create i

{% endif %}
- {{ form.hidden_tag() }} - -

{{ form.id.label }}
{{ form.id }}

-

{{ form.password.label }}
{{ form.password }}

-

{{ form.submit }}

+ {{ forms.authenticate(form) }}
{% endblock %} diff --git a/budget/templates/edit_bill.html b/budget/templates/edit_bill.html index 03a1a26..f069193 100644 --- a/budget/templates/edit_bill.html +++ b/budget/templates/edit_bill.html @@ -8,7 +8,7 @@

Edit a bill

-
+ {{ forms.add_bill(form) }}
diff --git a/budget/templates/forms.html b/budget/templates/forms.html index 62ad4b8..4e62f58 100644 --- a/budget/templates/forms.html +++ b/budget/templates/forms.html @@ -1,17 +1,29 @@ {% macro input(field, multiple=False) -%} -
+
+ {% if field.type != "SubmitField" %} {{ field.label }} {% endif %} - {% if multiple == True %} - {{ field(multiple=True) }} - {% else %} - {{ field }} - {% endif %} - {% if field.description %} -

{{ field.description }}

+
+ {% if multiple == True %} + {{ field(multiple=True) }} + {% else %} + {{ field }} + {% endif %} + {% if field.description %} + {{ field.description }} + {% endif %} +
+
+{% endmacro %} + +{% macro submit(field, cancel=False) -%} +
+ + {% if cancel %} + {% endif %} -
+
{% endmacro %} {% macro authenticate(form) %} @@ -20,7 +32,7 @@ {{ form.hidden_tag() }} {{ input(form.id) }} {{ input(form.password) }} - {{ input(form.submit) }} + {{ submit(form.submit) }} {% endmacro %} @@ -32,12 +44,14 @@ {{ input(form.id) }} {{ input(form.password) }} {{ input(form.contact_email) }} - {{ input(form.submit) }} + {{ submit(form.submit) }} {% endmacro %} {% macro add_bill(form) %} +
+ Add a bill {% include "display_errors.html" %} {{ form.hidden_tag() }} {{ input(form.date) }} @@ -45,15 +59,21 @@ {{ input(form.payer) }} {{ input(form.amount) }} {{ input(form.payed_for) }} - {{ input(form.submit) }} +
+ {{ submit(form.submit, cancel=True) }} {% endmacro %} {% macro add_member(form) %} - - {% include "display_errors.html" %} {{ form.hidden_tag() }} - {{ input(form.name) }} - {{ input(form.submit) }} + {{ form.name }} + {% endmacro %} + +{% macro authenticate(form) %} + {{ form.hidden_tag() }} + {{ input(form.id) }} + {{ input(form.password) }} + {{ submit(form.submit) }} +{% endmacro %} diff --git a/budget/templates/layout.html b/budget/templates/layout.html index 3ab6f1f..988ee58 100644 --- a/budget/templates/layout.html +++ b/budget/templates/layout.html @@ -2,36 +2,74 @@ -Account manager - - - + + {% block js %}{% endblock %} + }); + -
- -
- {% block top_menu %}{% endblock %} -
-
+
+

+ {% if g.project %} + + + {% endif %} +
+
+ +
{% for message in get_flashed_messages() %} -
{{ message }}
+

{{ message }}

{% endfor %} {% block content %} {% endblock %} - +
+ diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 94b0f8f..d73a95f 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -1,68 +1,71 @@ {% extends "layout.html" %} {% block js %} -// display the form when clicking on the "add bill" button -$('#add_bill_button').click(function(){ - $('#add_bill').show(200); - $(this).hide(); - $('#hide_bill_form').show(); - return false; -}); + // display the form when clicking on the "add bill" button + var show_form = function(){ + $('#bill-form').show(70); + $("#new-bill").hide(); + return false; + } + + // and provide a mechanism to hide it back + var hide_form = function(){ + $("#bill-form").hide(70); + $("#new-bill").show(); + return false; + } -// and provide a mechanism to hide it back -$('#hide_bill_form').click(function(){ - $('#add_bill').hide(200); - $(this).hide(); - $('#add_bill_button').show(); - return false; -}); + $('#new-bill').click(show_form); + $('#empty-new-bill').click(show_form); + $('#hide-bill-form').click(hide_form); + $('#cancel-form').click(hide_form); -// ask for confirmation before removing an user -$('a.remove').each(function(){ - $(this).hide(); - $(this).click(function(){ - return confirm("are you sure?"); + // ask for confirmation before removing an user + $('a.remove').each(function(){ + $(this).hide(); + $(this).click(function(){ + return confirm("are you sure?"); + }); }); -}); -// display the remove button on mouse over (and hide them per default) -$('.members li').hover(function(){ - $(this).children('a.remove').show(); -}, function(){ - $(this).children('a.remove').hide(); -}); + // display the remove button on mouse over (and hide them per default) + $('.balance tr').hover(function(){ + $(this).find('.remove').show(); + }, function(){ + $(this).find('.remove').hide(); + }); {% endblock %} -{% block top_menu %} - -{% endblock %} +{% block sidebar %} +

Balance

-{% block content %} -
-
    + {% set balance = g.project.get_balance() %} {% for member in g.project.active_members %} -
  • - {{ balance[member] }} - {{ member.name }} - delete
  • + + + + + {% endfor %} - +
    {{ member.name }} + {% if balance[member] > 0 %}+{% endif %}{{ balance[member] }} + delete
    +
    {{ forms.add_member(member_form) }}
    -
-
- Add a bill - - +{% endblock %} - +{% block content %} + Add a new bill + {% if bills.count() > 0 %} - +
{% for bill in bills %} @@ -80,7 +83,7 @@ $('.members li').hover(function(){
When?Who paid?For what?OwersHow much?Actions
{% else %} -

Nothing to list yet. You probably want to add a bill ?

+

Nothing to list yet. You probably want to add a bill ?

{% endif %}
{% endblock %} -- cgit v1.1