Fix image display and add AR fields management route
Fixes: 1. Image display - Images now properly display on tenant landing page and edit forms by prepending tenant ID to image paths (/tenant/images/... instead of /images/...) 2. AR fields route - Added /tenant/ar_fields route (without /admin/ prefix) for managing custom AR content fields 3. Template updates - Updated all image src attributes to include tenant prefix for proper routing 4. Navigation - Updated AR fields back button to return to settings page instead of non-existent admin index Images are now visible in: - Product list on tenant landing page - Product edit forms showing current images - Admin index (if accessed)
This commit is contained in:
@@ -295,7 +295,7 @@ def serve_barcode(tenant_id, filename):
|
||||
|
||||
# Import product management routes
|
||||
from routes.admin import (add_product, edit_product, delete_product,
|
||||
generate_barcode, generate_barcode_page)
|
||||
generate_barcode, generate_barcode_page, manage_ar_fields)
|
||||
|
||||
# Register product management routes (remove /admin/ from paths)
|
||||
app.add_url_rule('/<tenant:tenant_id>/add', 'admin.add_product', add_product, methods=['GET', 'POST'])
|
||||
@@ -303,6 +303,7 @@ app.add_url_rule('/<tenant:tenant_id>/edit/<product_id>', 'admin.edit_product',
|
||||
app.add_url_rule('/<tenant:tenant_id>/delete/<product_id>', 'admin.delete_product', delete_product, methods=['POST'])
|
||||
app.add_url_rule('/<tenant:tenant_id>/generate_barcode/<product_id>/<code_type>', 'admin.generate_barcode', generate_barcode)
|
||||
app.add_url_rule('/<tenant:tenant_id>/generate_barcode_page/<product_id>', 'admin.generate_barcode_page', generate_barcode_page)
|
||||
app.add_url_rule('/<tenant:tenant_id>/ar_fields', 'admin.manage_ar_fields', manage_ar_fields, methods=['GET', 'POST'])
|
||||
|
||||
# Register API routes with tenant prefix
|
||||
from routes.api import api_index
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<h1>Manage AR Content Fields</h1>
|
||||
<p>Configure the fields that will be returned by the /arcontentfields and /arinfo endpoints.</p>
|
||||
</div>
|
||||
<a href="{{ url_for('admin.index', tenant_id=tenant_id) }}" class="btn btn-secondary">Back to Admin</a>
|
||||
<a href="/{{ tenant_id }}/settings" class="btn btn-secondary">Back to Settings</a>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4">
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<div class="mt-3">
|
||||
<label class="form-label">Current Image:</label>
|
||||
<div>
|
||||
<img src="{{ current_value }}" alt="Current image" class="image-preview" style="max-width: 200px;">
|
||||
<img src="/{{ tenant_id }}{{ current_value }}" alt="Current image" class="image-preview" style="max-width: 200px;">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
{% if custom_field.fieldType == 'IMAGE_URI' %}
|
||||
{% if field.value %}
|
||||
<div class="product-image-container">
|
||||
<img src="{{ field.value }}" alt="{{ custom_field.label }}" class="product-image">
|
||||
<img src="/{{ tenant.id }}{{ field.value }}" alt="{{ custom_field.label }}" class="product-image">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<tr>
|
||||
<th>Product ID</th>
|
||||
{% for custom_field in custom_fields %}
|
||||
{% if custom_field.fieldName != '_id' and custom_field.fieldType != 'IMAGE_URI' %}
|
||||
{% if custom_field.fieldName != '_id' %}
|
||||
<th>{{ custom_field.label }}</th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -42,10 +42,18 @@
|
||||
<tr>
|
||||
<td>{{ product_id }}</td>
|
||||
{% for custom_field in custom_fields %}
|
||||
{% if custom_field.fieldName != '_id' and custom_field.fieldType != 'IMAGE_URI' %}
|
||||
{% if custom_field.fieldName != '_id' %}
|
||||
<td>
|
||||
{% set matching_fields = product_data|selectattr('fieldName', 'equalto', custom_field.fieldName)|list %}
|
||||
{{ matching_fields[0].value if matching_fields else '' }}
|
||||
{% if custom_field.fieldType == 'IMAGE_URI' %}
|
||||
{% if matching_fields and matching_fields[0].value %}
|
||||
<div class="product-image-container">
|
||||
<img src="/{{ tenant.id }}{{ matching_fields[0].value }}" alt="{{ custom_field.label }}" class="product-image">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ matching_fields[0].value if matching_fields else '' }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="text-muted">Manage the fields that are returned in the AR content API.</p>
|
||||
<a href="/{{ tenant.id }}/admin/ar_fields" class="btn btn-primary">
|
||||
<a href="/{{ tenant.id }}/ar_fields" class="btn btn-primary">
|
||||
<i class="bi bi-gear"></i> Manage AR Fields
|
||||
</a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user