diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html index 491d96d1..e91ff9a0 100755 --- a/rapids/templates/rapids/rapid_form.html +++ b/rapids/templates/rapids/rapid_form.html @@ -28,23 +28,40 @@ document.addEventListener('drop', function (e) { e.preventDefault(); }, false); + function getUnusedInputs(inputs) { + new_inputs = []; + for (let i = 0; i < inputs.length; i++) { + input = inputs.get(i); + + if (input.value) { + new_inputs.push(input); + } + + } + + return $(new_inputs); + + } + function extendInputs(n) { // Makes sure we have n inputs available - inputs = $("#rapid-form input[type=file][id^=id_images-]"); - //fileInput = document.getElementById("id_images-0-image"); + // returns available inputs + inputs = getUnusedInputs($("#rapid-form input[type=file][id^=id_images-]")); + //fileInput = document.getElementById("id_images-0-image"); - // Make sure we have enough input targets - input_diff = (n - inputs.length) - console.log("diff", input_diff) - if (input_diff > 0) { - for (let j = 0; j < input_diff; j++) { - add_input_form() - } + // Make sure we have enough input targets + input_diff = (n - inputs.length) + console.log("diff", input_diff) - // Need to make sure we include the new ones... - inputs = $("#rapid-form input[type=file][id^=id_images-]"); + if (input_diff > 0) { + for (let j = 0; j < input_diff; j++) { + add_input_form() } + + // Need to make sure we include the new ones... + inputs = getUnusedInputs($("#rapid-form input[type=file][id^=id_images-]")); + } return inputs; } @@ -451,7 +468,7 @@ option.appendTo($("#id_examination_to")); toastr.success(`Examination set to ${option.attr('title')} from dicom data`); } else { - toastr.warning(`Unable to set examination ${option.attr('title')} from dicom data (it needs creating)`); + toastr.warning(`Unable to set examination ${study_description} from dicom data (it needs creating)`); }