Commit 777c991e authored by bensinober's avatar bensinober Committed by Benjamin
Browse files

DEICH-5758 koha : improve visual feedback in deichman-reports

parent fe585f7d
......@@ -88,6 +88,7 @@ class DeichmanReports extends HTMLElement {
row.innerHTML = `<td>${el.id}</td><td>${el.desc}</td>`
row.addEventListener("click", (e) => {
this._clearResults()
this.report = el.id
this._fetchReport(el.id)
})
reports.appendChild(row)
......@@ -102,12 +103,23 @@ class DeichmanReports extends HTMLElement {
_refreshTables() {
let div = this.shadowRoot.getElementById("report-tables")
let frag = document.createDocumentFragment()
let head = document.createElement("div")
head.innerHTML = `<h3>Rapport: ${this.report}</h3>`
let args = ""
for (const a in this._args) {
args += `<li>${a} : ${this._args[a]}</li>`
}
head.innerHTML += `Parametre:
<ul>${args}</ul>
<h3>Resultat:</h3>`
frag.appendChild(head)
console.log(this._results)
// we can have multiple reports in one result
for (const res of this._results) {
const { id, desc, result } = res
const tbl = document.createElement("div")
if (result && result.length) {
const headers = Object.keys(result[0])
const tbl = document.createElement("div")
let rows = []
for (const row of result) {
let rowElements = []
......@@ -123,7 +135,10 @@ class DeichmanReports extends HTMLElement {
<tbody>${rows.map(row => `<tr>${row.map(el => `<td>${el}</td>`).join("")}</td></tr>`).join("")}</tbody>
<table>`
frag.appendChild(tbl)
} else {
tbl.innerHTML = `<h3>${res.desc}</h3>Intet resultat`
}
frag.appendChild(tbl)
}
this._clearResults()
div.appendChild(frag)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment