Преглед на файлове

Merge branch 'master' of https://git.luminad.com/harshit.pathak/content_quality_tool

Student Yadav преди 3 месеца
родител
ревизия
013a276115
променени са 2 файла, в които са добавени 53 реда и са изтрити 10 реда
  1. 52 9
      content_quality_tool_public/static/js/attr-extraction.js
  2. 1 1
      content_quality_tool_public/templates/attr-extraction.html

+ 52 - 9
content_quality_tool_public/static/js/attr-extraction.js

@@ -881,7 +881,7 @@ function renderProductsTable(items = getCurrentSlice()) {
     trh.appendChild(thSelect);
 
     // Other headers
-    ['Image', 'Product', 'SKU', 'Type', 'Short Description'].forEach(h => {
+    ['Image', 'Product', 'SKU', 'Type', 'Description'].forEach(h => {
         const th = document.createElement('th');
         th.textContent = h;
         trh.appendChild(th);
@@ -930,10 +930,53 @@ function renderProductsTable(items = getCurrentSlice()) {
             tdType.appendChild(b);
             tr.appendChild(tdType);
 
+            // const tdDesc = document.createElement('td');
+            // tdDesc.innerHTML = p.product_short_description || '';
+            // tr.appendChild(tdDesc);
+
             const tdDesc = document.createElement('td');
-            tdDesc.innerHTML = p.product_short_description || '';
+
+            // Create a container for descriptions
+            const descContainer = document.createElement('div');
+            descContainer.classList.add('description-cell');
+
+            // Short description (always visible)
+            const shortDesc = document.createElement('div');
+            shortDesc.classList.add('short-desc');
+            shortDesc.innerHTML = `<strong>Short Description:</strong> ${p.product_short_description || 'N/A'}`;
+
+            // Long description (hidden initially)
+            const longDesc = document.createElement('div');
+            longDesc.classList.add('long-desc');
+            longDesc.innerHTML = `<strong>Long Description:</strong> ${p.product_long_description || 'N/A'}`;
+            longDesc.style.display = 'none';
+
+            // Button to toggle long description
+            const toggleBtn = document.createElement('button');
+            toggleBtn.textContent = 'Show Long Description';
+            toggleBtn.classList.add('btn');
+            toggleBtn.classList.add('btn-primary');
+            toggleBtn.classList.add('btn-sm');
+            toggleBtn.classList.add('btn-toggle-desc');
+            toggleBtn.style.fontSize = 'smaller';
+            toggleBtn.style.margin = '5px';
+
+
+            // Toggle logic
+            toggleBtn.addEventListener('click', () => {
+            const isVisible = longDesc.style.display === 'block';
+            longDesc.style.display = isVisible ? 'none' : 'block';
+            toggleBtn.textContent = isVisible ? 'Show Long Description' : 'Hide Long Description';
+            });
+
+            // Append elements in order
+            descContainer.appendChild(shortDesc);
+            descContainer.appendChild(toggleBtn);
+            descContainer.appendChild(longDesc);
+            tdDesc.appendChild(descContainer);
             tr.appendChild(tdDesc);
 
+
             // Handle attribute rows (kept your same logic)
             const detailRow = document.createElement('tr');
             detailRow.classList.add('attribute-detail-row');
@@ -1610,13 +1653,13 @@ function renderMandatoryComparisonTable(attributes, title, productType) {
                 select.appendChild(option);
             });
 
-            if (!attr.isMatch && attr.aiValue !== 'N/A') {
-                const newOpt = document.createElement('option');
-                newOpt.value = attr.aiValue;
-                newOpt.textContent = attr.aiValue; // + " (new)";
-                newOpt.selected = true;
-                select.appendChild(newOpt);
-            }
+            // if (!attr.isMatch && attr.aiValue !== 'N/A') {
+            //     const newOpt = document.createElement('option');
+            //     newOpt.value = attr.aiValue;
+            //     newOpt.textContent = attr.aiValue; // + " (new)";
+            //     newOpt.selected = true;
+            //     select.appendChild(newOpt);
+            // }
 
             aiTd.appendChild(select);
             row.appendChild(aiTd);

+ 1 - 1
content_quality_tool_public/templates/attr-extraction.html

@@ -241,7 +241,7 @@
             <div id="successToast" class="toast align-items-center text-bg-success border-0" role="alert" aria-live="assertive" aria-atomic="true">
             <div class="d-flex">
                 <div class="toast-body">
-                Attribute extracted successfully.
+                Attribute saved successfully.
                 </div>
                 <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
             </div>