Improve editor selection in "no book" case. #4

This commit is contained in:
Gabriel Augendre 2018-06-02 09:33:43 +02:00
parent ddd1043113
commit f21f8a8ac9

View file

@ -4,10 +4,19 @@ document.addEventListener("DOMContentLoaded", function (event) {
if (_selector.checked) {
document.querySelector('#id_title').value = "PAS DE LIVRE POUR CETTE CLASSE";
document.querySelector('#id_authors').value = "N/A";
document.querySelector('#id_editor').value = 1;
document.querySelector('#id_publication_year').value = 1900;
document.querySelector('#id_isbn').value = "0000000000";
document.querySelector('#id_price').value = 0;
var editorValue = null;
for (var option of document.querySelector('#id_editor').children) {
if (editorValue === null && option.value !== "") {
editorValue = option.value;
}
if (option.firstChild.data.toLowerCase().indexOf('autre') !== -1) {
editorValue = option.value;
}
}
document.querySelector('#id_editor').value = editorValue;
} else {
document.querySelector('#id_title').value = "";
document.querySelector('#id_authors').value = "";