Skip to content
Snippets Groups Projects
Commit 16fad5bb authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Add character counter to job forms.

parent 129ee05b
No related branches found
No related tags found
No related merge requests found
...@@ -4,75 +4,56 @@ from wtforms.validators import DataRequired, Length ...@@ -4,75 +4,56 @@ from wtforms.validators import DataRequired, Length
class NewNLPJobForm(FlaskForm): class NewNLPJobForm(FlaskForm):
description = StringField( description = StringField('Description',
'Description', validators=[DataRequired(), Length(1, 255)])
validators=[DataRequired(), Length(1, 255)]
)
files = MultipleFileField('Files', validators=[DataRequired()]) files = MultipleFileField('Files', validators=[DataRequired()])
language = SelectField( language = SelectField('Language',
'Language', choices=[('', 'Choose your option'),
choices=[('', 'Choose your option'), ('nl', 'Dutch'),
('en', 'English'), ('en', 'English'),
('fr', 'French'), ('fr', 'French'),
('de', 'German'), ('de', 'German'),
('it', 'Italian'), ('el', 'Greek'),
('pt', 'Portuguese'), ('it', 'Italian'),
('es', 'Spanish')], ('pt', 'Portuguese'),
validators=[DataRequired()] ('es', 'Spanish')],
) validators=[DataRequired()])
submit = SubmitField('Submit') submit = SubmitField('Submit')
title = StringField( title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
'Title', version = SelectField('Version',
validators=[DataRequired(), Length(1, 32)] choices=[('latest', 'Latest (2.1.0)'),
) ('2.1.0', '2.1.0')],
version = SelectField( validators=[DataRequired()])
'Version',
choices=[('', 'Choose your option'),
('latest', 'Latest (2.1.0)'),
('2.1.0', '2.1.0')],
validators=[DataRequired()]
)
def validate_files(form, field): def validate_files(form, field):
for file in field.data: for file in field.data:
if not file.filename.lower().endswith('.txt'): if not file.filename.lower().endswith('.txt'):
raise ValidationError( raise ValidationError(
'File does not have an approved extension: ' 'File does not have an approved extension: .txt'
'.txt'
) )
class NewOCRJobForm(FlaskForm): class NewOCRJobForm(FlaskForm):
description = StringField( description = StringField('Description',
'Description', validators=[DataRequired(), Length(1, 255)])
validators=[DataRequired(), Length(1, 255)]
)
files = MultipleFileField('Files', validators=[DataRequired()]) files = MultipleFileField('Files', validators=[DataRequired()])
language = SelectField( language = SelectField('Language',
'Language', choices=[('', 'Choose your option'),
choices=[('', 'Choose your option'), ('eng', 'English'),
('eng', 'English'), ('enm', 'English, Middle (1100-1500)'),
('enm', 'English, Middle (1100-1500)'), ('fra', 'French'),
('fra', 'French'), ('frm', 'French, Middle (ca. 1400-1600)'),
('frm', 'French, Middle (ca. 1400-1600)'), ('deu', 'German'),
('deu', 'German'), ('frk', 'German Fraktur'),
('frk', 'German Fraktur'), ('ita', 'Italian'),
('ita', 'Italian'), ('por', 'Portuguese'),
('por', 'Portuguese'), ('spa', 'Spanish; Castilian')],
('spa', 'Spanish; Castilian')], validators=[DataRequired()])
validators=[DataRequired()]
)
submit = SubmitField('Submit') submit = SubmitField('Submit')
title = StringField( title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
'Title', version = SelectField('Version',
validators=[DataRequired(), Length(1, 32)] choices=[('latest', 'Latest')],
) validators=[DataRequired()])
version = SelectField(
'Version',
choices=[('', 'Choose your option'),
('latest', 'Latest')],
validators=[DataRequired()]
)
def validate_files(form, field): def validate_files(form, field):
for file in field.data: for file in field.data:
......
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
<script type="text/javascript" src="{{ url_for('static', filename='js/materialize.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/materialize.min.js') }}"></script>
<script> <script>
M.AutoInit(); M.AutoInit();
M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="text"]'))
M.Dropdown.init( M.Dropdown.init(
document.getElementById("nav-notifications"), document.getElementById("nav-notifications"),
{"alignment": "right", "constrainWidth": false, "coverTrigger": false} {"alignment": "right", "constrainWidth": false, "coverTrigger": false}
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> <div class="input-field">
<i class="material-icons prefix">title</i> <i class="material-icons prefix">title</i>
{{ new_nlp_job_form.title() }} {{ new_nlp_job_form.title(data_length='32') }}
{{ new_nlp_job_form.title.label }} {{ new_nlp_job_form.title.label }}
{% for error in new_nlp_job_form.title.errors %} {% for error in new_nlp_job_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span> <span class="helper-text red-text">{{ error }}</span>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<div class="col s12 m6"> <div class="col s12 m6">
<div class="input-field"> <div class="input-field">
<i class="material-icons prefix">description</i> <i class="material-icons prefix">description</i>
{{ new_nlp_job_form.description() }} {{ new_nlp_job_form.description(data_length='255') }}
{{ new_nlp_job_form.description.label }} {{ new_nlp_job_form.description.label }}
{% for error in new_nlp_job_form.description.errors %} {% for error in new_nlp_job_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span> <span class="helper-text red-text">{{ error }}</span>
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> <div class="input-field">
<i class="material-icons prefix">title</i> <i class="material-icons prefix">title</i>
{{ new_ocr_job_form.title() }} {{ new_ocr_job_form.title(data_length='32') }}
{{ new_ocr_job_form.title.label }} {{ new_ocr_job_form.title.label }}
{% for error in new_ocr_job_form.title.errors %} {% for error in new_ocr_job_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span> <span class="helper-text red-text">{{ error }}</span>
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<div class="col s12 m6"> <div class="col s12 m6">
<div class="input-field"> <div class="input-field">
<i class="material-icons prefix">description</i> <i class="material-icons prefix">description</i>
{{ new_ocr_job_form.description() }} {{ new_ocr_job_form.description(data_length='255') }}
{{ new_ocr_job_form.description.label }} {{ new_ocr_job_form.description.label }}
{% for error in new_ocr_job_form.description.errors %} {% for error in new_ocr_job_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span> <span class="helper-text red-text">{{ error }}</span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment