Skip to content

Commit c8a0c66

Browse files
committed
Adding filtering also in the offline report
1 parent 01b7e33 commit c8a0c66

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

html/index.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,36 @@ function getHtmlResults () {
593593
const doc = document.implementation.createHTMLDocument()
594594
const head = doc.head
595595
const body = doc.body
596+
597+
const script = doc.createElement('script')
598+
script.type = 'text/javascript'
599+
script.textContent = `
600+
function filterTestCasesBasedOnStateHandler(tableId, tableName, state, mandatoryOptional) { // eslint-disable-line no-unused-vars
601+
const checkBox = document.getElementById('filter-' + mandatoryOptional + '-' + state + '-' + tableName)
602+
const show = checkBox.checked
603+
if (show) {
604+
checkBox.setAttribute('checked', '')
605+
} else {
606+
checkBox.removeAttribute('checked')
607+
}
608+
const tableIdClean = tableId.replace(/#/g, '')
609+
const table = document.getElementById(tableIdClean)
610+
const elements = table.getElementsByClassName('accordion-item')
611+
for (let i = 0; i < elements.length; i++) {
612+
const element = elements[i]
613+
const id = element.getAttribute('data-id')
614+
if (id === state) {
615+
if (show === true) {
616+
element.removeAttribute('hidden')
617+
} else {
618+
element.setAttribute('hidden', 'hidden')
619+
}
620+
}
621+
}
622+
}
623+
`
624+
doc.head.appendChild(script)
625+
596626
selectScenarioComboBox = document.getElementById('selectScenarioComboBox')
597627
insertResults(body, 'mandatory')
598628
if (selectScenarioComboBox.value !== 'all') {
@@ -611,13 +641,8 @@ function getHtmlResults () {
611641
})
612642

613643
// Make document read-only
614-
const checkboxes = doc.querySelectorAll('input[type="checkbox"]')
615644
const textareas = doc.querySelectorAll('textarea')
616645

617-
checkboxes.forEach(checkbox => {
618-
checkbox.setAttribute('disabled', 'disabled')
619-
})
620-
621646
textareas.forEach(textarea => {
622647
textarea.readOnly = true
623648
})

0 commit comments

Comments
 (0)