Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9452743660 |
+17
-18
@@ -6383,8 +6383,8 @@ def is_library_item(item):
|
||||
@app.route('/item_edit/<id>', methods=['GET', 'POST'])
|
||||
def item_edit(id):
|
||||
"""
|
||||
Complete endpoint for editing items. Automatically detects whether the item
|
||||
is a Library item (ItemType != 'other') or an Inventory item (ItemType == 'other').
|
||||
Complete endpoint for editing items. Processes Filters 1-3 for ALL items,
|
||||
and applies Library-specific fields when the item is a Library item.
|
||||
"""
|
||||
if 'username' not in session:
|
||||
if request.method == 'POST' and request.is_json:
|
||||
@@ -6410,7 +6410,7 @@ def item_edit(id):
|
||||
flash('Element in der Datenbank nicht gefunden.', 'error')
|
||||
return redirect(url_for('home_admin'))
|
||||
|
||||
# Determine item type classification
|
||||
# Determine item classification
|
||||
library_module_active = cfg.MODULES.is_enabled('library')
|
||||
is_lib_item = it.is_library_item(current_item)
|
||||
show_library_features = library_module_active and is_lib_item
|
||||
@@ -6457,7 +6457,12 @@ def item_edit(id):
|
||||
anschaffungs_kosten = sanitize_form_value(request.form.get('anschaffungskosten'))
|
||||
reservierbar = 'reservierbar' in request.form
|
||||
|
||||
# Barcodes
|
||||
# System Filters 1, 2, and 3 (Processed for ALL items)
|
||||
filter1 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter')), 1)
|
||||
filter2 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter2')), 2)
|
||||
filter3 = sanitize_form_value(request.form.getlist('filter3'))
|
||||
|
||||
# Barcodes & Group Codes
|
||||
code_4 = sanitize_form_value(request.form.get('code_4'))
|
||||
individual_codes_raw = request.form.get('individual_codes', '')
|
||||
|
||||
@@ -6494,26 +6499,18 @@ def item_edit(id):
|
||||
|
||||
# Type-specific processing
|
||||
if show_library_features:
|
||||
# --- LIBRARY ITEM ---
|
||||
# --- LIBRARY ITEM SPECIFICS ---
|
||||
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
||||
item_isbn = normalize_and_validate_isbn(isbn_raw) if isbn_raw else ''
|
||||
item_type = sanitize_form_value(request.form.get('item_type_input', 'Buch'))
|
||||
library_category = sanitize_form_value(request.form.get('library_category', ''))
|
||||
|
||||
filter1 = current_item.get('Filter', [])
|
||||
filter2 = current_item.get('Filter2', [])
|
||||
filter3 = current_item.get('Filter3', [])
|
||||
images = current_item.get('Images', [])
|
||||
else:
|
||||
# --- INVENTORY ITEM ---
|
||||
# --- INVENTORY ITEM SPECIFICS ---
|
||||
item_isbn = current_item.get('ISBN', '')
|
||||
item_type = 'other' # Standard type for inventory items
|
||||
item_type = 'other'
|
||||
library_category = current_item.get('library_category', '')
|
||||
|
||||
filter1 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter')), 1)
|
||||
filter2 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter2')), 2)
|
||||
filter3 = sanitize_form_value(request.form.getlist('filter3'))
|
||||
|
||||
# Manage images for Inventory Mode
|
||||
images_to_keep = request.form.getlist('existing_images')
|
||||
original_images = current_item.get('Images', [])
|
||||
@@ -6555,14 +6552,14 @@ def item_edit(id):
|
||||
except Exception as e:
|
||||
app.logger.error(f"Image error for item {id}: {e}")
|
||||
|
||||
# Auto-add new location to predefined locations list if applicable
|
||||
# Auto-add location to predefined locations list if applicable
|
||||
if ort and ort not in it.get_predefined_locations():
|
||||
it.add_predefined_location(ort)
|
||||
|
||||
# Sync series/group barcode IDs
|
||||
# Sync group barcodes
|
||||
it.sync_group_codes(str(id), code_4, individual_codes)
|
||||
|
||||
# Update item in database
|
||||
# Save to MongoDB
|
||||
success = it.update_item(
|
||||
id=str(id),
|
||||
name=name,
|
||||
@@ -6588,6 +6585,8 @@ def item_edit(id):
|
||||
flash('Fehler beim Aktualisieren des Artikels.', 'error')
|
||||
|
||||
return redirect(redirect_target)
|
||||
|
||||
|
||||
@app.route('/update_group', methods=['POST'])
|
||||
def update_group():
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
/* Scanner Video Canvas */
|
||||
/* Scanner Elements */
|
||||
#code4-scanner video, #code4-scanner canvas,
|
||||
#isbn-scanner video, #isbn-scanner canvas {
|
||||
width: 100%;
|
||||
@@ -197,7 +197,7 @@
|
||||
<input type="hidden" name="item_id" value="{{ item._id }}">
|
||||
|
||||
{% if show_library_features %}
|
||||
<!-- ================= LIBRARY MODE FIELDS ================= -->
|
||||
<!-- ================= LIBRARY SPECIFIC FIELDS ================= -->
|
||||
<div class="form-group">
|
||||
<label for="isbn">ISBN / Barcode:</label>
|
||||
<div class="isbn-input-group">
|
||||
@@ -209,9 +209,26 @@
|
||||
<small id="isbn-scan-status" style="display:block; color:#666; margin-top:6px;"></small>
|
||||
<div id="book-info-container"></div>
|
||||
</div>
|
||||
|
||||
<div class="filter-inputs" style="margin-bottom: 20px;">
|
||||
<h3>Medientyp</h3>
|
||||
<div class="form-group">
|
||||
<select name="item_type_input" id="item_type_input">
|
||||
<option value="Buch" {% if item.ItemType == 'Buch' %}selected{% endif %}>Buch</option>
|
||||
<option value="Schulbuch" {% if item.ItemType == 'Schulbuch' %}selected{% endif %}>Schulbuch</option>
|
||||
<option value="CD" {% if item.ItemType == 'CD' %}selected{% endif %}>CD</option>
|
||||
<option value="DVD" {% if item.ItemType == 'DVD' %}selected{% endif %}>DVD</option>
|
||||
<option value="Sonstiges" {% if item.ItemType == 'Sonstiges' %}selected{% endif %}>Sonstiges</option>
|
||||
</select>
|
||||
</div>
|
||||
<h3>Bibliotheks-Kategorie:</h3>
|
||||
<div class="form-group">
|
||||
<input type="text" name="library_category" id="library_category" value="{{ item.library_category|default('') }}" placeholder="z.B. Belletristik, Sachbücher, etc.">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- ================= COMMON FIELDS ================= -->
|
||||
<!-- ================= COMMON CORE FIELDS ================= -->
|
||||
<div class="form-group">
|
||||
<label for="name">Name / Titel:</label>
|
||||
<input type="text" id="name" name="name" value="{{ item.Name|default('') }}" required>
|
||||
@@ -254,26 +271,7 @@
|
||||
<small style="display:block; color:#666; margin-top: 5px;">Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.</small>
|
||||
</div>
|
||||
|
||||
{% if show_library_features %}
|
||||
<!-- ================= LIBRARY CATEGORIZATION ================= -->
|
||||
<div class="filter-inputs">
|
||||
<h3>Medientyp</h3>
|
||||
<div class="form-group">
|
||||
<select name="item_type_input" id="item_type_input">
|
||||
<option value="Buch" {% if item.ItemType == 'Buch' %}selected{% endif %}>Buch</option>
|
||||
<option value="Schulbuch" {% if item.ItemType == 'Schulbuch' %}selected{% endif %}>Schulbuch</option>
|
||||
<option value="CD" {% if item.ItemType == 'CD' %}selected{% endif %}>CD</option>
|
||||
<option value="DVD" {% if item.ItemType == 'DVD' %}selected{% endif %}>DVD</option>
|
||||
<option value="Sonstiges" {% if item.ItemType == 'Sonstiges' %}selected{% endif %}>Sonstiges</option>
|
||||
</select>
|
||||
</div>
|
||||
<h3>Kategorie / Fach:</h3>
|
||||
<div class="form-group">
|
||||
<input type="text" name="library_category" id="library_category" value="{{ item.library_category|default('') }}" placeholder="z.B. Belletristik, Sachbücher, etc.">
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<!-- ================= INVENTORY FILTERS (1-3) ================= -->
|
||||
<!-- ================= SYSTEM FILTERS 1-3 (ALWAYS AVAILABLE) ================= -->
|
||||
<div class="filter-inputs">
|
||||
<h3>Unterrichtsfach (Filter 1):</h3>
|
||||
<div class="multi-filter">
|
||||
@@ -309,7 +307,6 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- ================= DATES & FINANCIALS ================= -->
|
||||
<div class="form-group">
|
||||
@@ -358,13 +355,12 @@
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2/dist/quagga.js"></script>
|
||||
<script>
|
||||
const libraryModuleEnabled = {{ 'true' if show_library_features else 'false' }};
|
||||
let scannerRunning = false;
|
||||
let activeScannerCallback = null;
|
||||
let code4LastScanned = '';
|
||||
let code4LastScannedAt = 0;
|
||||
|
||||
// Load filter dropdown options and pre-select current item values
|
||||
// Load filter dropdown options and select current values
|
||||
function loadAndSelectFilterValues(filterNumber) {
|
||||
fetch(`/get_predefined_filter_values/${filterNumber}`)
|
||||
.then(res => res.json())
|
||||
@@ -383,7 +379,6 @@
|
||||
select.appendChild(opt);
|
||||
});
|
||||
|
||||
// Add custom option if the item has a value not in predefined list
|
||||
if (selectedValue && !Array.from(select.options).some(o => o.value === selectedValue)) {
|
||||
const customOpt = document.createElement('option');
|
||||
customOpt.value = selectedValue;
|
||||
@@ -397,7 +392,6 @@
|
||||
.catch(err => console.error(`Error loading Filter ${filterNumber}:`, err));
|
||||
}
|
||||
|
||||
// Load locations
|
||||
function loadLocationOptions() {
|
||||
fetch('/get_predefined_locations')
|
||||
.then(res => res.json())
|
||||
@@ -420,7 +414,6 @@
|
||||
.catch(err => console.error('Error loading locations:', err));
|
||||
}
|
||||
|
||||
// New location handler
|
||||
function addNewLocation() {
|
||||
const input = document.getElementById('new-location-input');
|
||||
const val = input.value.trim();
|
||||
@@ -440,7 +433,6 @@
|
||||
document.getElementById('new-location-input').value = '';
|
||||
}
|
||||
|
||||
// Quagga Barcode Scanner Engine
|
||||
function runEngineInitialization(targetSelector, activeCallback, completionMsg, errorStatusSetter) {
|
||||
if (scannerRunning) { Quagga.stop(); scannerRunning = false; }
|
||||
activeScannerCallback = activeCallback;
|
||||
@@ -497,10 +489,9 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadLocationOptions();
|
||||
|
||||
if (!libraryModuleEnabled) {
|
||||
loadAndSelectFilterValues(1);
|
||||
loadAndSelectFilterValues(2);
|
||||
}
|
||||
// Always load Filter 1 and Filter 2 options for all items
|
||||
loadAndSelectFilterValues(1);
|
||||
loadAndSelectFilterValues(2);
|
||||
|
||||
const scanCodeBtn = document.getElementById('scan-code4-btn');
|
||||
if (scanCodeBtn) scanCodeBtn.addEventListener('click', startCode4Scanner);
|
||||
|
||||
Reference in New Issue
Block a user