|
@@ -715,152 +715,302 @@ function createAttributeChips(p, attr, initialSelected, isMandatory, updateCallb
|
|
|
return wrapper;
|
|
return wrapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// function renderProductsTable(items = getCurrentSlice()) {
|
|
|
|
|
+// const wrap = document.getElementById('tableContainer');
|
|
|
|
|
+// wrap.innerHTML = '';
|
|
|
|
|
+// const table = document.createElement('table');
|
|
|
|
|
+// table.classList.add('table', 'table-striped', 'table-bordered','table-responsive');
|
|
|
|
|
+
|
|
|
|
|
+// const thead = document.createElement('thead');
|
|
|
|
|
+// const trh = document.createElement('tr');
|
|
|
|
|
+
|
|
|
|
|
+// // Table Headers
|
|
|
|
|
+// ['Select', 'Image', 'Product', 'SKU', 'Type', 'Short Description'].forEach(h => {
|
|
|
|
|
+// const th = document.createElement('th'); th.textContent = h; trh.appendChild(th);
|
|
|
|
|
+// });
|
|
|
|
|
+// thead.appendChild(trh); table.appendChild(thead);
|
|
|
|
|
+
|
|
|
|
|
+// const tbody = document.createElement('tbody');
|
|
|
|
|
+
|
|
|
|
|
+// if (items.length > 0) {
|
|
|
|
|
+// items.forEach(p => {
|
|
|
|
|
+// const tr = document.createElement('tr');
|
|
|
|
|
+// tr.id = `row-${p.id}`;
|
|
|
|
|
+// if (isProductSelected(p.item_id)) tr.classList.add('selected');
|
|
|
|
|
+
|
|
|
|
|
+// // --- Define Checkbox (cb) and State Updater ---
|
|
|
|
|
+// const cb = document.createElement('input');
|
|
|
|
|
+// cb.type = 'checkbox';
|
|
|
|
|
+// cb.checked = isProductSelected(p.item_id);
|
|
|
|
|
+// // console.log("checkkkkk")
|
|
|
|
|
+
|
|
|
|
|
+// // The state updater function is bound to this specific row/checkbox
|
|
|
|
|
+// const updateProductState = getProductStateUpdater(p, cb, tr);
|
|
|
|
|
+
|
|
|
|
|
+// // --- Select Cell ---
|
|
|
|
|
+// const tdSel = document.createElement('td');
|
|
|
|
|
+// tdSel.className = 'select-cell';
|
|
|
|
|
+// tdSel.appendChild(cb);
|
|
|
|
|
+// tr.appendChild(tdSel);
|
|
|
|
|
+
|
|
|
|
|
+// // --- Other Cells ---
|
|
|
|
|
+// const tdImg = document.createElement('td'); tdImg.className = 'thumb-cell'; tdImg.appendChild(createMiniThumb(p)); tr.appendChild(tdImg);
|
|
|
|
|
+// const tdName = document.createElement('td'); tdName.textContent = p.product_name || '—'; tr.appendChild(tdName);
|
|
|
|
|
+// const tdSku = document.createElement('td'); tdSku.textContent = p.item_id || '—'; tr.appendChild(tdSku);
|
|
|
|
|
+// const tdType = document.createElement('td'); const b = document.createElement('span'); b.className = 'badge'; b.textContent = p.product_type || '—'; tdType.appendChild(b); tr.appendChild(tdType);
|
|
|
|
|
+// const tdDesc = document.createElement('td'); tdDesc.innerHTML = p.product_short_description || ''; tr.appendChild(tdDesc);
|
|
|
|
|
+
|
|
|
|
|
+// // ---------------------------------------------
|
|
|
|
|
+// // --- ATTRIBUTE SELECTION IMPLEMENTATION ---
|
|
|
|
|
+// // ---------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+// // 1. DETAIL ROW STRUCTURE
|
|
|
|
|
+// const detailRow = document.createElement('tr');
|
|
|
|
|
+// detailRow.classList.add('attribute-detail-row'); // Custom class for styling
|
|
|
|
|
+// detailRow.style.display = 'none'; // Initially hidden
|
|
|
|
|
+// detailRow.id = `detail-row-${p.id}`;
|
|
|
|
|
+
|
|
|
|
|
+// const detailCell = document.createElement('td');
|
|
|
|
|
+// detailCell.colSpan = 6; // Must span all columns
|
|
|
|
|
+
|
|
|
|
|
+// const attrContainer = document.createElement('div');
|
|
|
|
|
+// attrContainer.id = `attr-container-${p.item_id}`; // Unique ID for targeting by updateProductState
|
|
|
|
|
+// attrContainer.classList.add('attribute-selectors', 'table-selectors');
|
|
|
|
|
+
|
|
|
|
|
+// // 2. GENERATE CHIPS UI
|
|
|
|
|
+// generateAttributeUI(p, updateProductState, attrContainer);
|
|
|
|
|
+
|
|
|
|
|
+// // Initially disable the chips if the product is not selected
|
|
|
|
|
+// attrContainer.classList.toggle('disabled', !cb.checked);
|
|
|
|
|
+
|
|
|
|
|
+// detailCell.appendChild(attrContainer);
|
|
|
|
|
+// detailRow.appendChild(detailCell);
|
|
|
|
|
+
|
|
|
|
|
+// if(p.product_type_details.length > 0){
|
|
|
|
|
+// // 3. TOGGLE BUTTON (in the main row)
|
|
|
|
|
+// const tdAttr = document.createElement('td');
|
|
|
|
|
+// const toggleButton = document.createElement('button');
|
|
|
|
|
+// toggleButton.textContent = 'Configure';
|
|
|
|
|
+// toggleButton.classList.add('btn', 'btn-sm', 'btn-info', 'attribute-toggle-btn');
|
|
|
|
|
+// tdAttr.appendChild(toggleButton);
|
|
|
|
|
+// // tr.appendChild(tdAttr);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// // 4. EVENT LISTENERS
|
|
|
|
|
+
|
|
|
|
|
+// // a) Toggle Button Logic
|
|
|
|
|
+// toggleButton.addEventListener('click', (e) => {
|
|
|
|
|
+// e.stopPropagation(); // Stop row click event
|
|
|
|
|
+// const isHidden = detailRow.style.display === 'none';
|
|
|
|
|
+// detailRow.style.display = isHidden ? '' : 'none'; // Toggle visibility
|
|
|
|
|
+// toggleButton.textContent = isHidden ? 'Hide Attributes' : 'Configure';
|
|
|
|
|
+// toggleButton.classList.toggle('btn-info', !isHidden);
|
|
|
|
|
+// toggleButton.classList.toggle('btn-secondary', isHidden);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+// // b) Main Checkbox Change Logic
|
|
|
|
|
+// cb.addEventListener('change', () => {
|
|
|
|
|
+// // console.log("cheeeeeeeeee");
|
|
|
|
|
+// updateProductState(); // Update state on check/uncheck
|
|
|
|
|
+// attrContainer.classList.toggle('disabled', !cb.checked); // Enable/Disable chips
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+// // c) Row Click Listener (Updated to ignore button clicks)
|
|
|
|
|
+// tr.addEventListener('click', (e) => {
|
|
|
|
|
+// const tag = e.target.tagName.toLowerCase();
|
|
|
|
|
+// // console.log("clikk")
|
|
|
|
|
+// if (tag !== 'input' && tag !== 'button') {
|
|
|
|
|
+// cb.checked = !cb.checked;
|
|
|
|
|
+// cb.dispatchEvent(new Event('change'));
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// }else{
|
|
|
|
|
+// const tdAttr = document.createElement('td');
|
|
|
|
|
+// tr.appendChild(tdAttr);
|
|
|
|
|
+// // b) Main Checkbox Change Logic
|
|
|
|
|
+// cb.addEventListener('change', () => {
|
|
|
|
|
+// // console.log("cheeeeeeeeee");
|
|
|
|
|
+// updateProductState(); // Update state on check/uncheck
|
|
|
|
|
+// attrContainer.classList.toggle('disabled', !cb.checked); // Enable/Disable chips
|
|
|
|
|
+// });
|
|
|
|
|
+// tr.addEventListener('click', (e) => {
|
|
|
|
|
+// const tag = e.target.tagName.toLowerCase();
|
|
|
|
|
+// // console.log("clikk")
|
|
|
|
|
+// if (tag !== 'input' && tag !== 'button') {
|
|
|
|
|
+// cb.checked = !cb.checked;
|
|
|
|
|
+// cb.dispatchEvent(new Event('change'));
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 5. Append Rows to TBODY
|
|
|
|
|
+// tbody.appendChild(tr);
|
|
|
|
|
+// tbody.appendChild(detailRow); // Append the detail row right after the main row
|
|
|
|
|
+// });
|
|
|
|
|
+// } else {
|
|
|
|
|
+// const tr = el('tr');
|
|
|
|
|
+// const tdName = el('td');
|
|
|
|
|
+// tdName.colSpan = 6;
|
|
|
|
|
+// tdName.innerHTML = "No Products Found.";
|
|
|
|
|
+// tr.appendChild(tdName);
|
|
|
|
|
+// tbody.appendChild(tr);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// table.appendChild(tbody);
|
|
|
|
|
+// wrap.appendChild(table);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
function renderProductsTable(items = getCurrentSlice()) {
|
|
function renderProductsTable(items = getCurrentSlice()) {
|
|
|
const wrap = document.getElementById('tableContainer');
|
|
const wrap = document.getElementById('tableContainer');
|
|
|
wrap.innerHTML = '';
|
|
wrap.innerHTML = '';
|
|
|
const table = document.createElement('table');
|
|
const table = document.createElement('table');
|
|
|
- table.classList.add('table', 'table-striped', 'table-bordered','table-responsive');
|
|
|
|
|
-
|
|
|
|
|
- const thead = document.createElement('thead');
|
|
|
|
|
|
|
+ table.classList.add('table', 'table-striped', 'table-bordered', 'table-responsive');
|
|
|
|
|
+ table.id = 'productsTable'; // ✅ Add a unique table ID
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ const thead = document.createElement('thead');
|
|
|
const trh = document.createElement('tr');
|
|
const trh = document.createElement('tr');
|
|
|
-
|
|
|
|
|
- // Table Headers
|
|
|
|
|
- ['Select', 'Image', 'Product', 'SKU', 'Type', 'Short Description'].forEach(h => {
|
|
|
|
|
- const th = document.createElement('th'); th.textContent = h; trh.appendChild(th);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // --- "Select All" Header with Checkbox ---
|
|
|
|
|
+ const thSelect = document.createElement('th');
|
|
|
|
|
+ const selectAllCheckbox = document.createElement('input');
|
|
|
|
|
+ selectAllCheckbox.type = 'checkbox';
|
|
|
|
|
+ selectAllCheckbox.id = 'selectAllCheckbox';
|
|
|
|
|
+ thSelect.appendChild(selectAllCheckbox);
|
|
|
|
|
+ trh.appendChild(thSelect);
|
|
|
|
|
+
|
|
|
|
|
+ // Other headers
|
|
|
|
|
+ ['Image', 'Product', 'SKU', 'Type', 'Short Description'].forEach(h => {
|
|
|
|
|
+ const th = document.createElement('th');
|
|
|
|
|
+ th.textContent = h;
|
|
|
|
|
+ trh.appendChild(th);
|
|
|
});
|
|
});
|
|
|
- thead.appendChild(trh); table.appendChild(thead);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ thead.appendChild(trh);
|
|
|
|
|
+ table.appendChild(thead);
|
|
|
|
|
+
|
|
|
const tbody = document.createElement('tbody');
|
|
const tbody = document.createElement('tbody');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (items.length > 0) {
|
|
if (items.length > 0) {
|
|
|
items.forEach(p => {
|
|
items.forEach(p => {
|
|
|
- const tr = document.createElement('tr');
|
|
|
|
|
|
|
+ const tr = document.createElement('tr');
|
|
|
tr.id = `row-${p.id}`;
|
|
tr.id = `row-${p.id}`;
|
|
|
if (isProductSelected(p.item_id)) tr.classList.add('selected');
|
|
if (isProductSelected(p.item_id)) tr.classList.add('selected');
|
|
|
|
|
|
|
|
- // --- Define Checkbox (cb) and State Updater ---
|
|
|
|
|
- const cb = document.createElement('input');
|
|
|
|
|
- cb.type = 'checkbox';
|
|
|
|
|
|
|
+ // Checkbox for each row
|
|
|
|
|
+ const cb = document.createElement('input');
|
|
|
|
|
+ cb.type = 'checkbox';
|
|
|
|
|
+ cb.classList.add('checkbox-productlist'); // ✅ correct way to add class
|
|
|
cb.checked = isProductSelected(p.item_id);
|
|
cb.checked = isProductSelected(p.item_id);
|
|
|
- // console.log("checkkkkk")
|
|
|
|
|
-
|
|
|
|
|
- // The state updater function is bound to this specific row/checkbox
|
|
|
|
|
|
|
+
|
|
|
const updateProductState = getProductStateUpdater(p, cb, tr);
|
|
const updateProductState = getProductStateUpdater(p, cb, tr);
|
|
|
|
|
|
|
|
- // --- Select Cell ---
|
|
|
|
|
- const tdSel = document.createElement('td');
|
|
|
|
|
|
|
+ const tdSel = document.createElement('td');
|
|
|
tdSel.className = 'select-cell';
|
|
tdSel.className = 'select-cell';
|
|
|
- tdSel.appendChild(cb);
|
|
|
|
|
|
|
+ tdSel.appendChild(cb);
|
|
|
tr.appendChild(tdSel);
|
|
tr.appendChild(tdSel);
|
|
|
|
|
|
|
|
- // --- Other Cells ---
|
|
|
|
|
- const tdImg = document.createElement('td'); tdImg.className = 'thumb-cell'; tdImg.appendChild(createMiniThumb(p)); tr.appendChild(tdImg);
|
|
|
|
|
- const tdName = document.createElement('td'); tdName.textContent = p.product_name || '—'; tr.appendChild(tdName);
|
|
|
|
|
- const tdSku = document.createElement('td'); tdSku.textContent = p.item_id || '—'; tr.appendChild(tdSku);
|
|
|
|
|
- const tdType = document.createElement('td'); const b = document.createElement('span'); b.className = 'badge'; b.textContent = p.product_type || '—'; tdType.appendChild(b); tr.appendChild(tdType);
|
|
|
|
|
- const tdDesc = document.createElement('td'); tdDesc.innerHTML = p.product_short_description || ''; tr.appendChild(tdDesc);
|
|
|
|
|
|
|
+ const tdImg = document.createElement('td');
|
|
|
|
|
+ tdImg.className = 'thumb-cell';
|
|
|
|
|
+ tdImg.appendChild(createMiniThumb(p));
|
|
|
|
|
+ tr.appendChild(tdImg);
|
|
|
|
|
+
|
|
|
|
|
+ const tdName = document.createElement('td');
|
|
|
|
|
+ tdName.textContent = p.product_name || '—';
|
|
|
|
|
+ tr.appendChild(tdName);
|
|
|
|
|
|
|
|
- // ---------------------------------------------
|
|
|
|
|
- // --- ATTRIBUTE SELECTION IMPLEMENTATION ---
|
|
|
|
|
- // ---------------------------------------------
|
|
|
|
|
|
|
+ const tdSku = document.createElement('td');
|
|
|
|
|
+ tdSku.textContent = p.item_id || '—';
|
|
|
|
|
+ tr.appendChild(tdSku);
|
|
|
|
|
|
|
|
- // 1. DETAIL ROW STRUCTURE
|
|
|
|
|
|
|
+ const tdType = document.createElement('td');
|
|
|
|
|
+ const b = document.createElement('span');
|
|
|
|
|
+ b.className = 'badge';
|
|
|
|
|
+ b.textContent = p.product_type || '—';
|
|
|
|
|
+ tdType.appendChild(b);
|
|
|
|
|
+ tr.appendChild(tdType);
|
|
|
|
|
+
|
|
|
|
|
+ const tdDesc = document.createElement('td');
|
|
|
|
|
+ tdDesc.innerHTML = p.product_short_description || '';
|
|
|
|
|
+ tr.appendChild(tdDesc);
|
|
|
|
|
+
|
|
|
|
|
+ // Handle attribute rows (kept your same logic)
|
|
|
const detailRow = document.createElement('tr');
|
|
const detailRow = document.createElement('tr');
|
|
|
- detailRow.classList.add('attribute-detail-row'); // Custom class for styling
|
|
|
|
|
- detailRow.style.display = 'none'; // Initially hidden
|
|
|
|
|
|
|
+ detailRow.classList.add('attribute-detail-row');
|
|
|
|
|
+ detailRow.style.display = 'none';
|
|
|
detailRow.id = `detail-row-${p.id}`;
|
|
detailRow.id = `detail-row-${p.id}`;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const detailCell = document.createElement('td');
|
|
const detailCell = document.createElement('td');
|
|
|
- detailCell.colSpan = 6; // Must span all columns
|
|
|
|
|
-
|
|
|
|
|
|
|
+ detailCell.colSpan = 6;
|
|
|
|
|
+
|
|
|
const attrContainer = document.createElement('div');
|
|
const attrContainer = document.createElement('div');
|
|
|
- attrContainer.id = `attr-container-${p.item_id}`; // Unique ID for targeting by updateProductState
|
|
|
|
|
|
|
+ attrContainer.id = `attr-container-${p.item_id}`;
|
|
|
attrContainer.classList.add('attribute-selectors', 'table-selectors');
|
|
attrContainer.classList.add('attribute-selectors', 'table-selectors');
|
|
|
|
|
|
|
|
- // 2. GENERATE CHIPS UI
|
|
|
|
|
generateAttributeUI(p, updateProductState, attrContainer);
|
|
generateAttributeUI(p, updateProductState, attrContainer);
|
|
|
-
|
|
|
|
|
- // Initially disable the chips if the product is not selected
|
|
|
|
|
attrContainer.classList.toggle('disabled', !cb.checked);
|
|
attrContainer.classList.toggle('disabled', !cb.checked);
|
|
|
|
|
|
|
|
detailCell.appendChild(attrContainer);
|
|
detailCell.appendChild(attrContainer);
|
|
|
detailRow.appendChild(detailCell);
|
|
detailRow.appendChild(detailCell);
|
|
|
|
|
|
|
|
- if(p.product_type_details.length > 0){
|
|
|
|
|
- // 3. TOGGLE BUTTON (in the main row)
|
|
|
|
|
- const tdAttr = document.createElement('td');
|
|
|
|
|
- const toggleButton = document.createElement('button');
|
|
|
|
|
- toggleButton.textContent = 'Configure';
|
|
|
|
|
- toggleButton.classList.add('btn', 'btn-sm', 'btn-info', 'attribute-toggle-btn');
|
|
|
|
|
- tdAttr.appendChild(toggleButton);
|
|
|
|
|
- // tr.appendChild(tdAttr);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 4. EVENT LISTENERS
|
|
|
|
|
-
|
|
|
|
|
- // a) Toggle Button Logic
|
|
|
|
|
- toggleButton.addEventListener('click', (e) => {
|
|
|
|
|
- e.stopPropagation(); // Stop row click event
|
|
|
|
|
- const isHidden = detailRow.style.display === 'none';
|
|
|
|
|
- detailRow.style.display = isHidden ? '' : 'none'; // Toggle visibility
|
|
|
|
|
- toggleButton.textContent = isHidden ? 'Hide Attributes' : 'Configure';
|
|
|
|
|
- toggleButton.classList.toggle('btn-info', !isHidden);
|
|
|
|
|
- toggleButton.classList.toggle('btn-secondary', isHidden);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // b) Main Checkbox Change Logic
|
|
|
|
|
- cb.addEventListener('change', () => {
|
|
|
|
|
- // console.log("cheeeeeeeeee");
|
|
|
|
|
- updateProductState(); // Update state on check/uncheck
|
|
|
|
|
- attrContainer.classList.toggle('disabled', !cb.checked); // Enable/Disable chips
|
|
|
|
|
|
|
+ // Checkbox behavior
|
|
|
|
|
+ cb.addEventListener('change', () => {
|
|
|
|
|
+ updateProductState();
|
|
|
|
|
+ attrContainer.classList.toggle('disabled', !cb.checked);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // c) Row Click Listener (Updated to ignore button clicks)
|
|
|
|
|
- tr.addEventListener('click', (e) => {
|
|
|
|
|
|
|
+ tr.addEventListener('click', (e) => {
|
|
|
const tag = e.target.tagName.toLowerCase();
|
|
const tag = e.target.tagName.toLowerCase();
|
|
|
- // console.log("clikk")
|
|
|
|
|
- if (tag !== 'input' && tag !== 'button') {
|
|
|
|
|
- cb.checked = !cb.checked;
|
|
|
|
|
- cb.dispatchEvent(new Event('change'));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (tag !== 'input' && tag !== 'button') {
|
|
|
|
|
+ cb.checked = !cb.checked;
|
|
|
|
|
+ cb.dispatchEvent(new Event('change'));
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
- }else{
|
|
|
|
|
- const tdAttr = document.createElement('td');
|
|
|
|
|
- tr.appendChild(tdAttr);
|
|
|
|
|
- // b) Main Checkbox Change Logic
|
|
|
|
|
- cb.addEventListener('change', () => {
|
|
|
|
|
- // console.log("cheeeeeeeeee");
|
|
|
|
|
- updateProductState(); // Update state on check/uncheck
|
|
|
|
|
- attrContainer.classList.toggle('disabled', !cb.checked); // Enable/Disable chips
|
|
|
|
|
- });
|
|
|
|
|
- tr.addEventListener('click', (e) => {
|
|
|
|
|
- const tag = e.target.tagName.toLowerCase();
|
|
|
|
|
- // console.log("clikk")
|
|
|
|
|
- if (tag !== 'input' && tag !== 'button') {
|
|
|
|
|
- cb.checked = !cb.checked;
|
|
|
|
|
- cb.dispatchEvent(new Event('change'));
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 5. Append Rows to TBODY
|
|
|
|
|
|
|
+
|
|
|
tbody.appendChild(tr);
|
|
tbody.appendChild(tr);
|
|
|
- tbody.appendChild(detailRow); // Append the detail row right after the main row
|
|
|
|
|
|
|
+ tbody.appendChild(detailRow);
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
- const tr = el('tr');
|
|
|
|
|
- const tdName = el('td');
|
|
|
|
|
- tdName.colSpan = 6;
|
|
|
|
|
- tdName.innerHTML = "No Products Found.";
|
|
|
|
|
- tr.appendChild(tdName);
|
|
|
|
|
|
|
+ const tr = document.createElement('tr');
|
|
|
|
|
+ const td = document.createElement('td');
|
|
|
|
|
+ td.colSpan = 6;
|
|
|
|
|
+ td.textContent = 'No Products Found.';
|
|
|
|
|
+ tr.appendChild(td);
|
|
|
tbody.appendChild(tr);
|
|
tbody.appendChild(tr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
table.appendChild(tbody);
|
|
table.appendChild(tbody);
|
|
|
wrap.appendChild(table);
|
|
wrap.appendChild(table);
|
|
|
|
|
+
|
|
|
|
|
+ // --- Select All Checkbox Logic ---
|
|
|
|
|
+ selectAllCheckbox.addEventListener('change', () => {
|
|
|
|
|
+ // ✅ Only get product checkboxes inside *this* table
|
|
|
|
|
+ const allCheckboxes = table.querySelectorAll('tbody .checkbox-productlist');
|
|
|
|
|
+ console.log("allCheckboxes", allCheckboxes);
|
|
|
|
|
+
|
|
|
|
|
+ allCheckboxes.forEach(cb => {
|
|
|
|
|
+ cb.checked = selectAllCheckbox.checked;
|
|
|
|
|
+ cb.dispatchEvent(new Event('change'));
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // --- Keep "Select All" synced with individual selections ---
|
|
|
|
|
+ tbody.addEventListener('change', (e) => {
|
|
|
|
|
+ if (e.target && e.target.classList.contains('checkbox-productlist')) {
|
|
|
|
|
+ // ✅ Again, limit scope to *this* table
|
|
|
|
|
+ const allCheckboxes = table.querySelectorAll('tbody .checkbox-productlist');
|
|
|
|
|
+ const allChecked = Array.from(allCheckboxes).every(cb => cb.checked);
|
|
|
|
|
+ const someChecked = Array.from(allCheckboxes).some(cb => cb.checked);
|
|
|
|
|
+
|
|
|
|
|
+ selectAllCheckbox.checked = allChecked;
|
|
|
|
|
+ selectAllCheckbox.indeterminate = !allChecked && someChecked;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// function renderInlineForCards() {
|
|
// function renderInlineForCards() {
|
|
|
// const api = API_RESPONSE_AI;
|
|
// const api = API_RESPONSE_AI;
|
|
|
// // Clear all inline sections first
|
|
// // Clear all inline sections first
|
|
@@ -1463,7 +1613,7 @@ function renderMandatoryComparisonTable(attributes, title, productType) {
|
|
|
if (!attr.isMatch && attr.aiValue !== 'N/A') {
|
|
if (!attr.isMatch && attr.aiValue !== 'N/A') {
|
|
|
const newOpt = document.createElement('option');
|
|
const newOpt = document.createElement('option');
|
|
|
newOpt.value = attr.aiValue;
|
|
newOpt.value = attr.aiValue;
|
|
|
- newOpt.textContent = attr.aiValue + " (new)";
|
|
|
|
|
|
|
+ newOpt.textContent = attr.aiValue; // + " (new)";
|
|
|
newOpt.selected = true;
|
|
newOpt.selected = true;
|
|
|
select.appendChild(newOpt);
|
|
select.appendChild(newOpt);
|
|
|
}
|
|
}
|