Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c90cef6dcf |
@@ -1578,9 +1578,11 @@
|
|||||||
document.getElementById('editLibraryName').value = item.Name;
|
document.getElementById('editLibraryName').value = item.Name;
|
||||||
document.getElementById('editLibraryType').value = item.ItemType;
|
document.getElementById('editLibraryType').value = item.ItemType;
|
||||||
document.getElementById('editLibraryIsbn').value = item.ISBN || '';
|
document.getElementById('editLibraryIsbn').value = item.ISBN || '';
|
||||||
document.getElementById('editLibraryLocation').value = item.Ort;
|
|
||||||
document.getElementById('editLibraryDescription').value = item.Beschreibung;
|
document.getElementById('editLibraryDescription').value = item.Beschreibung;
|
||||||
|
|
||||||
|
// Orte laden und bestehenden Ort setzen
|
||||||
|
await loadEditLocationOptions(item.Ort);
|
||||||
|
|
||||||
const codesContainer = document.getElementById('editLibraryCodesContainer');
|
const codesContainer = document.getElementById('editLibraryCodesContainer');
|
||||||
if (codesContainer) {
|
if (codesContainer) {
|
||||||
codesContainer.innerHTML = '<div style="padding:10px 0; color:#6b7280;">Lade Codes...</div>';
|
codesContainer.innerHTML = '<div style="padding:10px 0; color:#6b7280;">Lade Codes...</div>';
|
||||||
@@ -1594,6 +1596,87 @@
|
|||||||
|
|
||||||
function closeEditLibraryModal() {
|
function closeEditLibraryModal() {
|
||||||
document.getElementById('editLibraryModal').style.display = 'none';
|
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 = '';
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -1642,10 +1725,27 @@
|
|||||||
<label>Mediencodes</label>
|
<label>Mediencodes</label>
|
||||||
<div id="editLibraryCodesContainer"></div>
|
<div id="editLibraryCodesContainer"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="full">
|
|
||||||
|
<!-- NEUER BEREICH FÜR DIE ORTS-AUSWAHL -->
|
||||||
|
<div class="full form-group">
|
||||||
<label for="editLibraryLocation">Ort</label>
|
<label for="editLibraryLocation">Ort</label>
|
||||||
<input id="editLibraryLocation" required style="width: 100%;">
|
<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>
|
</div>
|
||||||
|
<!-- ENDE ORTS-AUSWAHL -->
|
||||||
|
|
||||||
<div class="full">
|
<div class="full">
|
||||||
<label for="editLibraryDescription">Beschreibung</label>
|
<label for="editLibraryDescription">Beschreibung</label>
|
||||||
<textarea id="editLibraryDescription" rows="4" required style="width: 100%;"></textarea>
|
<textarea id="editLibraryDescription" rows="4" required style="width: 100%;"></textarea>
|
||||||
|
|||||||
Reference in New Issue
Block a user