Removal again
Release Inventarsystem / release-docker (push) Successful in 2m15s

This commit is contained in:
2026-08-22 00:08:38 +02:00
parent c67f64a45a
commit 17b58ff7ca
+10 -43
View File
@@ -1523,18 +1523,12 @@
document.getElementById('new-location-input').value = ''; document.getElementById('new-location-input').value = '';
} }
// Globale Variablen definieren // Function to fetch book information from ISBN
let currentFetchedIsbn = null; function fetchBookInfo(formType) {
let currentBookData = null; if (!libraryModuleEnabled) {
// Function to fetch book information from ISBN (an window gebunden)
window.fetchBookInfo = function(formType) {
// Sicherheitsprüfung, falls die Variable in manchen Ladezuständen nicht existiert
if (typeof libraryModuleEnabled !== 'undefined' && !libraryModuleEnabled) {
alert('Bibliotheks-Modul ist deaktiviert.'); alert('Bibliotheks-Modul ist deaktiviert.');
return; return;
} }
const isbnField = document.getElementById('isbn'); const isbnField = document.getElementById('isbn');
const infoContainer = document.getElementById('book-info-container'); const infoContainer = document.getElementById('book-info-container');
@@ -1543,25 +1537,13 @@
return; return;
} }
// Fallback, falls normalizeIsbnClient nicht geladen wurde const isbn = normalizeIsbnClient(isbnField.value);
const isbn = typeof normalizeIsbnClient === 'function' ? normalizeIsbnClient(isbnField.value) : isbnField.value.trim();
if (!isbn) { if (!isbn) {
infoContainer.innerHTML = '<div class="error-message">Bitte geben Sie eine ISBN oder einen Barcode ein.</div>'; infoContainer.innerHTML = '<div class="error-message">Bitte geben Sie eine ISBN oder einen Barcode ein.</div>';
currentFetchedIsbn = null;
return; return;
} }
// FIX FÜR DAS DOPPELKLICK-PROBLEM:
// Wenn die gleiche ISBN bereits geladen wurde, brechen wir hier ab,
// um den Import-Button nicht durch das DOM-Refresh zu überschreiben.
if (currentFetchedIsbn === isbn && currentBookData !== null) {
return;
}
// Setze aktuelle ISBN, um neue Anfragen während des Ladens zu blockieren
currentFetchedIsbn = isbn;
// Show loading indicator // Show loading indicator
infoContainer.innerHTML = '<div class="loading-spinner">Informationen werden abgerufen...</div>'; infoContainer.innerHTML = '<div class="loading-spinner">Informationen werden abgerufen...</div>';
@@ -1580,7 +1562,6 @@
.then(data => { .then(data => {
if (data.error) { if (data.error) {
infoContainer.innerHTML = `<div class="error-message">${data.error}</div>`; infoContainer.innerHTML = `<div class="error-message">${data.error}</div>`;
currentFetchedIsbn = null; // Bei Fehler zurücksetzen
return; return;
} }
@@ -1588,7 +1569,6 @@
currentBookData = data; currentBookData = data;
// Display book information with import button // Display book information with import button
// WICHTIG: onclick ruft jetzt explizit window.importBookInfo auf
infoContainer.innerHTML = ` infoContainer.innerHTML = `
<div class="book-info"> <div class="book-info">
<h4>${data.title}</h4> <h4>${data.title}</h4>
@@ -1604,7 +1584,7 @@
<p>${data.description}</p> <p>${data.description}</p>
</div> </div>
` : ''} ` : ''}
<button type="button" class="import-book-button" onclick="window.importBookInfo('${formType}')"> <button type="button" class="import-book-button" onclick="importBookInfo('${formType}')">
Buchdaten in Formular übernehmen Buchdaten in Formular übernehmen
</button> </button>
</div> </div>
@@ -1613,12 +1593,11 @@
.catch(error => { .catch(error => {
infoContainer.innerHTML = `<div class="error-message">${error.message}</div>`; infoContainer.innerHTML = `<div class="error-message">${error.message}</div>`;
currentBookData = null; currentBookData = null;
currentFetchedIsbn = null; // Bei Fehler zurücksetzen
}); });
}; }
// Function to import book information into form (an window gebunden) // Function to import book information into form
window.importBookInfo = function(formType) { function importBookInfo(formType) {
if (!currentBookData) { if (!currentBookData) {
alert('Keine Buchdaten verfügbar zum Import.'); alert('Keine Buchdaten verfügbar zum Import.');
return; return;
@@ -1627,7 +1606,7 @@
// Get form fields // Get form fields
const nameField = document.getElementById('name'); const nameField = document.getElementById('name');
const descriptionField = document.getElementById('beschreibung'); const descriptionField = document.getElementById('beschreibung');
const priceField = document.getElementById('anschaffungskosten'); const priceField = document.getElementById('anschaffungskosten'); // <-- NEU
if (!nameField || !descriptionField) { if (!nameField || !descriptionField) {
alert('Fehler: Formularfelder nicht gefunden.'); alert('Fehler: Formularfelder nicht gefunden.');
@@ -1673,24 +1652,12 @@
} }
// Download and import book cover image if available // Download and import book cover image if available
// Sicherstellen, dass die Funktion nicht crasht, falls sie auf der Seite fehlt
if (currentBookData.thumbnail) { if (currentBookData.thumbnail) {
if (typeof downloadBookCover === 'function') {
try {
downloadBookCover(currentBookData.thumbnail); downloadBookCover(currentBookData.thumbnail);
} catch(e) {
console.warn('Cover konnte nicht geladen werden:', e);
}
}
} }
// Show success message // Show success message
const infoContainer = document.getElementById('book-info-container'); const infoContainer = document.getElementById('book-info-container');
// Alte Erfolgsmeldung entfernen, um Doppelungen zu vermeiden
const oldMessage = infoContainer.querySelector('.import-success-message');
if (oldMessage) oldMessage.remove();
const successMessage = document.createElement('div'); const successMessage = document.createElement('div');
successMessage.className = 'import-success-message'; successMessage.className = 'import-success-message';
successMessage.textContent = 'Buchdaten erfolgreich in das Formular übernommen!'; successMessage.textContent = 'Buchdaten erfolgreich in das Formular übernommen!';
@@ -1702,7 +1669,7 @@
successMessage.parentNode.removeChild(successMessage); successMessage.parentNode.removeChild(successMessage);
} }
}, 3000); }, 3000);
}; }
function downloadBookCover(imageUrl) { function downloadBookCover(imageUrl) {
if (!imageUrl) { if (!imageUrl) {