feat(products): улучшить интерфейс массовой синхронизации с Recommerce

- Добавить секцию маркетинговых флагов в модалку синхронизации
- Добавить кнопки "Выбрать все" для групп полей
- Улучшить UX отображения списка товаров

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-13 13:21:08 +03:00
parent 3cffa9b05d
commit 36090382c1
5 changed files with 269 additions and 95 deletions

View File

@@ -12,7 +12,7 @@
// DOM elements
const selectAllCheckbox = document.getElementById('select-all-checkbox');
const batchActionsBtn = document.getElementById('batch-actions-btn');
const batchActionsDropdown = document.getElementById('batch-actions-dropdown');
const batchActionsWrapper = document.getElementById('batch-actions-wrapper');
let selectionCountSpan = document.getElementById('selection-count');
/**
@@ -138,17 +138,23 @@
const shouldEnable = count > 0;
if (batchActionsBtn) {
batchActionsBtn.disabled = !shouldEnable;
// Управляем подсказкой через data-атрибут
if (batchActionsWrapper) {
if (shouldEnable) {
batchActionsWrapper.removeAttribute('data-hint');
} else {
batchActionsWrapper.setAttribute('data-hint', 'true');
}
}
// Если в кнопке нет span#selection-count, значит текст был изменён - восстанавливаем
if (!batchActionsBtn.querySelector('#selection-count')) {
batchActionsBtn.innerHTML = `<i class="bi bi-gear-fill"></i> Действия над выбранными (<span id="selection-count">${count}</span>)`;
selectionCountSpan = document.getElementById('selection-count');
}
}
if (batchActionsDropdown) {
batchActionsDropdown.disabled = !shouldEnable;
}
// Показываем/скрываем dropdown для выбора всех
const selectAllDropdown = document.getElementById('select-all-dropdown-group');
if (selectAllDropdown) {

View File

@@ -62,6 +62,11 @@ document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('syncContent').checked) options.fields.push('content');
if (document.getElementById('syncImages').checked) options.fields.push('images');
// Маркетинговые флаги
if (document.getElementById('syncIsNew')?.checked) options.fields.push('is_new');
if (document.getElementById('syncIsPopular')?.checked) options.fields.push('is_popular');
if (document.getElementById('syncIsSpecial')?.checked) options.fields.push('is_special');
// Блокируем кнопку
startBtn.disabled = true;
const originalText = startBtn.innerHTML;
@@ -125,4 +130,24 @@ document.addEventListener('DOMContentLoaded', function() {
}
return cookieValue;
}
// Кнопки "Выбрать все" для групп полей
document.getElementById('toggleBasicFields')?.addEventListener('click', function() {
const check = !this.dataset.allSelected || this.dataset.allSelected === 'false';
this.dataset.allSelected = check;
this.textContent = check ? 'Снять все' : 'Выбрать все';
document.getElementById('syncPrice').checked = check;
document.getElementById('syncStock').checked = check;
document.getElementById('syncContent').checked = check;
document.getElementById('syncImages').checked = check;
});
document.getElementById('toggleMarketingFields')?.addEventListener('click', function() {
const check = !this.dataset.allSelected || this.dataset.allSelected === 'false';
this.dataset.allSelected = check;
this.textContent = check ? 'Снять все' : 'Выбрать все';
document.getElementById('syncIsNew').checked = check;
document.getElementById('syncIsPopular').checked = check;
document.getElementById('syncIsSpecial').checked = check;
});
});