Compare commits

..

5 Commits

Author SHA1 Message Date
Aiirondev_dev 36ccee38cb Addition of the button as described in the Issue #17
Release Inventarsystem / release-docker (push) Successful in 2m17s
2026-08-10 17:41:18 +02:00
Aiirondev_dev 9255c87f57 Implement ISBN live validation and automatic lookup on input change
Release Inventarsystem / release-docker (push) Successful in 2m15s
2026-08-10 14:16:20 +02:00
Aiirondev_dev a6b246a92b Refactor upload form fields for clarity and enhance focus navigation
Release Inventarsystem / release-docker (push) Successful in 3m15s
2026-08-10 14:10:08 +02:00
Aiirondev_dev 25f52eeeb5 Change sfor the issue #16 with some of the described changes as addtion of a arrow pointig down or the rearange ment done
Release Inventarsystem / release-docker (push) Successful in 2m14s
2026-08-10 00:24:05 +02:00
Aiirondev_dev c07d4e0bdd Changes to match the designated endpoint of the user when uploading an Item to dont have the system Jump between the systems.
Release Inventarsystem / release-docker (push) Successful in 2m19s
2026-08-09 23:59:13 +02:00
4 changed files with 174 additions and 65 deletions
View File
+2 -6
View File
@@ -5177,17 +5177,13 @@ def upload_item():
fs = get_gridfs()
can_access_admin_home = _page_access_allowed(permissions, 'home_admin') and _action_access_allowed(permissions, 'can_manage_settings')
if can_access_admin_home:
success_redirect_endpoint = 'home_admin'
elif cfg.MODULES.is_enabled('library') and _page_access_allowed(permissions, 'home_library'):
success_redirect_endpoint = 'home_library'
if cfg.MODULES.is_enabled('library') and sanitize_form_value(request.form.get('item_type_input', '')) != "other":
success_redirect_endpoint = 'library'
else:
success_redirect_endpoint = 'home_admin'
# Detect if request is from mobile device
is_mobile = 'Mobile' in request.headers.get('User-Agent', '')
is_ios = 'iPhone' in request.headers.get('User-Agent', '') or 'iPad' in request.headers.get('User-Agent', '')
# Log mobile request for debugging
if is_mobile:
+166 -59
View File
@@ -761,6 +761,21 @@
<h1>{{ page_title|default('Artikel hochladen') }}</h1>
<form method="POST" action="{{ url_for('upload_item') }}" enctype="multipart/form-data">
<input type="hidden" name="upload_mode" value="{{ upload_mode|default('item') }}">
{% if show_library_features %}
<div class="form-group">
<label for="isbn">ISBN/Barcode (für Bild-Suche):</label>
<div class="isbn-input-group">
<input type="text" id="isbn" name="isbn" placeholder="ISBN oder Barcode eingeben..." required>
<button type="button" id="scan-isbn-btn" class="fetch-isbn-button">Barcode scannen</button>
<button type="button" class="fetch-isbn-button" onclick="fetchBookInfo('upload')">Informationen abrufen</button>
</div>
<div id="isbn-scanner" style="width:100%; max-width:520px; display:none; margin-top:10px;"></div>
<small id="isbn-scan-status" style="display:block; color:#666; margin-top:6px;">Scannen oder manuell eingeben. Gültige ISBNs helfen beim Abruf von Buchdaten, andere Codes werden trotzdem akzeptiert.</small>
<div id="book-info-container" class="book-info-container"></div>
</div>
{% endif %}
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
@@ -784,7 +799,44 @@
<label for="beschreibung">Beschreibung:</label>
<textarea id="beschreibung" name="beschreibung" required></textarea>
</div>
<div class="form-group">
<label for="scan_mode">Erfassungs-Modus:</label>
<select id="scan_mode" name="scan_mode" class="form-control" onchange="toggleScanMode()">
<option value="single">Einzel-Code (Scanner stoppt nach 1 Scan) ↓ </option>
<option value="continuous">Fortlaufend scannen (Mehrere Codes nacheinander)</option>
<option value="range">Code-Bereich generieren (z.B. ABC-001 bis ABC-010)</option>
</select>
</div>
<div id="range_generator_group" class="form-group" style="display:none; background: #f9f9f9; padding: 15px; border-radius: 5px; border: 1px solid #ddd; margin-bottom: 15px;">
<label style="font-weight: bold;">Code-Bereich automatisch generieren:</label>
<div style="display: flex; gap: 10px; margin-bottom: 10px; align-items: center;">
<input type="text" id="range_prefix" placeholder="Präfix optional (z.B. IT-)" class="form-control" style="flex: 2;">
<input type="number" id="range_start" placeholder="Start (z.B. 1)" class="form-control" style="flex: 1;">
<span style="font-weight: bold;">bis</span>
<input type="text" id="range_end" placeholder="Ende (z.B. 020)" class="form-control" style="flex: 1;">
</div>
<small style="display:block; color:#666; margin-bottom: 10px;">Tipp: Der Präfix ist optional. Die Anzahl der Ziffern im "Ende"-Feld bestimmt die führenden Nullen (z.B. Ende "050" macht aus Start "1" einen "001").</small>
<button type="button" class="btn btn-secondary" onclick="generateCodeRange()">Bereich generieren & einfügen</button>
</div>
<div class="form-group" id="primary_code_group">
<label for="code_4">Basis-Code</label>
<div style="display: flex; gap: 10px;">
<input type="text" id="code_4" name="code_4" class="form-control" placeholder="Haupt-Barcode" required>
<button type="button" id="scan-code4-btn" class="btn btn-primary">Barcode scannen</button>
</div>
<div id="code4-scanner" style="display:none; margin-top: 10px;"></div>
<small id="code4-scan-status" class="form-text text-muted"></small>
</div>
<div class="form-group" id="individual_codes_group">
<label for="individual_codes">Weitere Einzelcodes (je Zeile ein Code)</label>
<textarea id="individual_codes" name="individual_codes" rows="6" placeholder="z.B.&#10;ABC-001&#10;ABC-002" class="form-control"></textarea>
<small style="display:block; color:#666; margin-top: 5px;">Bei Anzahl > 1 können hier individuelle Codes pro Item gesetzt werden. Der Scanner setzt immer zuerst den Basis-Code im Feld oben; weitere Einzelcodes werden hier angehängt.</small>
</div>
{% if show_library_features %}
<!-- Library Mode: Single Customizable Filter -->
<div class="filter-inputs">
@@ -800,9 +852,9 @@
</select>
<small style="display:block; color:#666;">Wählen Sie einen Medientyp aus zur Klassifizierung.</small>
</div>
<h3>Kategorie/Typ:</h3>
<h3>Kategorie/Typ/Fach:</h3>
<div class="form-group">
<input type="text" name="library_category" id="library_category" placeholder="z.B. Belletristik, Sachbücher, Nachschlagewerke, etc.">
<input type="text" name="library_category" id="library_category" placeholder="z.B. Belletristik, Sachbücher, Nachschlagewerke, etc. (optional)">
<small style="display:block; color:#666;">Geben Sie hier eine beliebige Kategorie ein zur freien Klassifizierung.</small>
</div>
</div>
@@ -902,42 +954,6 @@
<label for="anschaffungskosten">Anschaffungskosten (€)</label>
<input id="anschaffungskosten" name="anschaffungskosten">
</div>
<div class="form-group">
<label for="scan_mode">Erfassungs-Modus:</label>
<select id="scan_mode" name="scan_mode" class="form-control" onchange="toggleScanMode()">
<option value="single">Einzel-Code (Scanner stoppt nach 1 Scan)</option>
<option value="continuous">Fortlaufend scannen (Mehrere Codes nacheinander)</option>
<option value="range">Code-Bereich generieren (z.B. ABC-001 bis ABC-010)</option>
</select>
</div>
<div id="range_generator_group" class="form-group" style="display:none; background: #f9f9f9; padding: 15px; border-radius: 5px; border: 1px solid #ddd; margin-bottom: 15px;">
<label style="font-weight: bold;">Code-Bereich automatisch generieren:</label>
<div style="display: flex; gap: 10px; margin-bottom: 10px; align-items: center;">
<input type="text" id="range_prefix" placeholder="Präfix (z.B. IT-)" class="form-control" style="flex: 2;">
<input type="number" id="range_start" placeholder="Start (z.B. 1)" class="form-control" style="flex: 1;">
<span style="font-weight: bold;">bis</span>
<input type="text" id="range_end" placeholder="Ende (z.B. 020)" class="form-control" style="flex: 1;">
</div>
<small style="display:block; color:#666; margin-bottom: 10px;">Tipp: Die Anzahl der Ziffern im "Ende"-Feld bestimmt die führenden Nullen (z.B. Ende "050" macht aus Start "1" einen "001").</small>
<button type="button" class="btn btn-secondary" onclick="generateCodeRange()">Bereich generieren & einfügen</button>
</div>
<div class="form-group" id="primary_code_group">
<label for="code_4">Basis-Code</label>
<div style="display: flex; gap: 10px;">
<input type="text" id="code_4" name="code_4" class="form-control" placeholder="Haupt-Barcode" required>
<button type="button" id="scan-code4-btn" class="btn btn-primary">Barcode scannen</button>
</div>
<div id="code4-scanner" style="display:none; margin-top: 10px;"></div>
<small id="code4-scan-status" class="form-text text-muted"></small>
</div>
<div class="form-group" id="individual_codes_group">
<label for="individual_codes">Weitere Einzelcodes (je Zeile ein Code)</label>
<textarea id="individual_codes" name="individual_codes" rows="6" placeholder="z.B.&#10;ABC-001&#10;ABC-002" class="form-control"></textarea>
<small style="display:block; color:#666; margin-top: 5px;">Bei Anzahl > 1 können hier individuelle Codes pro Item gesetzt werden. Der Scanner setzt immer zuerst den Basis-Code im Feld oben; weitere Einzelcodes werden hier angehängt.</small>
</div>
<!-- Image upload (hidden for library mode) -->
<div class="form-group" {% if show_library_features %}style="display:none;"{% endif %}>
<label for="images">Bilder/Videos:</label>
@@ -946,27 +962,12 @@
<!-- Add image preview area -->
<div class="image-preview-container" id="image-preview-container"></div>
</div>
<!-- ISBN fields (library page only) -->
{% if show_library_features %}
<div class="form-group">
<label for="isbn">ISBN/Barcode (für Bild-Suche):</label>
<div class="isbn-input-group">
<input type="text" id="isbn" name="isbn" placeholder="ISBN oder Barcode eingeben..." required>
<button type="button" id="scan-isbn-btn" class="fetch-isbn-button">Barcode scannen</button>
<button type="button" class="fetch-isbn-button" onclick="fetchBookInfo('upload')">Informationen abrufen</button>
</div>
<div id="isbn-scanner" style="width:100%; max-width:520px; display:none; margin-top:10px;"></div>
<small id="isbn-scan-status" style="display:block; color:#666; margin-top:6px;">Scannen oder manuell eingeben. Gültige ISBNs helfen beim Abruf von Buchdaten, andere Codes werden trotzdem akzeptiert.</small>
<div id="book-info-container" class="book-info-container"></div>
</div>
<div class="form-group">
<label for="reservierbar" style="display:inline-block; width:auto; margin-right:10px;">Reservierbar:</label>
<input type="checkbox" id="reservierbar" name="reservierbar" style="width:auto;">
<small style="display:block; color:#666;">Wenn deaktiviert, kann der Artikel nicht im Voraus reserviert werden (Sofort-Ausleihe bleibt möglich).</small>
</div>
{% endif %}
<button type="submit" class="submit-button">{{ 'Bücher hochladen' if show_library_features else 'Artikel hochladen' }}</button>
</form>
@@ -1023,6 +1024,90 @@
<script>
const libraryModuleEnabled = {{ 'true' if library_module_enabled else 'false' }};
function getFocusableFormFields(form) {
if (!form) return [];
return Array.from(form.querySelectorAll('input, select, textarea, button'))
.filter((element) => {
if (element.disabled || element.getAttribute('aria-hidden') === 'true') return false;
const style = window.getComputedStyle(element);
if (style.display === 'none' || style.visibility === 'hidden') return false;
const tagName = element.tagName.toLowerCase();
const type = (element.type || '').toLowerCase();
return tagName !== 'button' || type !== 'button';
});
}
function focusNextFormField(currentField) {
const form = currentField && currentField.form ? currentField.form : null;
const fields = getFocusableFormFields(form || document);
const currentIndex = fields.indexOf(currentField);
if (currentIndex >= 0) {
for (let i = currentIndex + 1; i < fields.length; i++) {
const nextField = fields[i];
const nextStyle = window.getComputedStyle(nextField);
if (nextStyle.display !== 'none' && nextStyle.visibility !== 'hidden') {
nextField.focus();
if (nextField.tagName.toLowerCase() === 'select') {
nextField.click();
}
return true;
}
}
}
if (form) {
const submitButton = form.querySelector('button[type="submit"]');
if (submitButton) {
submitButton.focus();
return true;
}
}
return false;
}
function handleIsbnLookupFromScanner() {
const isbnField = document.getElementById('isbn');
if (!isbnField) return false;
const normalizedIsbn = typeof normalizeIsbnClient === 'function' ? normalizeIsbnClient(isbnField.value) : isbnField.value.trim();
if (!normalizedIsbn) return false;
if (typeof updateIsbnLiveValidation === 'function') {
updateIsbnLiveValidation();
}
if (typeof fetchBookInfo === 'function') {
fetchBookInfo('upload');
}
return true;
}
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('form').forEach(function (form) {
form.addEventListener('keydown', function (event) {
const target = event.target;
if (event.key !== 'Enter') return;
if (!target || target.tagName === 'TEXTAREA' && !event.shiftKey) return;
const tagName = target.tagName.toLowerCase();
const type = (target.type || '').toLowerCase();
if (!['input', 'select', 'textarea'].includes(tagName)) return;
if (['button', 'submit', 'reset', 'file', 'checkbox', 'radio', 'hidden'].includes(type)) return;
event.preventDefault();
if (target.id === 'isbn' || target.name === 'isbn') {
handleIsbnLookupFromScanner();
return;
}
focusNextFormField(target);
});
});
});
// Function to check if a file is a video
function isVideoFile(filename) {
const videoExtensions = ['.mp4', '.mov', '.avi', '.mkv', '.webm', '.flv', '.m4v', '.3gp'];
@@ -1194,7 +1279,7 @@
let generatedCodes = [];
for (let i = start; i <= end; i++) {
let numStr = i.toString().padStart(paddingLength, '0');
generatedCodes.push(`${prefix}${numStr}`);
generatedCodes.push(prefix ? `${prefix}${numStr}` : numStr);
}
const codeField = document.getElementById('code_4');
@@ -1384,10 +1469,32 @@
scanModeSelect.addEventListener('change', toggleScanMode);
}
// 4. ISBN Live-Validierung
// 4. ISBN Live-Validierung und automatische Abfrage nach Scan/Enter
const isbnInput = document.getElementById('isbn');
if (isbnInput && typeof updateIsbnLiveValidation === 'function') {
isbnInput.addEventListener('input', updateIsbnLiveValidation);
if (isbnInput) {
if (typeof updateIsbnLiveValidation === 'function') {
isbnInput.addEventListener('input', updateIsbnLiveValidation);
}
let isbnLookupTimer = null;
isbnInput.addEventListener('input', function () {
clearTimeout(isbnLookupTimer);
const normalizedIsbn = typeof normalizeIsbnClient === 'function' ? normalizeIsbnClient(isbnInput.value) : isbnInput.value.trim();
if (normalizedIsbn) {
isbnLookupTimer = setTimeout(function () {
handleIsbnLookupFromScanner();
}, 250);
}
});
isbnInput.addEventListener('change', function () {
if (typeof normalizeIsbnClient === 'function') {
const normalizedIsbn = normalizeIsbnClient(isbnInput.value);
if (normalizedIsbn) {
handleIsbnLookupFromScanner();
}
}
});
}
});
// Load predefined filter values for dropdowns
+6
View File
@@ -17,6 +17,12 @@
<div class="user-management-container">
<h2>Benutzer</h2>
<div class="mb-3">
<a href="{{ url_for('register') }}" class="btn btn-success">
Neuen Benutzer registrieren
</a>
</div>
<form method="POST" action="{{ url_for('admin_anonymize_names') }}" class="mb-3">
<button
type="submit"