mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:45:24 +02:00
Feat: Implement dynamic internal column protection and Fullscreen mode.
- Internal control columns (Type, Checking, etc.) now persist across Excel shifts. - Master data columns now prioritize Dropbox source of truth. - Added Fullscreen mode to all main tabs (Pricing, Descriptions, Matrix). - Improved Supabase data loading with pagination.
This commit is contained in:
+19
-14
@@ -190,22 +190,27 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
|||||||
// Start with fresh Dropbox values (prices from Excel)
|
// Start with fresh Dropbox values (prices from Excel)
|
||||||
let finalRow = [...row];
|
let finalRow = [...row];
|
||||||
|
|
||||||
// Load manual edits: status 'edited' = saved edits, 'pending' = unsaved edits
|
// Merge logic: Prioritize internal control columns and active session edits
|
||||||
if (synced && (synced.status === 'edited' || synced.status === 'pending')) {
|
if (synced && (synced.status === 'edited' || synced.status === 'pending' || synced.status === 'synced')) {
|
||||||
// Compare saved row vs fresh Excel row: wherever Supabase differs from Excel,
|
// 1. ALWAYS restore Internal Control Columns (indices >= 100)
|
||||||
// that means the user edited that column — apply it regardless of editableColumns
|
// These are the "TYPE", "Item to Logistic", "Checking", etc.
|
||||||
// index resolution, which can vary across sessions.
|
Object.values(COLUMNS).forEach(idx => {
|
||||||
const savedLen = Array.isArray(synced.data) ? synced.data.length : 0;
|
if (idx >= 100 && synced.data[idx] !== undefined && synced.data[idx] !== null) {
|
||||||
for (let idx = 0; idx < savedLen; idx++) {
|
finalRow[idx] = synced.data[idx];
|
||||||
const savedVal = synced.data[idx];
|
|
||||||
const excelVal = row[idx];
|
|
||||||
const savedStr = savedVal == null ? '' : String(savedVal);
|
|
||||||
const excelStr = excelVal == null ? '' : String(excelVal);
|
|
||||||
if (savedStr !== excelStr) {
|
|
||||||
// Value differs from Excel → user edited it, apply the saved value
|
|
||||||
finalRow[idx] = savedVal;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. For Master Data (indices < 100, like UVP/SRP), only restore if it's an active edit (pending)
|
||||||
|
// This protects against the "Column Shift" bug where old saved indices might be wrong.
|
||||||
|
if (synced.status === 'pending') {
|
||||||
|
editableColumns.forEach(idx => {
|
||||||
|
if (idx < 100 && synced.data[idx] !== undefined && synced.data[idx] !== null) {
|
||||||
|
finalRow[idx] = synced.data[idx];
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update row status in UI
|
||||||
setRowStatuses(prev => ({ ...prev, [articleNo]: synced.status }));
|
setRowStatuses(prev => ({ ...prev, [articleNo]: synced.status }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -656,12 +656,11 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit,
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={isFullscreen ? "fixed inset-0 z-40 bg-[#041021] p-4 overflow-auto" : "space-y-6"}>
|
<div className={isFullscreen ? "fixed inset-0 z-[100] bg-[#041021] p-6 overflow-auto" : "space-y-6"}>
|
||||||
{isFullscreen && (
|
{isFullscreen && (
|
||||||
<button
|
<button
|
||||||
onClick={() => setIsFullscreen(false)}
|
onClick={() => setIsFullscreen(false)}
|
||||||
className="fixed top-4 right-4 z-50 w-10 h-10 flex items-center justify-center bg-slate-800/90 backdrop-blur border border-slate-600 text-white rounded hover:bg-slate-700 hover:scale-105 transition-all"
|
className="fixed top-4 right-4 z-[110] p-2 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded-md transition-colors border border-slate-700"
|
||||||
title="Exit fullscreen"
|
|
||||||
>
|
>
|
||||||
<X className="w-5 h-5" />
|
<X className="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user