fix, table cp, mengenfeld
This commit is contained in:
@@ -3512,6 +3512,7 @@ function downloadText(filename, text) {
|
||||
function createTableModal(dispatch, config) {
|
||||
let tableWrapper;
|
||||
let currentState = config.getStateFunc();
|
||||
let isPasting = false; // Flag um Paste-Vorgang zu markieren
|
||||
|
||||
// State-Referenz aktualisieren (wird nach jedem Dispatch aufgerufen)
|
||||
const updateState = () => {
|
||||
@@ -3585,6 +3586,9 @@ function createTableModal(dispatch, config) {
|
||||
oninput: col.readOnly
|
||||
? null
|
||||
: (e) => {
|
||||
// Während Paste-Vorgang ignorieren - Paste-Handler übernimmt
|
||||
if (isPasting) return;
|
||||
|
||||
// Scroll-Position VOR dem dispatch speichern
|
||||
const modalContent = e.target.closest(".sk-modal-content");
|
||||
const scrollTop = modalContent ? modalContent.scrollTop : 0;
|
||||
@@ -3633,15 +3637,26 @@ function createTableModal(dispatch, config) {
|
||||
// Excel Paste Handler mit automatischer Tabellen-Aktualisierung
|
||||
table.addEventListener("paste", (e) => {
|
||||
e.preventDefault();
|
||||
isPasting = true; // Flag setzen um oninput zu blockieren
|
||||
|
||||
const text = e.clipboardData.getData("text/plain");
|
||||
|
||||
if (!text || !text.trim()) return;
|
||||
if (!text || !text.trim()) {
|
||||
isPasting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const rows = text.split(/\r?\n/).filter((r) => r.trim());
|
||||
if (rows.length === 0) return;
|
||||
if (rows.length === 0) {
|
||||
isPasting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const activeInput = document.activeElement;
|
||||
if (!activeInput || !activeInput.classList.contains("sk-input")) return;
|
||||
if (!activeInput || !activeInput.classList.contains("sk-input")) {
|
||||
isPasting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const startRow = parseInt(activeInput.dataset.row || "0");
|
||||
const startCol = parseInt(activeInput.dataset.col || "0");
|
||||
@@ -3683,6 +3698,11 @@ function createTableModal(dispatch, config) {
|
||||
// Tabelle im Modal aktualisieren
|
||||
renderTable();
|
||||
}
|
||||
|
||||
// Flag nach kurzem Delay zurücksetzen (für evtl. verzögerte input-Events)
|
||||
setTimeout(() => {
|
||||
isPasting = false;
|
||||
}, 50);
|
||||
});
|
||||
|
||||
return table;
|
||||
@@ -4039,20 +4059,26 @@ function renderRecipientsTable(state, dispatch) {
|
||||
}
|
||||
table.appendChild(tbody);
|
||||
|
||||
// Focusout-Handler mit Debounce um Flackern zu vermeiden
|
||||
let focusoutTimer = null;
|
||||
let hasLocalChanges = false; // Track ob lokale Änderungen gemacht wurden
|
||||
table.addEventListener("focusout", (e) => {
|
||||
if (focusoutTimer) clearTimeout(focusoutTimer);
|
||||
focusoutTimer = setTimeout(() => {
|
||||
const newFocus = document.activeElement;
|
||||
if (!table.contains(newFocus) && hasLocalChanges) {
|
||||
// Nur dispatchen wenn lokale Änderungen gemacht wurden
|
||||
dispatch({ type: "SET_RECIPIENT_ROWS", rows: [...table._rows] });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
// Save-Funktion für Registry (wird bei Navigation und periodisch aufgerufen)
|
||||
let hasLocalChanges = false;
|
||||
const saveLocalChanges = () => {
|
||||
if (hasLocalChanges) {
|
||||
dispatch({ type: "SET_RECIPIENT_ROWS", rows: [...table._rows] });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Bei globaler Registry registrieren
|
||||
const unregisterSave = registerTableSave(saveLocalChanges);
|
||||
|
||||
// Auto-Save alle 60 Sekunden
|
||||
const autoSaveInterval = setInterval(saveLocalChanges, 60000);
|
||||
|
||||
// Cleanup-Funktion
|
||||
table._cleanup = () => {
|
||||
if (autoSaveInterval) clearInterval(autoSaveInterval);
|
||||
unregisterSave();
|
||||
};
|
||||
|
||||
// Änderungen tracken bei Input
|
||||
table.addEventListener("input", () => {
|
||||
@@ -4129,6 +4155,7 @@ function renderRecipientsTable(state, dispatch) {
|
||||
});
|
||||
|
||||
if (pastedCells > 0) {
|
||||
hasLocalChanges = false; // Paste übernimmt - keine alten Änderungen mehr relevant
|
||||
dispatch({ type: "SET_RECIPIENT_ROWS", rows: newData });
|
||||
}
|
||||
});
|
||||
@@ -4200,20 +4227,26 @@ function renderRecipientsTable(state, dispatch) {
|
||||
}
|
||||
table.appendChild(tbody);
|
||||
|
||||
// Focusout-Handler mit Debounce um Flackern zu vermeiden
|
||||
let focusoutTimer = null;
|
||||
let hasLocalChanges = false; // Track ob lokale Änderungen gemacht wurden
|
||||
table.addEventListener("focusout", (e) => {
|
||||
if (focusoutTimer) clearTimeout(focusoutTimer);
|
||||
focusoutTimer = setTimeout(() => {
|
||||
const newFocus = document.activeElement;
|
||||
if (!table.contains(newFocus) && hasLocalChanges) {
|
||||
// Nur dispatchen wenn lokale Änderungen gemacht wurden
|
||||
dispatch({ type: "SET_FREE_ADDRESS_ROWS", rows: [...rows] });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
// Save-Funktion für Registry (wird bei Navigation und periodisch aufgerufen)
|
||||
let hasLocalChanges = false;
|
||||
const saveLocalChanges = () => {
|
||||
if (hasLocalChanges) {
|
||||
dispatch({ type: "SET_FREE_ADDRESS_ROWS", rows: [...rows] });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Bei globaler Registry registrieren
|
||||
const unregisterSave = registerTableSave(saveLocalChanges);
|
||||
|
||||
// Auto-Save alle 60 Sekunden
|
||||
const autoSaveInterval = setInterval(saveLocalChanges, 60000);
|
||||
|
||||
// Cleanup-Funktion
|
||||
table._cleanup = () => {
|
||||
if (autoSaveInterval) clearInterval(autoSaveInterval);
|
||||
unregisterSave();
|
||||
};
|
||||
|
||||
// Änderungen tracken bei Input
|
||||
table.addEventListener("input", () => {
|
||||
@@ -4272,6 +4305,7 @@ function renderRecipientsTable(state, dispatch) {
|
||||
});
|
||||
|
||||
if (pastedCells > 0) {
|
||||
hasLocalChanges = false; // Paste übernimmt - keine alten Änderungen mehr relevant
|
||||
dispatch({ type: "SET_FREE_ADDRESS_ROWS", rows: newData });
|
||||
}
|
||||
});
|
||||
@@ -4561,18 +4595,6 @@ function renderCombinedPlaceholderTable(
|
||||
}
|
||||
table.appendChild(tbody);
|
||||
|
||||
// Focusout-Handler: Speichern wenn Fokus die Tabelle verlässt
|
||||
let focusoutTimer = null;
|
||||
table.addEventListener("focusout", (e) => {
|
||||
if (focusoutTimer) clearTimeout(focusoutTimer);
|
||||
focusoutTimer = setTimeout(() => {
|
||||
const newFocus = document.activeElement;
|
||||
if (!table.contains(newFocus)) {
|
||||
saveLocalChanges();
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
|
||||
// Paste-Handler für Excel-Daten
|
||||
table.addEventListener("paste", (e) => {
|
||||
e.preventDefault();
|
||||
@@ -4814,20 +4836,26 @@ function renderPlaceholderTable(
|
||||
}
|
||||
table.appendChild(tbody);
|
||||
|
||||
// Focusout-Handler mit Debounce - analog zur Empfängertabelle
|
||||
let focusoutTimer = null;
|
||||
let hasLocalChanges = false; // Track ob lokale Änderungen gemacht wurden
|
||||
table.addEventListener("focusout", (e) => {
|
||||
if (focusoutTimer) clearTimeout(focusoutTimer);
|
||||
focusoutTimer = setTimeout(() => {
|
||||
const newFocus = document.activeElement;
|
||||
if (!table.contains(newFocus) && hasLocalChanges) {
|
||||
// Nur dispatchen wenn lokale Änderungen gemacht wurden
|
||||
dispatch({ type: "SET_PLACEHOLDER_VALUES", values: localValues });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
// Save-Funktion für Registry (wird bei Navigation und periodisch aufgerufen)
|
||||
let hasLocalChanges = false;
|
||||
const saveLocalChanges = () => {
|
||||
if (hasLocalChanges) {
|
||||
dispatch({ type: "SET_PLACEHOLDER_VALUES", values: localValues });
|
||||
hasLocalChanges = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Bei globaler Registry registrieren
|
||||
const unregisterSave = registerTableSave(saveLocalChanges);
|
||||
|
||||
// Auto-Save alle 60 Sekunden
|
||||
const autoSaveInterval = setInterval(saveLocalChanges, 60000);
|
||||
|
||||
// Cleanup-Funktion
|
||||
table._cleanup = () => {
|
||||
if (autoSaveInterval) clearInterval(autoSaveInterval);
|
||||
unregisterSave();
|
||||
};
|
||||
|
||||
// Änderungen tracken bei Input
|
||||
table.addEventListener("input", () => {
|
||||
@@ -4881,6 +4909,7 @@ function renderPlaceholderTable(
|
||||
|
||||
// Einmal dispatch für alle Änderungen
|
||||
if (pastedCells > 0) {
|
||||
hasLocalChanges = false; // Paste übernimmt - keine alten Änderungen mehr relevant
|
||||
dispatch({ type: "SET_PLACEHOLDER_VALUES", values: localValues });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user