Merge pull request #148 from LD-Reborn/147-fix-bugs-in-homeinventory-invalid-entries-open-modal-camera-requests-while-change-modal-is-open

147 fix bugs in homeinventory invalid entries open modal camera requests while change modal is open
This commit is contained in:
LD50
2025-10-17 20:00:44 +02:00
committed by GitHub

View File

@@ -13,8 +13,6 @@
<div class="col-md-3 text-center"> <div class="col-md-3 text-center">
<input type="text" id="barcodeInput" class="form-control mt-3" placeholder="@T["Asset ID"]" /> <input type="text" id="barcodeInput" class="form-control mt-3" placeholder="@T["Asset ID"]" />
<button id="enterAssetIdManuallyButton" class="btn btn-secondary mt-3">@T["Enter asset ID manually"]</button> <button id="enterAssetIdManuallyButton" class="btn btn-secondary mt-3">@T["Enter asset ID manually"]</button>
</div>
<div class="col-md-6 text-center">
<div id="reader" style="display:none" class="mt-3"></div> <div id="reader" style="display:none" class="mt-3"></div>
<button id="scanBarcodeButton" class="btn btn-primary mt-3">@T["Scan barcode"]</button> <button id="scanBarcodeButton" class="btn btn-primary mt-3">@T["Scan barcode"]</button>
</div> </div>
@@ -174,7 +172,6 @@
const modal = new bootstrap.Modal(viewModal); const modal = new bootstrap.Modal(viewModal);
viewContent.innerHTML = '<p class="text-center text-muted">@T["Loading..."]</p>'; viewContent.innerHTML = '<p class="text-center text-muted">@T["Loading..."]</p>';
modal.show();
try { try {
const response = await fetch(`/Assets/Get?cn=${decodedText}`); const response = await fetch(`/Assets/Get?cn=${decodedText}`);
@@ -182,9 +179,12 @@
const asset = json.assetsModel; const asset = json.assetsModel;
if (!asset) { if (!asset) {
viewContent.innerHTML = `<p class="text-danger text-center">@T["Asset not found."]</p>`; const input = document.getElementById("barcodeInput");
input.classList.add("is-invalid");
showToast('@T["Asset not found."]', 'danger');
return; return;
} }
modal.show();
const html = ` const html = `
<div class="row g-3"> <div class="row g-3">
@@ -311,16 +311,6 @@
onScanSuccess, onScanSuccess,
onScanError onScanError
); );
document.getElementById('viewAssetModal').addEventListener('hidden.bs.modal', () => {
html5QrCode.start(
{ facingMode: "environment" },
{ fps: 10, qrbox: { width: 300, height: 150 } },
onScanSuccess,
onScanError
).catch(err => console.error("Error restarting scanner:", err));
});
}); });
} }
@@ -378,6 +368,11 @@
} }
}); });
} }
document.getElementById("barcodeInput").addEventListener("input", e => {
e.target.classList.remove("is-invalid");
});
</script> </script>
} }