fix(shop): форма товара скроллится в видимую область + тип «Фон» вместо мёртвого «Тема»

- shopAdminCreateItem/EditItem открывали форму под таблицей на 51 строку —
  вне экрана, выглядело как «кнопки не работают». Добавлен showShopForm():
  scrollIntoView + фокус в поле названия.
- В выпадающем списке типов «Тема» (theme) не поддерживается бэкендом
  (валидация POST: frame/title/effect/background) → создание падало с 400.
  Заменён на рабочий «Фон» (background); добавлена подпись в typeLabels.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-06-03 14:02:05 +03:00
parent d9a89296de
commit 78a870ab70
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -48,7 +48,7 @@
function renderShopItems() {
const body = document.getElementById('shop-items-body');
if (!_shopItems.length) { body.innerHTML = '<tr><td colspan="7" class="empty">Нет товаров</td></tr>'; return; }
const typeLabels = { frame:'Рамка', title:'Титул', theme:'Тема', effect:'Эффект' };
const typeLabels = { frame:'Рамка', title:'Титул', theme:'Тема', effect:'Эффект', background:'Фон' };
body.innerHTML = _shopItems.map(it => `<tr>
<td>${it.id}</td>
<td><strong>${esc(it.name)}</strong></td>
@@ -69,6 +69,13 @@
if (window.lucide) lucide.createIcons();
}
function showShopForm() {
const form = document.getElementById('shop-item-form');
form.style.display = '';
form.scrollIntoView({ behavior: 'smooth', block: 'center' });
document.getElementById('shop-f-name').focus();
}
function shopAdminCreateItem() {
_shopEditId = null;
document.getElementById('shop-form-title').textContent = 'Добавить товар';
@@ -79,7 +86,7 @@
document.getElementById('shop-f-icon').value = '';
document.getElementById('shop-f-data').value = '';
document.getElementById('shop-f-active').checked = true;
document.getElementById('shop-item-form').style.display = '';
showShopForm();
}
function shopAdminEditItem(id) {
@@ -94,7 +101,7 @@
document.getElementById('shop-f-icon').value = it.icon || '';
document.getElementById('shop-f-data').value = it.data ? (typeof it.data === 'string' ? it.data : JSON.stringify(it.data)) : '';
document.getElementById('shop-f-active').checked = !!it.is_active;
document.getElementById('shop-item-form').style.display = '';
showShopForm();
}
function shopAdminCancelForm() {