use mapping_table on user-profile page

This commit is contained in:
Leo Hemsted
2017-11-14 16:54:53 +00:00
parent 1559c074d1
commit 6df775fb11

View File

@@ -1,5 +1,6 @@
{% extends "withoutnav_template.html" %} {% extends "withoutnav_template.html" %}
{% from "components/table.html" import list_table, row, field %} {% from "components/table.html" import list_table, row, field %}
{% from "components/table.html" import mapping_table, row, text_field, optional_text_field, edit_field, field, boolean_field %}
{% block per_page_title %} {% block per_page_title %}
Your profile Your profile
@@ -9,33 +10,40 @@
<h1 class="heading-large">Your profile</h1> <h1 class="heading-large">Your profile</h1>
{% call(item, row_number) list_table( {% call mapping_table(
[ caption='Your profile',
{'label': 'Name', 'value': current_user.name, 'url': url_for('.user_profile_name')}, field_headings=['Label', 'Value', 'Action'],
{'label': 'Email address', 'value': current_user.email_address, 'url': url_for('.user_profile_email')},
{'label': 'Mobile number', 'value': current_user.mobile_number, 'url': url_for('.user_profile_mobile_number')},
{'label': 'Password', 'value': 'Last changed ' + current_user.password_changed_at|format_delta, 'url': url_for('.user_profile_password')},
],
caption='Account settings',
field_headings=['Setting', 'Value', 'Link to change'],
field_headings_visible=False, field_headings_visible=False,
caption_visible=False caption_visible=False
) %} ) %}
{% call field() %} {% call row() %}
{{ item.label }} {{ text_field('Name') }}
{{ text_field(current_user.name) }}
{{ edit_field('Change', url_for('.user_profile_name')) }}
{% endcall %} {% endcall %}
{% call field() %}
{{ item.value }} {% call row() %}
{% endcall %} {{ text_field('Email address') }}
{% call field(align='right') %} {{ text_field(current_user.email_address) }}
{% if item.label == 'Email address' %} {% if can_see_edit %}
{% if can_see_edit %} {{ edit_field('Change', url_for('.user_profile_email')) }}
<a href="{{ item.url }}">Change</a>
{% endif %}
{% else %} {% else %}
<a href="{{ item.url }}">Change</a> {{ text_field('') }}
{% endif %} {% endif %}
{% endcall %} {% endcall %}
{% call row() %}
{{ text_field('Mobile number') }}
{{ optional_text_field(current_user.mobile_number) }}
{{ edit_field('Change', url_for('.user_profile_mobile_number')) }}
{% endcall %}
{% call row() %}
{{ text_field('Password') }}
{{ text_field('Last changed ' + current_user.password_changed_at|format_delta) }}
{{ edit_field('Change', url_for('.user_profile_password')) }}
{% endcall %}
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}