Kgshop commited on
Commit
f0c25a4
·
verified ·
1 Parent(s): aa625f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -14
app.py CHANGED
@@ -503,13 +503,13 @@ CATALOG_TEMPLATE = '''
503
  <div class="product-info">
504
  <h2>{{ product['name'] }}</h2>
505
  <div class="price-container">
506
- <span class="product-price-line">{{ "%.2f"|format(product['price']) }} {{ currency_code }}</span>
507
- <span class="product-price-piece">
508
- {% if product.get('items_per_line', 0) > 1 %}
509
- {{ "%.2f"|format(product['price'] / product.get('items_per_line')) }} {{ currency_code }} / {{ _('price_per_piece') }}
510
- ({{ product.get('items_per_line') }} {{ _('items_in_line') }})
511
- {% endif %}
512
- </span>
513
  </div>
514
  <div class="product-colors">
515
  {% set colors = product.get('colors', [])|select('ne', '')|list %}
@@ -1072,12 +1072,16 @@ PRODUCT_DETAIL_TEMPLATE = '''
1072
 
1073
  <div style="margin-top: 20px; font-size: 1rem; line-height: 1.8;">
1074
  <p><strong>{{ _('category') }}</strong> {{ product.get('category', _('no_category')) }}</p>
1075
- <p style="font-size: 1.4rem; font-weight: bold; color: var(--primary-accent);">
1076
- <strong>{{ _('price') }}</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}
1077
- </p>
1078
- {% if product.get('items_per_line', 0) > 1 %}
1079
  <p style="font-size: 1rem; color: var(--text-muted); margin-top: -10px; margin-bottom: 15px;">
1080
- {{ "%.2f"|format(product['price'] / product.get('items_per_line')) }} {{ currency_code }} / {{ _('price_per_piece') }} ({{ product.get('items_per_line') }} {{ _('items_in_line') }})
 
 
 
 
1081
  </p>
1082
  {% endif %}
1083
  <p><strong>{{ _('description') }}</strong><br> {{ product.get('description', _('no_description'))|replace('\\n', '<br>')|safe }}</p>
@@ -1377,6 +1381,10 @@ ADMIN_TEMPLATE = '''
1377
 
1378
  <div class="section">
1379
  <h2><i class="fas fa-box-open"></i> Управление товарами</h2>
 
 
 
 
1380
  <details>
1381
  <summary><i class="fas fa-plus-circle"></i> Добавить новый товар</summary>
1382
  <div class="form-content">
@@ -1424,9 +1432,9 @@ ADMIN_TEMPLATE = '''
1424
 
1425
  <h3>Список товаров:</h3>
1426
  {% if products %}
1427
- <div class="item-list">
1428
  {% for product in products %}
1429
- <div class="item">
1430
  <div style="display: flex; gap: 15px; align-items: flex-start;">
1431
  <div class="photo-preview" style="flex-shrink: 0;">
1432
  {% if product.get('photos') %}
@@ -1582,6 +1590,20 @@ ADMIN_TEMPLATE = '''
1582
  console.warn("Could not find parent .color-input-group for remove button");
1583
  }
1584
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1585
  </script>
1586
  </body>
1587
  </html>
 
503
  <div class="product-info">
504
  <h2>{{ product['name'] }}</h2>
505
  <div class="price-container">
506
+ {% if product.get('items_per_line', 1) > 1 %}
507
+ <span class="product-price-line">{{ "%.2f"|format(product['price'] / product.get('items_per_line')) }} {{ currency_code }}</span>
508
+ <span class="product-price-piece">{{ _('price_per_piece') }} / {{ "%.2f"|format(product['price']) }} {{ _('price_per_line') }}</span>
509
+ {% else %}
510
+ <span class="product-price-line">{{ "%.2f"|format(product['price']) }} {{ currency_code }}</span>
511
+ <span class="product-price-piece">{{ _('price_per_piece') }}</span>
512
+ {% endif %}
513
  </div>
514
  <div class="product-colors">
515
  {% set colors = product.get('colors', [])|select('ne', '')|list %}
 
1072
 
1073
  <div style="margin-top: 20px; font-size: 1rem; line-height: 1.8;">
1074
  <p><strong>{{ _('category') }}</strong> {{ product.get('category', _('no_category')) }}</p>
1075
+ {% if product.get('items_per_line', 1) > 1 %}
1076
+ <p style="font-size: 1.4rem; font-weight: bold; color: var(--primary-accent);">
1077
+ <strong>{{ _('price_per_piece') }}:</strong> {{ "%.2f"|format(product['price'] / product.get('items_per_line')) }} {{ currency_code }}
1078
+ </p>
1079
  <p style="font-size: 1rem; color: var(--text-muted); margin-top: -10px; margin-bottom: 15px;">
1080
+ ({{ _('price_per_line') }}: {{ "%.2f"|format(product['price']) }} {{ currency_code }} - {{ product.get('items_per_line') }} {{ _('items_in_line') }})
1081
+ </p>
1082
+ {% else %}
1083
+ <p style="font-size: 1.4rem; font-weight: bold; color: var(--primary-accent);">
1084
+ <strong>{{ _('price') }}</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}
1085
  </p>
1086
  {% endif %}
1087
  <p><strong>{{ _('description') }}</strong><br> {{ product.get('description', _('no_description'))|replace('\\n', '<br>')|safe }}</p>
 
1381
 
1382
  <div class="section">
1383
  <h2><i class="fas fa-box-open"></i> Управление товарами</h2>
1384
+ <div style="margin-bottom: 20px;">
1385
+ <label for="admin-product-search" style="font-weight: 600;">Поиск по товарам:</label>
1386
+ <input type="text" id="admin-product-search" placeholder="Введите название товара для поиска..." onkeyup="filterAdminProducts()">
1387
+ </div>
1388
  <details>
1389
  <summary><i class="fas fa-plus-circle"></i> Добавить новый товар</summary>
1390
  <div class="form-content">
 
1432
 
1433
  <h3>Список товаров:</h3>
1434
  {% if products %}
1435
+ <div class="item-list" id="admin-product-list">
1436
  {% for product in products %}
1437
+ <div class="item" data-product-name="{{ product.name|lower }}">
1438
  <div style="display: flex; gap: 15px; align-items: flex-start;">
1439
  <div class="photo-preview" style="flex-shrink: 0;">
1440
  {% if product.get('photos') %}
 
1590
  console.warn("Could not find parent .color-input-group for remove button");
1591
  }
1592
  }
1593
+ function filterAdminProducts() {
1594
+ const searchTerm = document.getElementById('admin-product-search').value.toLowerCase().trim();
1595
+ const productItems = document.querySelectorAll('#admin-product-list .item');
1596
+ let visibleCount = 0;
1597
+ productItems.forEach(item => {
1598
+ const productName = item.getAttribute('data-product-name');
1599
+ if (productName.includes(searchTerm)) {
1600
+ item.style.display = 'block';
1601
+ visibleCount++;
1602
+ } else {
1603
+ item.style.display = 'none';
1604
+ }
1605
+ });
1606
+ }
1607
  </script>
1608
  </body>
1609
  </html>