58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
// QA Checklist API Client
|
|
async function loadQaChecklist() {
|
|
try {
|
|
const res = await fetch('/api/qa');
|
|
if (!res.ok) throw new Error("Failed to load QA data");
|
|
const tasks = await res.json();
|
|
|
|
const container = document.getElementById('qa-checklist-container');
|
|
if (!container) return;
|
|
|
|
container.innerHTML = '';
|
|
|
|
tasks.forEach(task => {
|
|
const div = document.createElement('div');
|
|
div.className = 'check-item';
|
|
|
|
const checkbox = document.createElement('input');
|
|
checkbox.type = 'checkbox';
|
|
checkbox.checked = task.is_completed;
|
|
checkbox.dataset.id = task.id;
|
|
checkbox.addEventListener('change', async (e) => {
|
|
await toggleQaTask(task.id, e.target.checked);
|
|
if (typeof updateQAProgress === 'function') {
|
|
updateQAProgress();
|
|
}
|
|
});
|
|
|
|
const label = document.createElement('label');
|
|
label.innerHTML = `<strong>${task.id}:</strong> ${task.label}`;
|
|
|
|
div.appendChild(checkbox);
|
|
div.appendChild(label);
|
|
container.appendChild(div);
|
|
});
|
|
|
|
if (typeof updateQAProgress === 'function') {
|
|
updateQAProgress();
|
|
}
|
|
} catch (err) {
|
|
console.error("QA Loading Error:", err);
|
|
}
|
|
}
|
|
|
|
async function toggleQaTask(id, is_completed) {
|
|
try {
|
|
await fetch(`/api/qa/${id}`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ is_completed })
|
|
});
|
|
} catch (err) {
|
|
console.error("Failed to update QA task", err);
|
|
}
|
|
}
|
|
|
|
window.loadQaChecklist = loadQaChecklist;
|
|
window.toggleQaTask = toggleQaTask;
|