mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
77 lines
2.4 KiB
Django/Jinja
77 lines
2.4 KiB
Django/Jinja
{% macro field(field) %}
|
|
{% if field.type == 'BooleanField' %}
|
|
{{ boolean_field(field, *args, **kwargs) }}
|
|
{% elif field.type == 'SubmitField' %}
|
|
{{ submit_field(field, *args, **kwargs) }}
|
|
{% elif field.type in ['FileField', 'MultipleFileField'] %}
|
|
{{ file_field(field, *args, **kwargs) }}
|
|
{% elif field.type in ['IntegerField', 'PasswordField', 'SelectField', 'StringField'] %}
|
|
{{ generic_field(field, *args, **kwargs) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro boolean_field(field) %}
|
|
<div class="switch">
|
|
{% if 'material_icon' in kwargs %}
|
|
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
|
|
{% endif %}
|
|
<label>
|
|
{{ field.label.text }}
|
|
{{ field() }}
|
|
<span class="lever"></span>
|
|
</label>
|
|
{% for error in field.errors %}
|
|
<span class="helper-text red-text">{{ error }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro file_field(field) %}
|
|
<div class="file-field input-field">
|
|
<div class="btn">
|
|
<span>{{ field.label.text }}</span>
|
|
{{ field(**kwargs) }}
|
|
</div>
|
|
<div class="file-path-wrapper">
|
|
<input class="file-path validate" type="text">
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro generic_field(field) %}
|
|
{% if field.type == 'IntegerField' %}
|
|
{% set tmp = kwargs.update({'type': 'number'}) %}
|
|
{% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %}
|
|
{% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %}
|
|
{% else %}
|
|
{% set tmp = kwargs.update({'class_': 'validate'}) %}
|
|
{% endif %}
|
|
{% endif %}
|
|
<div class="input-field">
|
|
{% if 'material_icon' in kwargs %}
|
|
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
|
|
{% endif %}
|
|
{{ field(**kwargs) }}
|
|
{{ field.label }}
|
|
{% for error in field.errors %}
|
|
<span class="helper-text red-text">{{ error }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro 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 %}
|
|
<i class="material-icons right">{{ kwargs.pop('material_icon') }}</i>
|
|
{% 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 %}
|