diff options
| -rw-r--r-- | ihatemoney/templates/history.html | 18 | ||||
| -rw-r--r-- | ihatemoney/templates/list_bills.html | 26 | ||||
| -rw-r--r-- | ihatemoney/templates/settle_bills.html | 12 | ||||
| -rw-r--r-- | ihatemoney/templates/sidebar_table_layout.html | 44 | ||||
| -rw-r--r-- | ihatemoney/templates/statistics.html | 17 |
5 files changed, 48 insertions, 69 deletions
diff --git a/ihatemoney/templates/history.html b/ihatemoney/templates/history.html index 9cf66a7..d9f2b4d 100644 --- a/ihatemoney/templates/history.html +++ b/ihatemoney/templates/history.html @@ -98,23 +98,7 @@ {% block sidebar %} <div id="table_overflow"> - <table class="balance table"> - <thead> - <tr class="d-none d-md-table-row"> - <th>{{ _("Who?") }}</th> - <th class="balance-value">{{ _("Balance") }}</th> - </tr> - </thead> - {% set balance = g.project.balance %} - {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %} - <tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}> - <td class="balance-name">{{ member.name }}</td> - <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}"> - {% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }} - </td> - </tr> - {% endfor %} - </table> + {{ balance_table(show_weight=False, show_header=True) }} </div> {% endblock %} diff --git a/ihatemoney/templates/list_bills.html b/ihatemoney/templates/list_bills.html index 7ae3bd6..1f4235b 100644 --- a/ihatemoney/templates/list_bills.html +++ b/ihatemoney/templates/list_bills.html @@ -45,31 +45,7 @@ </form> <div id="table_overflow"> - <table class="balance table"> - {% set balance = g.project.balance %} - {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %} - <tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}> - <td class="balance-name">{{ member.name }} - <span class="light{% if not g.project.uses_weights %} extra-info{% endif %}">(x{{ member.weight|minimal_round(1) }})</span> - </td> - {% if member.activated %} - <td> - <form class="action delete" action="{{ url_for(".remove_member", member_id=member.id) }}" method="POST"> - <button type="submit">{{ _("deactivate") }}</button></form> - <form class="action edit" action="{{ url_for(".edit_member", member_id=member.id) }}" method="GET"> - <button type="submit">{{ _("edit") }}</button></form> - </td> - {% else %} - <td> - <form class="action reactivate" action="{{ url_for(".reactivate", member_id=member.id) }}" method="POST"> - <button type="submit">{{ _("reactivate") }}</button></form></td> - {% endif %} - <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}"> - {% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }} - </td> - </tr> - {% endfor %} - </table> + {{ balance_table(member_edit=True) }} </div> </div> <div class="identifier"> diff --git a/ihatemoney/templates/settle_bills.html b/ihatemoney/templates/settle_bills.html index 30f64d0..a9b0dbc 100644 --- a/ihatemoney/templates/settle_bills.html +++ b/ihatemoney/templates/settle_bills.html @@ -2,17 +2,7 @@ {% block sidebar %} <div id="table_overflow"> - <table class="balance table"> - {% set balance = g.project.balance %} - {% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %} - <tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}> - <td class="balance-name">{{ member.name }}</td> - <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}"> - {% if balance[member.id]|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }} - </td> - </tr> - {% endfor %} - </table> + {{ balance_table(show_weight=False) }} </div> {% endblock %} diff --git a/ihatemoney/templates/sidebar_table_layout.html b/ihatemoney/templates/sidebar_table_layout.html index 9d588a3..d616e68 100644 --- a/ihatemoney/templates/sidebar_table_layout.html +++ b/ihatemoney/templates/sidebar_table_layout.html @@ -1,5 +1,49 @@ {% extends "layout.html" %} +{% macro balance_table(show_weight = True, show_header = False, member_edit = False) %} + <table class="balance table"> + {%- set balance = g.project.balance %} + {%- if show_header %} + <thead> + <tr class="d-none d-md-table-row"> + <th>{{ _("Who?") }}</th> + <th class="balance-value">{{ _("Balance") }}</th> + </tr> + </thead> + {%- endif %} + {%- for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id]|round(2) != 0 %} + <tr id="bal-member-{{ member.id }}" action="{% if member.activated %}delete{% else %}reactivate{% endif %}"> + <td class="balance-name">{{ member.name }} + {%- if show_weight -%} + <span class="light{% if not g.project.uses_weights %} extra-info{% endif %}">(x{{ member.weight|minimal_round(1) }})</span> + {%- endif -%} + </td> + {%- if member_edit %} + {%- if member.activated %} + <td> + <form class="action delete" action="{{ url_for(".remove_member", member_id=member.id) }}" method="POST"> + <button type="submit">{{ _("deactivate") }}</button> + </form> + <form class="action edit" action="{{ url_for(".edit_member", member_id=member.id) }}" method="GET"> + <button type="submit">{{ _("edit") }}</button> + </form> + </td> + {%- else %} + <td> + <form class="action reactivate" action="{{ url_for(".reactivate", member_id=member.id) }}" method="POST"> + <button type="submit">{{ _("reactivate") }}</button> + </form> + </td> + {%- endif %} + {%- endif %} + <td class="balance-value {% if balance[member.id]|round(2) > 0 %}positive{% elif balance[member.id]|round(2) < 0 %}negative{% endif %}"> + {% if balance[member.id] | round(2) > 0 %}+{% endif %}{{ balance[member.id]|currencyformat_nc(g.project.default_currency) }} + </td> + </tr> + {%- endfor %} + </table> +{% endmacro %} + {% block body %} <div class="row"> <aside id="sidebar" class="sidebar col-xs-12 col-md-3 " style="height: 100%"> diff --git a/ihatemoney/templates/statistics.html b/ihatemoney/templates/statistics.html index af3d9d5..3b0a9dd 100644 --- a/ihatemoney/templates/statistics.html +++ b/ihatemoney/templates/statistics.html @@ -2,22 +2,7 @@ {% block sidebar %} <div id="table_overflow" class="statistics mr-md-n3"> - <table class="balance table"> - <thead> - <tr class="d-none d-md-table-row"> - <th>{{ _("Who?") }}</th> - <th class="balance-value">{{ _("Balance") }}</th> - </tr> - </thead> - {% for stat in members_stats|sort(attribute='member.name') %} - <tr> - <td class="balance-name">{{ stat.member.name }}</td> - <td class="balance-value {% if stat.balance|round(2) > 0 %}positive{% elif stat.balance|round(2) < 0 %}negative{% endif %}"> - {% if stat.balance|round(2) > 0 %}+{% endif %}{{ "%.2f" | format(stat.balance) }} - </td> - </tr> - {% endfor %} - </table> + {{ balance_table(show_weight=False, show_header=True) }} </div> {% endblock %} |
