From 154631dcb4750de5d793e7989ce18480862528a9 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Thu, 23 Apr 2020 12:39:59 +0200 Subject: [PATCH] Add placeholder to indicate required file types in forms --- app/templates/corpora/add_corpus_file.html.j2 | 2 +- app/templates/macros/materialize.html.j2 | 13 +++++++------ app/templates/services/file-setup.html.j2 | 2 +- app/templates/services/nlp.html.j2 | 2 +- app/templates/services/ocr.html.j2 | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/templates/corpora/add_corpus_file.html.j2 b/app/templates/corpora/add_corpus_file.html.j2 index 9242c0e8..11bca5dd 100644 --- a/app/templates/corpora/add_corpus_file.html.j2 +++ b/app/templates/corpora/add_corpus_file.html.j2 @@ -24,7 +24,7 @@ {{ M.render_field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
- {{ M.render_field(add_corpus_file_form.file, accept='.vrt') }} + {{ M.render_field(add_corpus_file_form.file, accept='.vrt', placeholder='Choose your .vrt file') }}
diff --git a/app/templates/macros/materialize.html.j2 b/app/templates/macros/materialize.html.j2 index 5b063dfa..40785de6 100644 --- a/app/templates/macros/materialize.html.j2 +++ b/app/templates/macros/materialize.html.j2 @@ -1,5 +1,5 @@ {% macro render_field(field) %} - {% if field.flags.required %} + {% if field.flags.required and field.type not in ['FileField', 'MultipleFileField'] %} {% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %} {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %} {% else %} @@ -35,7 +35,7 @@ {% endif %} {% for error in field.errors %} @@ -46,18 +46,19 @@ {% macro render_decimal_range_field(field) %}

- {{ field(**kwargs) }} + {{ field(*args, **kwargs) }}

{% endmacro %} {% macro render_file_field(field) %} + {% set placeholder = kwargs.pop('placeholder', '') %}
{{ field.label.text }} - {{ field(**kwargs) }} + {{ field(*args, **kwargs) }}
- +
{% endmacro %} @@ -67,7 +68,7 @@ {% if 'material_icon' in kwargs %} {{ kwargs.pop('material_icon') }} {% endif %} - {{ field(**kwargs) }} + {{ field(*args, **kwargs) }} {{ field.label }} {% for error in field.errors %} {{ error }} diff --git a/app/templates/services/file-setup.html.j2 b/app/templates/services/file-setup.html.j2 index f949752a..f84d2823 100644 --- a/app/templates/services/file-setup.html.j2 +++ b/app/templates/services/file-setup.html.j2 @@ -36,7 +36,7 @@ {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
- {{ M.render_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', placeholder='Choose your .jpeg, .png or .tiff files') }}
{{ M.render_field(add_job_form.version, material_icon='apps') }} diff --git a/app/templates/services/nlp.html.j2 b/app/templates/services/nlp.html.j2 index cf96befe..249a0a99 100644 --- a/app/templates/services/nlp.html.j2 +++ b/app/templates/services/nlp.html.j2 @@ -54,7 +54,7 @@ {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
- {{ M.render_field(add_job_form.files, accept='text/plain') }} + {{ M.render_field(add_job_form.files, accept='text/plain', placeholder='Choose your .txt files') }}
{{ M.render_field(add_job_form.language, material_icon='language') }} diff --git a/app/templates/services/ocr.html.j2 b/app/templates/services/ocr.html.j2 index 164dcc6a..9552de69 100644 --- a/app/templates/services/ocr.html.j2 +++ b/app/templates/services/ocr.html.j2 @@ -36,7 +36,7 @@ {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
- {{ M.render_field(add_job_form.files, accept='application/pdf') }} + {{ M.render_field(add_job_form.files, accept='application/pdf', placeholder='Choose your .pdf files') }}
{{ M.render_field(add_job_form.language, material_icon='language') }}