diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php index 86a1531..ca0be79 100644 --- a/public/userarea/import_edit2.php +++ b/public/userarea/import_edit2.php @@ -156,7 +156,8 @@ function fixedDefaultValue(array $f): string } input, - select { + select, + textarea { width: 100%; box-sizing: border-box; border: 1px solid #ced4da; @@ -166,10 +167,36 @@ function fixedDefaultValue(array $f): string } input, - select { + select, + textarea { color: #333; } + textarea { + resize: vertical; + min-height: 60px; + border: 1px solid #ced4da !important; + } + + textarea:focus, + textarea:active, + textarea:hover { + border: 1px solid #ced4da !important; + outline: none !important; + } + + textarea.auto-input { + background-color: #d4edda; + } + + textarea.manual-input { + background-color: #fff3cd; + } + + textarea.required-input { + background-color: #f8d7da; + } + .status-badge { display: inline-block; padding: 2px 8px; @@ -197,11 +224,12 @@ function fixedDefaultValue(array $f): string .grid-container { overflow-x: auto; - max-width: 100%; + width: 100%; margin-bottom: 20px; border: 1px solid #dee2e6; border-radius: 0.25rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + position: relative; } .grid-row { @@ -249,6 +277,55 @@ function fixedDefaultValue(array $f): string border-right: none; } + /* Sticky columns - first column (Actions) */ + .grid-header.button-header, + .grid-cell.button-cell { + position: sticky !important; + left: 0; + z-index: 9; + background: white; + overflow: visible; + flex-shrink: 0; + } + + .grid-header.button-header { + background-color: #e9ecef; + } + + .grid-row:nth-child(even) .grid-cell.button-cell { + background-color: #f8f9fa; + } + + .grid-row:hover .grid-cell.button-cell { + background-color: #e9ecef; + } + + .grid-row .grid-header:nth-child(2), + .grid-row .grid-cell:nth-child(2) { + position: sticky !important; + left: 210px; + z-index: 8; + background: white; + overflow: visible; + flex-shrink: 0; + } + + .grid-row .grid-header:nth-child(2) { + background-color: #e9ecef; + } + + .grid-row:nth-child(even) .grid-cell:nth-child(2) { + background-color: #f8f9fa; + } + + .grid-row:hover .grid-cell:nth-child(2) { + background-color: #e9ecef; + } + + .grid-row { + position: relative; + } + .grid-cell.expanded { max-width: 500px !important; white-space: normal !important; @@ -276,6 +353,8 @@ function fixedDefaultValue(array $f): string display: flex; align-items: flex-start; padding: 10px 0; + min-height: 0; + flex-wrap: nowrap; } .grid-top .grid-cell { @@ -285,6 +364,7 @@ function fixedDefaultValue(array $f): string display: flex; flex-direction: column; align-items: center; + overflow: visible; } .grid-top .save-all-cell { @@ -292,6 +372,15 @@ function fixedDefaultValue(array $f): string align-items: flex-start; } + .grid-top .grid-cell input, + .grid-top .grid-cell select, + .grid-top .grid-cell .date-picker, + .grid-top .grid-cell .fixed-top { + position: relative; + max-width: 100%; + z-index: 1; + } + .propagate-btn { background: none; border: none; @@ -489,6 +578,10 @@ function fixedDefaultValue(array $f): string font-size: 14px; } + .select2-results__options { + max-height: 400px !important; + } + .select2-container--default .select2-selection--single { height: 31px; border: 1px solid #ced4da; @@ -552,8 +645,12 @@ function fixedDefaultValue(array $f): string
- -
+ +
- -
+ + +
-
+
"; - echo ""; echo ""; echo ""; echo ""; echo "
"; } else { - echo "
"; + echo "
"; } + $autoIndex++; + $topColIndex++; } } + $manualIndex = 0; + foreach ($allMappings as $mapping) { if ($mapping['is_manual'] && $mapping['main_field'] != 1 && $mapping['is_visible_import'] == 1) { $fieldValue = $mapping['manual_default'] ?? ''; @@ -615,7 +722,7 @@ function fixedDefaultValue(array $f): string } $inputClass = 'manual-input'; if ($mapping['is_required']) $inputClass .= ' required-input'; - echo "
"; + echo "
"; if ($mapping['data_type'] === 'SceltaMultipla') { echo " @@ -891,10 +1012,12 @@ function fixedDefaultValue(array $f): string
-
+ +
Shipment Info
+ { - input.addEventListener('focus', function() { - this.closest('.grid-cell').classList.add('expanded'); - }); - input.addEventListener('blur', function() { - this.closest('.grid-cell').classList.remove('expanded'); - }); + if (input.tagName === 'SELECT' || + input.classList.contains('date-picker') || + input.type === 'number' || + input.type === 'date') { + input.addEventListener('focus', function() { + this.closest('.grid-cell').classList.add('expanded'); + }); + input.addEventListener('blur', function() { + this.closest('.grid-cell').classList.remove('expanded'); + }); + return; + } + + if (input.type === 'text') { + input.addEventListener('focus', function() { + const cell = this.closest('.grid-cell'); + + cell.classList.add('expanded'); + cell.dataset.convertingToTextarea = 'true'; + + const textarea = document.createElement('textarea'); + + textarea.value = this.value; + textarea.name = this.name; + textarea.className = this.className; + textarea.required = this.required; + textarea.style.border = '1px solid #ced4da'; + textarea.setAttribute('data-mapping-id', this.getAttribute('data-mapping-id') || ''); + textarea.setAttribute('data-field-id', this.getAttribute('data-field-id') || ''); + textarea.setAttribute('data-selected-value', this.getAttribute('data-selected-value') || ''); + textarea.setAttribute('data-current-value', this.getAttribute('data-current-value') || ''); + textarea.setAttribute('data-fixed-key', this.getAttribute('data-fixed-key') || ''); + textarea.dataset.originalInput = 'true'; + + this.parentNode.replaceChild(textarea, this); + + setTimeout(() => { + textarea.focus(); + delete cell.dataset.convertingToTextarea; + }, 0); + }); + } else { + input.addEventListener('focus', function() { + this.closest('.grid-cell').classList.add('expanded'); + }); + } }); + document.addEventListener('blur', function(e) { + const element = e.target; + if (element.tagName === 'TEXTAREA' && element.dataset.originalInput === 'true') { + const cell = element.closest('.grid-cell'); + + const input = document.createElement('input'); + input.type = 'text'; + input.value = element.value; + input.name = element.name; + input.className = element.className; + input.required = element.required; + input.setAttribute('data-mapping-id', element.getAttribute('data-mapping-id') || ''); + input.setAttribute('data-field-id', element.getAttribute('data-field-id') || ''); + input.setAttribute('data-selected-value', element.getAttribute('data-selected-value') || ''); + input.setAttribute('data-current-value', element.getAttribute('data-current-value') || ''); + input.setAttribute('data-fixed-key', element.getAttribute('data-fixed-key') || ''); + + element.parentNode.replaceChild(input, element); + + cell.classList.remove('expanded'); + + input.addEventListener('focus', function() { + const cell = this.closest('.grid-cell'); + cell.classList.add('expanded'); + cell.dataset.convertingToTextarea = 'true'; + + const textarea = document.createElement('textarea'); + textarea.value = this.value; + textarea.name = this.name; + textarea.className = this.className; + textarea.required = this.required; + textarea.style.border = '1px solid #ced4da'; + textarea.setAttribute('data-mapping-id', this.getAttribute('data-mapping-id') || ''); + textarea.setAttribute('data-field-id', this.getAttribute('data-field-id') || ''); + textarea.setAttribute('data-selected-value', this.getAttribute('data-selected-value') || ''); + textarea.setAttribute('data-current-value', this.getAttribute('data-current-value') || ''); + textarea.setAttribute('data-fixed-key', this.getAttribute('data-fixed-key') || ''); + textarea.dataset.originalInput = 'true'; + + this.parentNode.replaceChild(textarea, this); + setTimeout(() => { + textarea.focus(); + delete cell.dataset.convertingToTextarea; + }, 0); + }); + + const changeEvent = new Event('change', { bubbles: true }); + input.dispatchEvent(changeEvent); + } else if (element.tagName === 'INPUT' && element.type === 'text') { + const cell = element.closest('.grid-cell'); + if (cell && !cell.dataset.convertingToTextarea) { + cell.classList.remove('expanded'); + } + } + }, true); + // Gestione della propagazione const propagateButtons = document.querySelectorAll('.propagate-btn'); propagateButtons.forEach(button => { @@ -1453,12 +1672,14 @@ function fixedDefaultValue(array $f): string function resize(e) { if (currentResizer) { - const dx = e.pageX - startX; - const newWidth = startWidth + dx; + const deltaX = e.pageX - startX; + const newWidth = Math.max(80, startWidth + deltaX); const headers = document.querySelectorAll(`.grid-header[data-index="${columnIndex}"]`); const cells = document.querySelectorAll(`.grid-cell[data-index="${columnIndex}"]`); + const topCells = document.querySelectorAll(`.grid-top .grid-cell[data-index="${columnIndex}"]`); headers.forEach(header => header.style.flex = `0 0 ${newWidth}px`); cells.forEach(cell => cell.style.flex = `0 0 ${newWidth}px`); + topCells.forEach(cell => cell.style.flex = `0 0 ${newWidth}px`); } } @@ -2009,6 +2230,17 @@ function fixedDefaultValue(array $f): string }); } }); + + // Fix for sticky columns + const gridContainer = document.querySelector('.grid-container'); + if (gridContainer) { + const rows = document.querySelectorAll('.grid-row'); + rows.forEach(row => { + if (!row.style.minWidth) { + row.style.minWidth = 'max-content'; + } + }); + } });