Fix codice_univoco truncation error on Stabile sync and improve sidebar scroll persistence in Filament UI
This commit is contained in:
parent
7d3bede792
commit
248bdd032c
|
|
@ -574,7 +574,7 @@ public function syncRubricaContatto(): RubricaUniversale
|
|||
|
||||
$data = [
|
||||
'amministratore_id' => $this->amministratore_id,
|
||||
'codice_univoco' => 'STABILE-' . $this->codice_stabile,
|
||||
'codice_univoco' => substr('ST-' . $this->codice_stabile, 0, 8),
|
||||
'categoria' => 'condomino', // Usiamo condomino o altra categoria gestita
|
||||
'tipo_contatto' => 'persona_giuridica',
|
||||
'ragione_sociale' => $this->denominazione,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@
|
|||
|
||||
<script>
|
||||
(function() {
|
||||
let isNavigating = false;
|
||||
let isRestoring = false;
|
||||
|
||||
const getSidebar = () => {
|
||||
return document.querySelector('.fi-sidebar-nav') ||
|
||||
document.querySelector('aside nav') ||
|
||||
|
|
@ -53,7 +56,11 @@
|
|||
};
|
||||
|
||||
const handleScroll = (e) => {
|
||||
localStorage.setItem('fi-sidebar-scroll-top', e.currentTarget.scrollTop);
|
||||
if (isNavigating || isRestoring) {
|
||||
return;
|
||||
}
|
||||
const scrollTop = e.currentTarget.scrollTop;
|
||||
localStorage.setItem('fi-sidebar-scroll-top', scrollTop);
|
||||
};
|
||||
|
||||
const restoreScroll = () => {
|
||||
|
|
@ -63,16 +70,28 @@
|
|||
const savedScroll = localStorage.getItem('fi-sidebar-scroll-top');
|
||||
if (savedScroll !== null) {
|
||||
const scrollTopVal = parseInt(savedScroll, 10);
|
||||
sidebar.scrollTop = scrollTopVal;
|
||||
requestAnimationFrame(() => {
|
||||
sidebar.scrollTop = scrollTopVal;
|
||||
});
|
||||
if (scrollTopVal <= 0) return;
|
||||
|
||||
isRestoring = true;
|
||||
|
||||
let attempts = 0;
|
||||
const maxAttempts = 10;
|
||||
|
||||
const applyScroll = () => {
|
||||
const sb = getSidebar();
|
||||
if (!sb) return;
|
||||
sb.scrollTop = scrollTopVal;
|
||||
attempts++;
|
||||
if (attempts < maxAttempts) {
|
||||
requestAnimationFrame(applyScroll);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
sidebar.scrollTop = scrollTopVal;
|
||||
}, 50);
|
||||
setTimeout(() => {
|
||||
sidebar.scrollTop = scrollTopVal;
|
||||
}, 150);
|
||||
isRestoring = false;
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
applyScroll();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -85,14 +104,26 @@
|
|||
};
|
||||
|
||||
const init = () => {
|
||||
isNavigating = false;
|
||||
restoreScroll();
|
||||
setupScrollListener();
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
|
||||
document.addEventListener('livewire:navigating', () => {
|
||||
isNavigating = true;
|
||||
});
|
||||
document.addEventListener('livewire:navigated', init);
|
||||
document.addEventListener('livewire:load', init);
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
isNavigating = true;
|
||||
});
|
||||
window.addEventListener('pagehide', () => {
|
||||
isNavigating = true;
|
||||
});
|
||||
|
||||
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
||||
init();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user