mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
Add Feedback for select field in job forms
This commit is contained in:
parent
283fbca969
commit
54baa8633a
@ -31,7 +31,7 @@ def service(service):
|
||||
if service == 'corpus_analysis':
|
||||
return render_template('services/{}.html.j2'.format(service),
|
||||
title=SERVICES[service]['name'])
|
||||
add_job_form = SERVICES[service]['add_job_form']()
|
||||
add_job_form = SERVICES[service]['add_job_form'](prefix='add-job-form')
|
||||
if add_job_form.is_submitted():
|
||||
if not add_job_form.validate():
|
||||
return make_response(add_job_form.errors, 400)
|
||||
|
@ -21,10 +21,23 @@ nopaque.foreignJobsSubscribers = [];
|
||||
// nopaque functions
|
||||
nopaque.forms = {};
|
||||
nopaque.forms.init = function() {
|
||||
var abortRequestElement, progressElement, progressModal,
|
||||
progressModalElement, request;
|
||||
var abortRequestElement, parentElement, progressElement, progressModal,
|
||||
progressModalElement, request, submitElement;
|
||||
|
||||
for (let form of document.querySelectorAll(".nopaque-job-form")) {
|
||||
submitElement = form.querySelector('button[type="submit"]');
|
||||
submitElement.addEventListener("click", function() {
|
||||
for (let selectElement of form.querySelectorAll('select')) {
|
||||
if (selectElement.value === "") {
|
||||
parentElement = selectElement.closest(".input-field");
|
||||
for (let helperTextElement of parentElement.querySelectorAll(".helper-text")) {
|
||||
helperTextElement.remove();
|
||||
}
|
||||
parentElement.insertAdjacentHTML("beforeend", `<span class="helper-text red-text">Please select an option.</span>`);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
request = new XMLHttpRequest();
|
||||
if (form.dataset.hasOwnProperty("progressModal")) {
|
||||
progressModalElement = document.getElementById(form.dataset.progressModal);
|
||||
|
@ -185,7 +185,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
<button class="btn waves-effect waves-light" id="submit" name="submit" type="submit">Submit<i class="material-icons right">send</i></button>
|
||||
<button class="btn waves-effect waves-light" id="add-job-form-submit" name="add-job-form-submit" type="submit">Submit<i class="material-icons right">send</i></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user