fix: Restore global scope for UI functions by separating qa.js from inline script
This commit is contained in:
parent
c24b33143d
commit
79559ba6f0
@ -922,7 +922,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Master Interactive JavaScript Application -->
|
<!-- Master Interactive JavaScript Application -->
|
||||||
<script type="module">
|
<script src="./qa.js"></script>
|
||||||
|
<script>
|
||||||
let scene, camera, renderer, controls;
|
let scene, camera, renderer, controls;
|
||||||
let groupSkeleton, groupSheets, groupFacade, groupDrives, groupFans, groupPcba, groupIsolatedPart;
|
let groupSkeleton, groupSheets, groupFacade, groupDrives, groupFans, groupPcba, groupIsolatedPart;
|
||||||
let raycaster, mouse;
|
let raycaster, mouse;
|
||||||
@ -2219,8 +2220,7 @@
|
|||||||
renderer.render(scene, camera);
|
renderer.render(scene, camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
import { loadQaChecklist } from './qa.js';
|
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
loadQaChecklist();
|
loadQaChecklist();
|
||||||
init3D();
|
init3D();
|
||||||
|
|||||||
26
viewer/qa.js
26
viewer/qa.js
@ -1,5 +1,5 @@
|
|||||||
// QA Checklist API Client
|
// QA Checklist API Client
|
||||||
export async function loadQaChecklist() {
|
async function loadQaChecklist() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/qa');
|
const res = await fetch('/api/qa');
|
||||||
if (!res.ok) throw new Error("Failed to load QA data");
|
if (!res.ok) throw new Error("Failed to load QA data");
|
||||||
@ -8,7 +8,7 @@ export async function loadQaChecklist() {
|
|||||||
const container = document.getElementById('qa-checklist-container');
|
const container = document.getElementById('qa-checklist-container');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
container.innerHTML = ''; // Clear hardcoded items
|
container.innerHTML = '';
|
||||||
|
|
||||||
tasks.forEach(task => {
|
tasks.forEach(task => {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
@ -20,7 +20,9 @@ export async function loadQaChecklist() {
|
|||||||
checkbox.dataset.id = task.id;
|
checkbox.dataset.id = task.id;
|
||||||
checkbox.addEventListener('change', async (e) => {
|
checkbox.addEventListener('change', async (e) => {
|
||||||
await toggleQaTask(task.id, e.target.checked);
|
await toggleQaTask(task.id, e.target.checked);
|
||||||
updateQAProgress();
|
if (typeof updateQAProgress === 'function') {
|
||||||
|
updateQAProgress();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const label = document.createElement('label');
|
const label = document.createElement('label');
|
||||||
@ -31,22 +33,15 @@ export async function loadQaChecklist() {
|
|||||||
container.appendChild(div);
|
container.appendChild(div);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expose function to global scope since HTML uses inline onchange="updateQAProgress()" for some reason
|
if (typeof updateQAProgress === 'function') {
|
||||||
window.updateQAProgress = () => {
|
updateQAProgress();
|
||||||
const total = document.querySelectorAll('.check-item input').length;
|
}
|
||||||
const checked = document.querySelectorAll('.check-item input:checked').length;
|
|
||||||
const pct = Math.round((checked / total) * 100) || 0;
|
|
||||||
document.getElementById('qa-progress-label').innerText = `${pct}% Complete`;
|
|
||||||
document.getElementById('qa-progress-bar').style.width = `${pct}%`;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.updateQAProgress();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("QA Loading Error:", err);
|
console.error("QA Loading Error:", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function toggleQaTask(id, is_completed) {
|
async function toggleQaTask(id, is_completed) {
|
||||||
try {
|
try {
|
||||||
await fetch(`/api/qa/${id}`, {
|
await fetch(`/api/qa/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@ -57,3 +52,6 @@ export async function toggleQaTask(id, is_completed) {
|
|||||||
console.error("Failed to update QA task", err);
|
console.error("Failed to update QA task", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.loadQaChecklist = loadQaChecklist;
|
||||||
|
window.toggleQaTask = toggleQaTask;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user