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 = [
|
$data = [
|
||||||
'amministratore_id' => $this->amministratore_id,
|
'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
|
'categoria' => 'condomino', // Usiamo condomino o altra categoria gestita
|
||||||
'tipo_contatto' => 'persona_giuridica',
|
'tipo_contatto' => 'persona_giuridica',
|
||||||
'ragione_sociale' => $this->denominazione,
|
'ragione_sociale' => $this->denominazione,
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
|
let isNavigating = false;
|
||||||
|
let isRestoring = false;
|
||||||
|
|
||||||
const getSidebar = () => {
|
const getSidebar = () => {
|
||||||
return document.querySelector('.fi-sidebar-nav') ||
|
return document.querySelector('.fi-sidebar-nav') ||
|
||||||
document.querySelector('aside nav') ||
|
document.querySelector('aside nav') ||
|
||||||
|
|
@ -53,7 +56,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleScroll = (e) => {
|
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 = () => {
|
const restoreScroll = () => {
|
||||||
|
|
@ -63,16 +70,28 @@
|
||||||
const savedScroll = localStorage.getItem('fi-sidebar-scroll-top');
|
const savedScroll = localStorage.getItem('fi-sidebar-scroll-top');
|
||||||
if (savedScroll !== null) {
|
if (savedScroll !== null) {
|
||||||
const scrollTopVal = parseInt(savedScroll, 10);
|
const scrollTopVal = parseInt(savedScroll, 10);
|
||||||
sidebar.scrollTop = scrollTopVal;
|
if (scrollTopVal <= 0) return;
|
||||||
requestAnimationFrame(() => {
|
|
||||||
sidebar.scrollTop = scrollTopVal;
|
isRestoring = true;
|
||||||
});
|
|
||||||
setTimeout(() => {
|
let attempts = 0;
|
||||||
sidebar.scrollTop = scrollTopVal;
|
const maxAttempts = 10;
|
||||||
}, 50);
|
|
||||||
setTimeout(() => {
|
const applyScroll = () => {
|
||||||
sidebar.scrollTop = scrollTopVal;
|
const sb = getSidebar();
|
||||||
}, 150);
|
if (!sb) return;
|
||||||
|
sb.scrollTop = scrollTopVal;
|
||||||
|
attempts++;
|
||||||
|
if (attempts < maxAttempts) {
|
||||||
|
requestAnimationFrame(applyScroll);
|
||||||
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
isRestoring = false;
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
applyScroll();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -85,14 +104,26 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
|
isNavigating = false;
|
||||||
restoreScroll();
|
restoreScroll();
|
||||||
setupScrollListener();
|
setupScrollListener();
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', init);
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
|
||||||
|
document.addEventListener('livewire:navigating', () => {
|
||||||
|
isNavigating = true;
|
||||||
|
});
|
||||||
document.addEventListener('livewire:navigated', init);
|
document.addEventListener('livewire:navigated', init);
|
||||||
document.addEventListener('livewire:load', init);
|
document.addEventListener('livewire:load', init);
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', () => {
|
||||||
|
isNavigating = true;
|
||||||
|
});
|
||||||
|
window.addEventListener('pagehide', () => {
|
||||||
|
isNavigating = true;
|
||||||
|
});
|
||||||
|
|
||||||
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user