Skip to content

Commit a74efbe

Browse files
committed
add check if row exists
1 parent de740c7 commit a74efbe

File tree

1 file changed

+17
-14
lines changed
  • dsf-fhir/dsf-fhir-server/src/main/resources/fhir/static

1 file changed

+17
-14
lines changed

dsf-fhir/dsf-fhir-server/src/main/resources/fhir/static/form.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -722,24 +722,27 @@ function getValueOfDifferential(differentials, path, property) {
722722
function modifyTaskInputRow(definition) {
723723
const id = definition.typeSystem + "|" + definition.typeCode
724724
const row = document.querySelector(`div.row[for="${CSS.escape(id)}"]`)
725-
const span = row.querySelector('span.cardinalities')
726-
span.innerText = `[${definition.min}..${definition.max}]`
727725

728-
if (definition.max !== "1") {
729-
const plusIcon = htmlToElement('<span class="plus-minus-icon"></span>')
730-
const plusIconSvg = htmlToElement('<svg height="20" width="20" viewBox="0 -960 960 960"><title>Add additional input</title><path d="M453-280h60v-166h167v-60H513v-174h-60v174H280v60h173v166Zm27.266 200q-82.734 0-155.5-31.5t-127.266-86q-54.5-54.5-86-127.341Q80-397.681 80-480.5q0-82.819 31.5-155.659Q143-709 197.5-763t127.341-85.5Q397.681-880 480.5-880q82.819 0 155.659 31.5Q709-817 763-763t85.5 127Q880-563 880-480.266q0 82.734-31.5 155.5T763-197.684q-54 54.316-127 86Q563-80 480.266-80Zm.234-60Q622-140 721-239.5t99-241Q820-622 721.188-721 622.375-820 480-820q-141 0-240.5 98.812Q140-622.375 140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"/></svg>')
726+
if (row) {
727+
const span = row.querySelector('span.cardinalities')
728+
span.innerText = `[${definition.min}..${definition.max}]`
731729

732-
plusIconSvg.addEventListener("click", event => {
733-
appendInputRowAfter(id)
734-
event.preventDefault()
735-
})
730+
if (definition.max !== "1") {
731+
const plusIcon = htmlToElement('<span class="plus-minus-icon"></span>')
732+
const plusIconSvg = htmlToElement('<svg height="20" width="20" viewBox="0 -960 960 960"><title>Add additional input</title><path d="M453-280h60v-166h167v-60H513v-174h-60v174H280v60h173v166Zm27.266 200q-82.734 0-155.5-31.5t-127.266-86q-54.5-54.5-86-127.341Q80-397.681 80-480.5q0-82.819 31.5-155.659Q143-709 197.5-763t127.341-85.5Q397.681-880 480.5-880q82.819 0 155.659 31.5Q709-817 763-763t85.5 127Q880-563 880-480.266q0 82.734-31.5 155.5T763-197.684q-54 54.316-127 86Q563-80 480.266-80Zm.234-60Q622-140 721-239.5t99-241Q820-622 721.188-721 622.375-820 480-820q-141 0-240.5 98.812Q140-622.375 140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"/></svg>')
736733

737-
plusIcon.appendChild(plusIconSvg)
738-
span.appendChild(plusIcon)
739-
}
734+
plusIconSvg.addEventListener("click", event => {
735+
appendInputRowAfter(id)
736+
event.preventDefault()
737+
})
740738

741-
if (definition.min < 1 || definition.min === undefined)
742-
row.setAttribute("optional", "")
739+
plusIcon.appendChild(plusIconSvg)
740+
span.appendChild(plusIcon)
741+
}
742+
743+
if (definition.min < 1 || definition.min === undefined)
744+
row.setAttribute("optional", "")
745+
}
743746
}
744747

745748
function modifyQuestionnaireInputRow(item) {

0 commit comments

Comments
 (0)