Additiopn to filter out the iduvidual items and
Release Inventarsystem / release-docker (push) Has been cancelled
Release Inventarsystem / release-docker (push) Has been cancelled
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -800,7 +800,7 @@
|
||||
return `
|
||||
<tr>
|
||||
<td class="table-title">${escapeHtml(item.Name || 'Untitled')}</td>
|
||||
<td>${escapeHtml(item.Code_4 || item.Code4 || '-')}</td>
|
||||
<td>${escapeHtml(Item.ISBN || '-')}</td>
|
||||
<td>${getItemTypeLabel(item.ItemType || 'book')}</td>
|
||||
<td style="font-weight:600; text-align:center;">${item.Quantity || item.GroupedDisplayCount || 1}</td>
|
||||
<td>
|
||||
@@ -1565,197 +1565,8 @@
|
||||
}).join('');
|
||||
}
|
||||
|
||||
window.openEditLibraryItem = async function (itemId) {
|
||||
const item = libraryItems.find(i => i._id === itemId);
|
||||
if (!item) return;
|
||||
|
||||
editLibraryState.itemId = item._id;
|
||||
editLibraryState.seriesGroupId = item.SeriesGroupId || '';
|
||||
editLibraryState.groupMembers = [];
|
||||
|
||||
// Felder befüllen
|
||||
document.getElementById('editLibraryItemId').value = item._id;
|
||||
document.getElementById('editLibraryName').value = item.Name;
|
||||
document.getElementById('editLibraryType').value = item.ItemType;
|
||||
document.getElementById('editLibraryIsbn').value = item.ISBN || '';
|
||||
document.getElementById('editLibraryDescription').value = item.Beschreibung;
|
||||
|
||||
// Orte laden und bestehenden Ort setzen
|
||||
await loadEditLocationOptions(item.Ort);
|
||||
|
||||
const codesContainer = document.getElementById('editLibraryCodesContainer');
|
||||
if (codesContainer) {
|
||||
codesContainer.innerHTML = '<div style="padding:10px 0; color:#6b7280;">Lade Codes...</div>';
|
||||
}
|
||||
|
||||
const groupMembers = item.SeriesGroupId ? await fetchLibraryGroupMembers(item.SeriesGroupId) : [item];
|
||||
renderLibraryGroupCodeFields(groupMembers.length > 0 ? groupMembers : [item], item._id);
|
||||
|
||||
document.getElementById('editLibraryModal').style.display = 'flex';
|
||||
};
|
||||
|
||||
function closeEditLibraryModal() {
|
||||
document.getElementById('editLibraryModal').style.display = 'none';
|
||||
// Setzt das Feld für neuen Ort sicherheitshalber zurück, wenn geschlossen wird
|
||||
cancelEditAddLocation();
|
||||
}
|
||||
|
||||
// Lädt die Optionen in das Dropdown und wählt den aktuellen Ort des Mediums aus
|
||||
async function loadEditLocationOptions(currentLocation) {
|
||||
try {
|
||||
const response = await fetch('/get_predefined_locations');
|
||||
const data = await response.json();
|
||||
const ortSelect = document.getElementById('editLibraryLocation');
|
||||
|
||||
if (ortSelect) {
|
||||
// Bestehende Optionen löschen (außer die erste Platzhalter-Option)
|
||||
while (ortSelect.children.length > 1) {
|
||||
ortSelect.removeChild(ortSelect.lastChild);
|
||||
}
|
||||
|
||||
let locationFound = false;
|
||||
|
||||
// Neue Optionen aus der Datenbank hinzufügen
|
||||
data.locations.forEach(location => {
|
||||
const option = document.createElement('option');
|
||||
option.value = location;
|
||||
option.textContent = location;
|
||||
ortSelect.appendChild(option);
|
||||
|
||||
if (location === currentLocation) {
|
||||
locationFound = true;
|
||||
}
|
||||
});
|
||||
|
||||
// WICHTIG: Falls der aktuell hinterlegte Ort nicht in der Datenbank-Liste ist,
|
||||
// fügen wir ihn als temporäre Option hinzu, damit er nicht beim Speichern überschrieben wird.
|
||||
if (currentLocation && !locationFound) {
|
||||
const option = document.createElement('option');
|
||||
option.value = currentLocation;
|
||||
option.textContent = currentLocation;
|
||||
ortSelect.appendChild(option);
|
||||
}
|
||||
|
||||
// Zuletzt den aktuellen Ort anwählen
|
||||
if (currentLocation) {
|
||||
ortSelect.value = currentLocation;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading location options:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Funktion um einen neuen Ort ins Bearbeiten-Dropdown aufzunehmen
|
||||
function addEditNewLocation() {
|
||||
const newLocationInput = document.getElementById('edit-new-location-input');
|
||||
const newLocation = newLocationInput.value.trim();
|
||||
|
||||
if (!newLocation) {
|
||||
alert('Bitte geben Sie einen Ort ein.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Füge Option dem Dropdown hinzu
|
||||
const ortSelect = document.getElementById('editLibraryLocation');
|
||||
const option = document.createElement('option');
|
||||
option.value = newLocation;
|
||||
option.textContent = newLocation;
|
||||
ortSelect.appendChild(option);
|
||||
|
||||
// Wähle die neue Option direkt aus
|
||||
ortSelect.value = newLocation;
|
||||
|
||||
// Verstecke die Eingabemaske wieder
|
||||
cancelEditAddLocation();
|
||||
}
|
||||
|
||||
// Funktion zum Abbrechen der Orteingabe
|
||||
function cancelEditAddLocation() {
|
||||
const container = document.getElementById('edit-new-location-container');
|
||||
if(container) container.style.display = 'none';
|
||||
|
||||
const input = document.getElementById('edit-new-location-input');
|
||||
if(input) input.value = '';
|
||||
function openEditLibraryItem(itemId) {
|
||||
window.location.href = `/item_edit/${itemId}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="editLibraryModal" class="modal" style="display:none;">
|
||||
<div class="modal-content" style="max-width: 760px; padding: 25px; border-radius: 8px;">
|
||||
<span class="close" onclick="closeEditLibraryModal()" style="cursor: pointer; float: right; font-size: 24px;">×</span>
|
||||
<h3 style="margin-top:0;">Bibliotheksmedium bearbeiten</h3>
|
||||
|
||||
<!-- Bereich für Gruppen-Informationen (Hier konsolidiert!) -->
|
||||
<div id="editLibraryGroupWarning" style="display:none; background-color: #fff; padding: 15px; border-radius: 6px; margin-bottom: 20px; border: 1px solid #0ea5e9;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 10px;">
|
||||
<strong style="color: #0ea5e9;">Gruppen-Range (Total: <span id="editLibraryGroupCount"></span>)</strong>
|
||||
</div>
|
||||
|
||||
<p id="editLibraryGroupHint" style="margin: 5px 0; font-size: 12px; color: #555;">
|
||||
Änderungen an Titel, Ort und Beschreibung werden auf alle Exemplare der Gruppe übertragen.
|
||||
</p>
|
||||
|
||||
<div style="margin-top: 15px; font-size: 11px; background: #e0f2fe; padding: 8px; border-radius: 4px;">
|
||||
<strong>Hinweis:</strong> Jeder Mediencode wird einzeln gespeichert, damit alle Exemplare der Gruppe korrekt bleiben.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="editLibraryForm">
|
||||
<input type="hidden" id="editLibraryItemId">
|
||||
<div class="edit-grid">
|
||||
<div class="full">
|
||||
<label for="editLibraryName">Titel</label>
|
||||
<input id="editLibraryName" required style="width: 100%;">
|
||||
</div>
|
||||
<div>
|
||||
<label for="editLibraryType">Medientyp</label>
|
||||
<select id="editLibraryType" style="width: 100%;">
|
||||
<option value="Buch">Buch</option>
|
||||
<option value="Schulbuch">Schulbuch</option>
|
||||
<option value="cd">CD</option>
|
||||
<option value="dvd">DVD</option>
|
||||
<option value="other">Sonstige Medien</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="editLibraryIsbn">ISBN</label>
|
||||
<input id="editLibraryIsbn" placeholder="optional ISBN-10/13" style="width: 100%;">
|
||||
</div>
|
||||
<div>
|
||||
<label>Mediencodes</label>
|
||||
<div id="editLibraryCodesContainer"></div>
|
||||
</div>
|
||||
|
||||
<!-- NEUER BEREICH FÜR DIE ORTS-AUSWAHL -->
|
||||
<div class="full form-group">
|
||||
<label for="editLibraryLocation">Ort</label>
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 5px;">
|
||||
<select id="editLibraryLocation" required style="flex-grow: 1; padding: 8px;">
|
||||
<option value="">-- Bitte Ort auswählen --</option>
|
||||
<!-- Options will be loaded by JavaScript -->
|
||||
</select>
|
||||
<button type="button" class="button" id="edit-add-new-location-btn" onclick="document.getElementById('edit-new-location-container').style.display = 'flex';" style="white-space: nowrap;">
|
||||
Neuen Ort hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
<div id="edit-new-location-container" class="edit-new-location-container" style="display: none; gap: 10px; margin-top: 5px;">
|
||||
<input type="text" id="edit-new-location-input" placeholder="Neuen Ort eingeben" style="flex-grow: 1; padding: 8px;">
|
||||
<button type="button" class="button" onclick="addEditNewLocation()" style="background:#10b981; color:#fff;">Hinzufügen</button>
|
||||
<button type="button" class="button" onclick="cancelEditAddLocation()" style="background:#ef4444; color:#fff;">Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ENDE ORTS-AUSWAHL -->
|
||||
|
||||
<div class="full">
|
||||
<label for="editLibraryDescription">Beschreibung</label>
|
||||
<textarea id="editLibraryDescription" rows="4" required style="width: 100%;"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-actions" style="margin-top:20px;">
|
||||
<button type="submit" class="button" style="background:#0ea5e9;color:#fff;">Speichern & Synchronisieren</button>
|
||||
<button type="button" class="button" onclick="closeEditLibraryModal()">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user