const subcategory = $link.data('subcategory');
const $row = $link.closest('tr');
- // Get filter data
const filters = getFilterData();
filters.month = getMonthByWeek(week, year, true);
filters.category = category;
filters.subcategory = subcategory;
- // Show loading overlay
$('.loader-overlay').removeClass('d-none');
$.ajax({
return;
}
- // Generate title string function
- const generateTitleString = (titleObj) => {
- if (!titleObj || typeof titleObj !== 'object') return '';
- return Object.entries(titleObj)
- .map(([type, groups]) => {
- if (typeof groups !== 'object') return '';
- const groupParts = Object.entries(groups)
- .map(([group, value]) => `${group}: ${value}`);
- return `${type} — ${groupParts.join(', ')}`;
- })
- .filter(Boolean)
- .join(' | ');
- };
-
- // Create document fragment for better performance
const fragment = document.createDocumentFragment();
response.forEach(item => {
const tr = $('<tr>').addClass('inserted-row');
- // Create subcategory cell
const subcategoryTd = $(`
<td class="subcategory d-flex justify-content-end">
<span class="list-group-item list-group-item-action subcategory-link w-90"
`);
tr.append(subcategoryTd);
- // Map values for easier access
const valuesMap = new Map(item.values?.map(val => [
val.store_id,
{
}
]) || []);
- // Process table headers
$('table thead th').each(function (index) {
const $th = $(this);
const storeId = $th.data('store-id');
fragment.appendChild(tr[0]);
});
- // Append all rows at once
$row.after(fragment);
- // Initialize Bootstrap tooltips
$('[data-bs-toggle="tooltip"]').tooltip();
},
error: function (xhr) {