diff --git a/Web/app.py b/Web/app.py index 2a67695..89a0f82 100755 --- a/Web/app.py +++ b/Web/app.py @@ -6383,8 +6383,8 @@ def is_library_item(item): @app.route('/item_edit/', 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(): diff --git a/Web/templates/edit_library.html b/Web/templates/edit_library.html index 9b4c1ec..1f1bb5d 100644 --- a/Web/templates/edit_library.html +++ b/Web/templates/edit_library.html @@ -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 @@ {% if show_library_features %} - +
@@ -209,9 +209,26 @@
+ +
+

Medientyp

+
+ +
+

Bibliotheks-Kategorie:

+
+ +
+
{% endif %} - +
@@ -254,26 +271,7 @@ Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.
- {% if show_library_features %} - -
-

Medientyp

-
- -
-

Kategorie / Fach:

-
- -
-
- {% else %} - +

Unterrichtsfach (Filter 1):

@@ -309,7 +307,6 @@ {% endfor %}
- {% endif %}
@@ -358,13 +355,12 @@