fix(assessment-history): fix func detail

This commit is contained in:
arieeefajar 2025-04-29 14:49:54 +07:00
parent 28588ac6bf
commit 4a4be65050
2 changed files with 27 additions and 39 deletions

View File

@ -1,30 +1,32 @@
function detailData(data) {
let tbody = document.querySelector("#detailTable tbody");
const detailBody = document.querySelector("#detail-body");
detailBody.innerHTML = "";
tbody.innerHTML = "";
if (Array.isArray(data)) {
data.forEach((item) => {
const parameterTypes = item.indicator.rules
.map((rule) => rule.parameter_type)
.join(", ");
let row = `
<tr>
<td>${item.indicator.name}</td>
<td>${parameterTypes}</td>
</tr>
`;
tbody.innerHTML += row;
});
} else {
data.forEach((item) => {
const parameterTypes = item.indicator.rules
.map((rule) => rule.parameter_type)
.join(", ");
let row = `
<tr>
<td>${data.indicator.name}</td>
<td>${parameterTypes}</td>
</tr>
<div class="mb-3">
<label for="indicator-${
item.indicator.id
}" class="form-label">${item.indicator.name}</label>
<select name="indicator" class="form-control" id="indicator-${
item.indicator.id
}" disabled>
<option value="" disabled selected>Pilih Jawaban</option>
${item.indicator.rules
.map((rule) => {
return `<option value="${rule.cf}" ${
item.cf_e == rule.cf ? "selected" : ""
}>${rule.parameter_type}</option>`;
})
.join("")}
</select>
</div>
`;
tbody.innerHTML += row;
}
detailBody.innerHTML += row;
});
}
var perPage = 10,

View File

@ -194,26 +194,12 @@ class="fw-medium link-primary">#VZ2101</a>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
id="close-modal"></button>
</div>
<div class="modal-body">
<table class="table align-middle table-nowrap" id="detailTable">
<thead>
<tr>
<th>Indikator</th>
<th>Nilai</th>
</tr>
</thead>
<tbody>
<tr>
<td>pH</td>
<td>0.8</td>
</tr>
</tbody>
</table>
<div class="modal-body" id="detail-body">
</div>
<div class="modal-footer">
<div class="hstack gap-2 justify-content-end">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">
Close
Tutup
</button>
</div>
</div>