* fix: Use relative URL for submission status link * refactor: Refactor/rename process_uploaded_submission async task * feat: Add async task to process but not accept a submission * feat: Replace upload_submission() with an async implementation (WIP) * fix: Do not put Submission in "uploaded" state if an error occured * refactor: Improve text/XML draft processing flow * feat: Extract authors from text in async processing * fix: Fix call signatures and abort submission on failed validation * feat: Validate submission name format * fix: Correctly validate emails from text submission * fix: Clean up submission validation * fix: Better display errors on upload_submission page * feat: Reload submission status page when awaiting validation * test: Fix call signatures; remove unused imports * chore: Add type hint * test: Update tests to match renamed task * fix: Fix typo in error message * test: Fix failing Api- and AsyncSubmissionTests * Rename process_uploaded_submission to process_and_accept_... * Remove outdated tests Does not yet test new behavior. * refactor: Break up submission_file() helper * test: Refactor tests to run the async processing (wip) * test: Drop test of bad PDF submission The PDF submission field was removed, so no need to test it. * test: Update more tests * test: Bring back create_and_post_submission() and fix more tests * fix: Drop to manual, don't cancel, on revision inconsistency Fixes remaining failing SubmitTest tests * style: Restyle upload_submission() with black * test: Verify that async submission processing is invoked on upload * test: Bring back old do_submission and fix tests Properly separating the upload and async processing stages of submission is a bigger refactoring than will fit right now. This better exercises the submission pipeline. * fix: Accept only XML for API submissions * test: Test submission processing utilities * feat: Improve status display for "validating" submissions * chore: Remove obsolete code * test: Update test to match amended text --------- Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
94 lines
3.2 KiB
JavaScript
94 lines
3.2 KiB
JavaScript
$(function () {
|
|
// fill in submitter info when an author button is clicked
|
|
$("form.idsubmit button.author")
|
|
.on("click", function () {
|
|
var name = $(this)
|
|
.data("name");
|
|
var email = $(this)
|
|
.data("email");
|
|
|
|
$(this)
|
|
.parents("form")
|
|
.find("input[name=submitter-name]")
|
|
.val(name || "");
|
|
$(this)
|
|
.parents("form")
|
|
.find("input[name=submitter-email]")
|
|
.val(email || "");
|
|
});
|
|
|
|
$("form.idsubmit")
|
|
.on("submit", function () {
|
|
if (this.submittedAlready)
|
|
return false;
|
|
else {
|
|
this.submittedAlready = true;
|
|
return true;
|
|
}
|
|
});
|
|
|
|
$("form.idsubmit #add-author")
|
|
.on("click", function () {
|
|
// clone the last author block and make it empty
|
|
var cloner = $("#cloner");
|
|
var next = cloner.clone();
|
|
next.find('input:not([type=hidden])')
|
|
.val('');
|
|
|
|
// find the author number
|
|
var t = next.children('h3')
|
|
.text();
|
|
var n = parseInt(t.replace(/\D/g, ''));
|
|
|
|
// change the number in attributes and text
|
|
next.find('*')
|
|
.each(function () {
|
|
var e = this;
|
|
$.each(['id', 'for', 'name', 'value'], function (i, v) {
|
|
if ($(e)
|
|
.attr(v)) {
|
|
$(e)
|
|
.attr(v, $(e)
|
|
.attr(v)
|
|
.replace(n - 1, n));
|
|
}
|
|
});
|
|
});
|
|
|
|
t = t.replace(n, n + 1);
|
|
next.children('h3')
|
|
.text(t);
|
|
|
|
// move the cloner id to next and insert next into the DOM
|
|
cloner.removeAttr('id');
|
|
next.attr('id', 'cloner');
|
|
next.insertAfter(cloner);
|
|
|
|
});
|
|
|
|
// Reload page periodically if the enableAutoReload checkbox is present and checked
|
|
const autoReloadSwitch = document.getElementById("enableAutoReload");
|
|
const timeSinceDisplay = document.getElementById("time-since-uploaded");
|
|
if (autoReloadSwitch) {
|
|
const autoReloadTime = 30000; // ms
|
|
let autoReloadTimeoutId;
|
|
autoReloadSwitch.parentElement.classList.remove("d-none");
|
|
timeSinceDisplay.classList.remove("d-none");
|
|
autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime);
|
|
autoReloadSwitch.addEventListener("change", (e) => {
|
|
if (e.currentTarget.checked) {
|
|
if (!autoReloadTimeoutId) {
|
|
autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime);
|
|
timeSinceDisplay.classList.remove("d-none");
|
|
}
|
|
} else {
|
|
if (autoReloadTimeoutId) {
|
|
clearTimeout(autoReloadTimeoutId);
|
|
autoReloadTimeoutId = null;
|
|
timeSinceDisplay.classList.add("d-none");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|