Change macro names

This commit is contained in:
Patrick Jentsch 2020-04-17 11:13:11 +02:00
parent 1f0a87a474
commit b9ebb64fcc
17 changed files with 75 additions and 82 deletions

View File

@ -12,13 +12,13 @@
<form method="POST">
<div class="card-content">
{{ edit_user_form.hidden_tag() }}
{{ materialize.field(edit_user_form.username, data_length='64', material_icon='account_circle') }}
{{ materialize.field(edit_user_form.email, class_='validate', material_icon='email', type='email') }}
{{ materialize.field(edit_user_form.role, material_icon='swap_vert') }}
{{ materialize.field(edit_user_form.confirmed, material_icon='check') }}
{{ M.render_field(edit_user_form.username, data_length='64', material_icon='account_circle') }}
{{ M.render_field(edit_user_form.email, class_='validate', material_icon='email', type='email') }}
{{ M.render_field(edit_user_form.role, material_icon='swap_vert') }}
{{ M.render_field(edit_user_form.confirmed, material_icon='check') }}
</div>
<div class="card-action right-align">
{{ materialize.field(edit_user_form.submit, material_icon='send') }}
{{ M.render_field(edit_user_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -28,19 +28,19 @@
<form method="POST">
<div class="card-content">
{{ login_form.hidden_tag() }}
{{ materialize.field(login_form.user, material_icon='person') }}
{{ materialize.field(login_form.password, material_icon='vpn_key') }}
{{ M.render_field(login_form.user, material_icon='person') }}
{{ M.render_field(login_form.password, material_icon='vpn_key') }}
<div class="row" style="margin-bottom: 0;">
<div class="col s6 left-align">
<a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a>
</div>
<div class="col s6 right-align">
{{ materialize.field(login_form.remember_me) }}
{{ M.render_field(login_form.remember_me) }}
</div>
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(login_form.submit, material_icon='send') }}
{{ M.render_field(login_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -26,13 +26,13 @@
<form method="POST">
<div class="card-content">
{{ registration_form.hidden_tag() }}
{{ materialize.field(registration_form.username, data_length='64', material_icon='person') }}
{{ materialize.field(registration_form.password, data_length='128', material_icon='vpn_key') }}
{{ materialize.field(registration_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
{{ materialize.field(registration_form.email, class_='validate', material_icon='email', type='email') }}
{{ M.render_field(registration_form.username, data_length='64', material_icon='person') }}
{{ M.render_field(registration_form.password, data_length='128', material_icon='vpn_key') }}
{{ M.render_field(registration_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
{{ M.render_field(registration_form.email, class_='validate', material_icon='email', type='email') }}
</div>
<div class="card-action right-align">
{{ materialize.field(registration_form.submit, material_icon='send') }}
{{ M.render_field(registration_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -11,11 +11,11 @@
<form method="POST">
<div class="card-content">
{{ reset_password_form.hidden_tag() }}
{{ materialize.field(reset_password_form.password, data_length='128') }}
{{ materialize.field(reset_password_form.password_confirmation, data_length='128') }}
{{ M.render_field(reset_password_form.password, data_length='128') }}
{{ M.render_field(reset_password_form.password_confirmation, data_length='128') }}
</div>
<div class="card-action right-align">
{{ materialize.field(reset_password_form.submit, material_icon='send') }}
{{ M.render_field(reset_password_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -10,10 +10,10 @@
<form method="POST">
<div class="card-content">
{{ reset_password_request_form.hidden_tag() }}
{{ materialize.field(reset_password_request_form.email, class_='validate', material_icon='email', type='email') }}
{{ M.render_field(reset_password_request_form.email, class_='validate', material_icon='email', type='email') }}
</div>
<div class="card-action right-align">
{{ materialize.field(reset_password_request_form.submit, material_icon='send') }}
{{ M.render_field(reset_password_request_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -13,15 +13,15 @@
{{ add_corpus_form.hidden_tag() }}
<div class="row">
<div class="col s12 m4">
{{ materialize.field(add_corpus_form.title, data_length='32', material_icon='title') }}
{{ M.render_field(add_corpus_form.title, data_length='32', material_icon='title') }}
</div>
<div class="col s12 m8">
{{ materialize.field(add_corpus_form.description, data_length='255', material_icon='description') }}
{{ M.render_field(add_corpus_form.description, data_length='255', material_icon='description') }}
</div>
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(add_corpus_form.submit, material_icon='send') }}
{{ M.render_field(add_corpus_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -15,21 +15,21 @@
{{ add_corpus_file_form.hidden_tag() }}
<div class="row">
<div class="col s12 m4">
{{ materialize.field(add_corpus_file_form.author, data_length='255', material_icon='person') }}
{{ M.render_field(add_corpus_file_form.author, data_length='255', material_icon='person') }}
</div>
<div class="col s12 m4">
{{ materialize.field(add_corpus_file_form.title, data_length='255', material_icon='title') }}
{{ M.render_field(add_corpus_file_form.title, data_length='255', material_icon='title') }}
</div>
<div class="col s12 m4">
{{ materialize.field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
{{ M.render_field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
</div>
<div class="col s12">
{{ materialize.field(add_corpus_file_form.file, accept='.vrt') }}
{{ M.render_field(add_corpus_file_form.file, accept='.vrt') }}
</div>
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(add_corpus_file_form.submit, material_icon='send') }}
{{ M.render_field(add_corpus_file_form.submit, material_icon='send') }}
</div>
</div>
<br>
@ -39,7 +39,7 @@
<div class="collapsible-body">
{% for field in add_corpus_file_form
if field.short_name not in ['author', 'csrf_token', 'file', 'publishing_year', 'submit', 'title'] %}
{{ materialize.field(field, data_length='255', material_icon=field.label.text[0:1]) }}
{{ M.render_field(field, data_length='255', material_icon=field.label.text[0:1]) }}
{% endfor %}
</div>
</li>

View File

@ -34,7 +34,7 @@
</div>
<div class="col s12 m2">
<br class="hide-on-small-only">
{{ materialize.field(query_form.submit, material_icon='send') }}
{{ M.render_field(query_form.submit, material_icon='send') }}
</div>
</div>
</form>
@ -49,13 +49,13 @@
<form id="display-options-form">
<div class="row">
<div class="col s12 m6">
{{ materialize.field(display_options_form.results_per_page, material_icon='format_list_numbered') }}
{{ M.render_field(display_options_form.results_per_page, material_icon='format_list_numbered') }}
</div>
<div class="col s12 m6">
{{ materialize.field(display_options_form.result_context, material_icon='short_text') }}
{{ M.render_field(display_options_form.result_context, material_icon='short_text') }}
</div>
<div class="col s12">
{{ materialize.field(display_options_form.expert_mode) }}
{{ M.render_field(display_options_form.expert_mode) }}
</div>
</div>
</form>

View File

@ -14,18 +14,18 @@
<div class="card-content">
<div class="row">
<div class="col s12 m4">
{{ materialize.field(edit_corpus_file_form.author, data_length='255', material_icon='person') }}
{{ M.render_field(edit_corpus_file_form.author, data_length='255', material_icon='person') }}
</div>
<div class="col s12 m4">
{{ materialize.field(edit_corpus_file_form.title, data_length='255', material_icon='title') }}
{{ M.render_field(edit_corpus_file_form.title, data_length='255', material_icon='title') }}
</div>
<div class="col s12 m4">
{{ materialize.field(edit_corpus_file_form.publishing_year, material_icon='access_time') }}
{{ M.render_field(edit_corpus_file_form.publishing_year, material_icon='access_time') }}
</div>
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(edit_corpus_file_form.submit, material_icon='send') }}
{{ M.render_field(edit_corpus_file_form.submit, material_icon='send') }}
</div>
</div>
<br>
@ -35,7 +35,7 @@
<div class="collapsible-body">
{% for field in edit_corpus_file_form
if field.short_name not in ['author', 'csrf_token', 'publishing_year', 'submit', 'title'] %}
{{ materialize.field(field) }}
{{ M.render_field(field) }}
{% endfor %}
</div>
</li>

View File

@ -1,16 +1,16 @@
{% macro field(field) %}
{% macro render_field(field) %}
{% if field.type == 'BooleanField' %}
{{ boolean_field(field, *args, **kwargs) }}
{{ render_boolean_field(field, *args, **kwargs) }}
{% elif field.type == 'SubmitField' %}
{{ submit_field(field, *args, **kwargs) }}
{{ render_submit_field(field, *args, **kwargs) }}
{% elif field.type in ['FileField', 'MultipleFileField'] %}
{{ file_field(field, *args, **kwargs) }}
{{ render_file_field(field, *args, **kwargs) }}
{% elif field.type in ['IntegerField', 'PasswordField', 'SelectField', 'StringField'] %}
{{ generic_field(field, *args, **kwargs) }}
{{ render_generic_field(field, *args, **kwargs) }}
{% endif %}
{% endmacro %}
{% macro boolean_field(field) %}
{% macro render_boolean_field(field) %}
<div class="switch">
{% if 'material_icon' in kwargs %}
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
@ -26,7 +26,7 @@
</div>
{% endmacro %}
{% macro file_field(field) %}
{% macro render_file_field(field) %}
<div class="file-field input-field">
<div class="btn">
<span>{{ field.label.text }}</span>
@ -38,7 +38,7 @@
</div>
{% endmacro %}
{% macro generic_field(field) %}
{% macro render_generic_field(field) %}
{% if field.type == 'IntegerField' %}
{% set tmp = kwargs.update({'type': 'number'}) %}
{% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %}
@ -59,7 +59,7 @@
</div>
{% endmacro %}
{% macro submit_field(field) %}
{% macro render_submit_field(field) %}
<button class="btn waves-effect waves-light" id="{{ field.id }}" name="{{ field.name }}" type="submit" value="{{ field.label.text }}">
{{ field.label.text }}
{% if 'material_icon' in kwargs %}
@ -67,10 +67,3 @@
{% endif %}
</button>
{% endmacro %}
{% macro submit_button(input) %}
<button class="btn waves-effect waves-light" id="{{ input.id }}" name="{{ input.name }}" type="submit" value="{{ input.label.text }}">
{{ input.label.text }}
<i class="material-icons right">send</i>
</button>
{% endmacro %}

View File

@ -26,7 +26,7 @@
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(feedback_form.submit, material_icon='send') }}
{{ M.render_field(feedback_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -145,19 +145,19 @@
<div class="card-content">
<span class="card-title">Log in</span>
{{ login_form.hidden_tag() }}
{{ materialize.field(login_form.user, material_icon='person') }}
{{ materialize.field(login_form.password, material_icon='vpn_key') }}
{{ M.render_field(login_form.user, material_icon='person') }}
{{ M.render_field(login_form.password, material_icon='vpn_key') }}
<div class="row" style="margin-bottom: 0;">
<div class="col s6 left-align">
<a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a>
</div>
<div class="col s6 right-align">
{{ materialize.field(login_form.remember_me) }}
{{ M.render_field(login_form.remember_me) }}
</div>
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(login_form.submit, material_icon='send') }}
{{ M.render_field(login_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -1,4 +1,4 @@
{% import "materialize.jinja" as materialize %}
{% import "macros/materialize.html.j2" as M %}
<!DOCTYPE html>
<html lang="en">

View File

@ -46,7 +46,7 @@
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(edit_general_settings_form.save_settings, material_icon='send') }}
{{ M.render_field(edit_general_settings_form.save_settings, material_icon='send') }}
</div>
</form>
</div>
@ -65,12 +65,12 @@
<form method="POST">
<div class="card-content">
{{ edit_password_form.hidden_tag() }}
{{ materialize.field(edit_password_form.current_password, data_length='128', material_icon='vpn_key') }}
{{ materialize.field(edit_password_form.password, data_length='128', material_icon='vpn_key') }}
{{ materialize.field(edit_password_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
{{ M.render_field(edit_password_form.current_password, data_length='128', material_icon='vpn_key') }}
{{ M.render_field(edit_password_form.password, data_length='128', material_icon='vpn_key') }}
{{ M.render_field(edit_password_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
</div>
<div class="card-action right-align">
{{ materialize.field(edit_password_form.save_password, material_icon='send') }}
{{ M.render_field(edit_password_form.save_password, material_icon='send') }}
</div>
</form>
</div>
@ -89,10 +89,10 @@
<form method="POST">
<div class="card-content">
{{ edit_email_form.hidden_tag() }}
{{ materialize.field(edit_email_form.email, class_='validate', material_icon='email', type='email') }}
{{ M.render_field(edit_email_form.email, class_='validate', material_icon='email', type='email') }}
</div>
<div class="card-action right-align">
{{ materialize.field(edit_email_form.save_email, material_icon='send') }}
{{ M.render_field(edit_email_form.save_email, material_icon='send') }}
</div>
</form>
</div>

View File

@ -30,16 +30,16 @@
{{ add_job_form.hidden_tag() }}
<div class="row">
<div class="col s12 l4">
{{ materialize.field(add_job_form.title, data_length='32', material_icon='title') }}
{{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
</div>
<div class="col s12 l8">
{{ materialize.field(add_job_form.description, data_length='255', material_icon='description') }}
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12">
{{ materialize.field(add_job_form.files, accept='image/jpeg, image/png, image/tiff') }}
{{ M.render_field(add_job_form.files, accept='image/jpeg, image/png, image/tiff') }}
</div>
<div class="col s12 hide">
{{ materialize.field(add_job_form.version, material_icon='apps') }}
{{ M.render_field(add_job_form.version, material_icon='apps') }}
</div>
</div>
</div>

View File

@ -48,19 +48,19 @@
{{ add_job_form.hidden_tag() }}
<div class="row">
<div class="col s12 l4">
{{ materialize.field(add_job_form.title, data_length='32', material_icon='title') }}
{{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
</div>
<div class="col s12 l8">
{{ materialize.field(add_job_form.description, data_length='255', material_icon='description') }}
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12 l5">
{{ materialize.field(add_job_form.files, accept='text/plain') }}
{{ M.render_field(add_job_form.files, accept='text/plain') }}
</div>
<div class="col s12 l4">
{{ materialize.field(add_job_form.language, material_icon='language') }}
{{ M.render_field(add_job_form.language, material_icon='language') }}
</div>
<div class="col s12 l3">
{{ materialize.field(add_job_form.version, material_icon='apps') }}
{{ M.render_field(add_job_form.version, material_icon='apps') }}
</div>
<div class="col s12">
<span class="card-title">Preprocessing</span>
@ -86,7 +86,7 @@
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(add_job_form.submit, material_icon='send') }}
{{ M.render_field(add_job_form.submit, material_icon='send') }}
</div>
</form>
</div>

View File

@ -30,19 +30,19 @@
{{ add_job_form.hidden_tag() }}
<div class="row">
<div class="col s12 l4">
{{ materialize.field(add_job_form.title, data_length='32', material_icon='title') }}
{{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
</div>
<div class="col s12 l8">
{{ materialize.field(add_job_form.description, data_length='255', material_icon='description') }}
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12 l5">
{{ materialize.field(add_job_form.files, accept='application/pdf') }}
{{ M.render_field(add_job_form.files, accept='application/pdf') }}
</div>
<div class="col s12 l4">
{{ materialize.field(add_job_form.language, material_icon='language') }}
{{ M.render_field(add_job_form.language, material_icon='language') }}
</div>
<div class="col s12 l3">
{{ materialize.field(add_job_form.version, material_icon='apps') }}
{{ M.render_field(add_job_form.version, material_icon='apps') }}
</div>
<div class="col s12">
<span class="card-title">Preprocessing</span>
@ -113,7 +113,7 @@
</div>
</div>
<div class="card-action right-align">
{{ materialize.field(add_job_form.submit, material_icon='send') }}
{{ M.render_field(add_job_form.submit, material_icon='send') }}
</div>
</form>
</div>