This commit is contained in:
@@ -1049,7 +1049,7 @@
|
|||||||
const resp = await fetch('/api/library_return_by_code', {
|
const resp = await fetch('/api/library_return_by_code', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({item_code: code})
|
body: JSON.stringify({ item_code: code })
|
||||||
});
|
});
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (!resp.ok || !result.ok) {
|
if (!resp.ok || !result.ok) {
|
||||||
@@ -1068,7 +1068,6 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setScanStatus('Verarbeite Mediencode...', 'warn');
|
setScanStatus('Verarbeite Mediencode...', 'warn');
|
||||||
const response = await fetch('/api/library_scan_action', {
|
const response = await fetch('/api/library_scan_action', {
|
||||||
@@ -1120,9 +1119,9 @@
|
|||||||
|
|
||||||
scanEditBtn.textContent = 'Scanner schließen';
|
scanEditBtn.textContent = 'Scanner schließen';
|
||||||
|
|
||||||
startScanner(function (decodedText) {
|
startScanner(function(decodedText) {
|
||||||
editCodeInput.value = decodedText;
|
editCodeInput.value = decodedText;
|
||||||
if (typeof validateCodeField === "function") {
|
if(typeof validateCodeField === "function") {
|
||||||
validateCodeField(editCodeInput, document.getElementById('edit-item-id')?.value || null);
|
validateCodeField(editCodeInput, document.getElementById('edit-item-id')?.value || null);
|
||||||
}
|
}
|
||||||
scanEditBtn.textContent = 'Barcode scannen';
|
scanEditBtn.textContent = 'Barcode scannen';
|
||||||
@@ -1208,7 +1207,7 @@
|
|||||||
if (kind) el.classList.add(kind);
|
if (kind) el.classList.add(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSmallConfirm(message, kind = 'ok') {
|
function showSmallConfirm(message, kind='ok') {
|
||||||
// Append the small helper text in German
|
// Append the small helper text in German
|
||||||
const helper = 'Sie können fortfahren. Dies ist nur eine kleine Benachrichtigung.';
|
const helper = 'Sie können fortfahren. Dies ist nur eine kleine Benachrichtigung.';
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
@@ -1220,12 +1219,7 @@
|
|||||||
if (el && el.parentNode) el.parentNode.removeChild(el);
|
if (el && el.parentNode) el.parentNode.removeChild(el);
|
||||||
});
|
});
|
||||||
// auto remove after 3 seconds
|
// auto remove after 3 seconds
|
||||||
setTimeout(() => {
|
setTimeout(() => { try { if (el && el.parentNode) el.parentNode.removeChild(el); } catch(e){} }, 3000);
|
||||||
try {
|
|
||||||
if (el && el.parentNode) el.parentNode.removeChild(el);
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActiveStudentCard(cardId) {
|
function setActiveStudentCard(cardId) {
|
||||||
@@ -1239,7 +1233,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getItemTypeLabel(type) {
|
function getItemTypeLabel(type) {
|
||||||
const labels = {'book': 'Buch', 'cd': 'CD', 'dvd': 'DVD', 'other': 'Sonstige', 'schoolbook': 'Schulbuch'};
|
const labels = { 'book': 'Buch', 'cd': 'CD', 'dvd': 'DVD', 'other': 'Sonstige', 'schoolbook': 'Schulbuch' };
|
||||||
return labels[type] || type;
|
return labels[type] || type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1282,7 +1276,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Closes the modal if the user clicks the dark background overlay
|
// Closes the modal if the user clicks the dark background overlay
|
||||||
window.onclick = function (event) {
|
window.onclick = function(event) {
|
||||||
const modal = document.getElementById('detailModal');
|
const modal = document.getElementById('detailModal');
|
||||||
// If the click happened directly on the dark overlay (not the white box)
|
// If the click happened directly on the dark overlay (not the white box)
|
||||||
if (event.target === modal) {
|
if (event.target === modal) {
|
||||||
@@ -1341,7 +1335,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run when DOM structure is entirely ready
|
// Run when DOM structure is entirely ready
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
wireScannerUi(); // Setup scanner control buttons
|
wireScannerUi(); // Setup scanner control buttons
|
||||||
loadLibraryItems(); // Fetch your database items right away!
|
loadLibraryItems(); // Fetch your database items right away!
|
||||||
|
|
||||||
@@ -1405,31 +1399,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Edit Modal Form processing
|
||||||
const editForm = document.getElementById('editLibraryForm');
|
const editForm = document.getElementById('editLibraryForm');
|
||||||
if (editForm) {
|
if (editForm) {
|
||||||
editForm.addEventListener('submit', async function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const itemId = document.getElementById('editLibraryItemId').value;
|
|
||||||
const currentItem = libraryItems.find(i => i._id === itemId);
|
|
||||||
if (!currentItem) return;
|
|
||||||
|
|
||||||
const sharedPayload = {
|
|
||||||
name: document.getElementById('editLibraryName').value,
|
|
||||||
item_type: document.getElementById('editLibraryType').value,
|
|
||||||
isbn: document.getElementById('editLibraryIsbn').value,
|
|
||||||
ort: document.getElementById('editLibraryLocation').value,
|
|
||||||
beschreibung: document.getElementById('editLibraryDescription').value,
|
|
||||||
ansch_jahr: currentItem.Anschaffungsjahr || '',
|
|
||||||
ansch_kost: currentItem.Anschaffungskosten || '',
|
|
||||||
reservierbar: currentItem.Reservierbar !== false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const codeInputs = Array.from(document.querySelectorAll('#editLibraryCodesContainer input[data-item-id]'));
|
|
||||||
const codeByItemId = new Map(codeInputs.map(input => [input.dataset.itemId, (input.value || '').trim()]));
|
|
||||||
const groupMembers = editLibraryState.groupMembers.length > 0 ? editLibraryState.groupMembers : [currentItem];
|
|
||||||
const isGroupedEdit = Boolean(currentItem.SeriesGroupId) && groupMembers.length > 1;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isGroupedEdit) {
|
if (isGroupedEdit) {
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -1495,6 +1467,29 @@
|
|||||||
console.error('Update failed:', error);
|
console.error('Update failed:', error);
|
||||||
alert('Netzwerkfehler beim Aktualisieren des Mediums.');
|
alert('Netzwerkfehler beim Aktualisieren des Mediums.');
|
||||||
}
|
}
|
||||||
|
editForm.addEventListener('submit', async function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const itemId = document.getElementById('editLibraryItemId').value;
|
||||||
|
const currentItem = libraryItems.find(i => i._id === itemId);
|
||||||
|
if (!currentItem) return;
|
||||||
|
|
||||||
|
const codeInputs = Array.from(document.querySelectorAll('#editLibraryCodesContainer input[data-item-id]'));
|
||||||
|
|
||||||
|
const sharedPayload = {
|
||||||
|
name: document.getElementById('editLibraryName').value,
|
||||||
|
item_type: document.getElementById('editLibraryType').value,
|
||||||
|
isbn: document.getElementById('editLibraryIsbn').value,
|
||||||
|
ort: document.getElementById('editLibraryLocation').value,
|
||||||
|
beschreibung: document.getElementById('editLibraryDescription').value,
|
||||||
|
ansch_jahr: currentItem.Anschaffungsjahr || '',
|
||||||
|
ansch_kost: currentItem.Anschaffungskosten || '',
|
||||||
|
reservierbar: currentItem.Reservierbar !== false,
|
||||||
|
};
|
||||||
|
const codeByItemId = new Map(codeInputs.map(input => [input.dataset.itemId, (input.value || '').trim()]));
|
||||||
|
const groupMembers = editLibraryState.groupMembers.length > 0 ? editLibraryState.groupMembers : [currentItem];
|
||||||
|
const isGroupedEdit = Boolean(currentItem.SeriesGroupId) && groupMembers.length > 1;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user