mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-19 01:41:37 +00:00
Turbo-Kompatibilität verbessern.
Hinzufügen von Prüfungen auf Vorhandensein von DOM-Elementen in mehreren Controllern sowie Optimierung der Form-Submit-Logik für bessere Turbo-Integration. Anpassung von Template-Elementen und JavaScript-Events zur Unterstützung von Turbo Morphing auf der Startseite.
This commit is contained in:
parent
66c905738d
commit
563d39ff2d
9 changed files with 104 additions and 35 deletions
|
|
@ -35,6 +35,7 @@ class RegisterEventHelper {
|
|||
});
|
||||
|
||||
this.registerModalDropRemovalOnFormSubmit();
|
||||
this.registerHomepageCleanupOnSearch();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -63,6 +64,39 @@ class RegisterEventHelper {
|
|||
document.addEventListener('turbo:load', fn);
|
||||
}
|
||||
|
||||
registerHomepageCleanupOnSearch() {
|
||||
const cleanup = () => {
|
||||
const ids = [
|
||||
'homepage-banner-container',
|
||||
'homepage-last-activity-container',
|
||||
'homepage-search-container',
|
||||
'homepage-first-steps',
|
||||
'homepage-license',
|
||||
'new-version-alert'
|
||||
];
|
||||
|
||||
const isSearchPage = window.location.pathname.includes('/search') || window.location.search.includes('keyword=');
|
||||
|
||||
ids.forEach(id => {
|
||||
const elements = document.querySelectorAll('#' + id);
|
||||
elements.forEach(el => {
|
||||
if (isSearchPage) {
|
||||
//We hide it, instead of removing it, to not break Turbo Morphing anchors
|
||||
el.style.setProperty('display', 'none', 'important');
|
||||
} else {
|
||||
//On non-search pages, we ensure it is visible again if it was hidden by this script
|
||||
//But only if it's not one of the "anchor" divs from base.html.twig which should stay hidden
|
||||
if (el.hasAttribute('data-turbo-temporary')) {
|
||||
el.style.display = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.registerLoadHandler(cleanup);
|
||||
}
|
||||
|
||||
configureDropdowns() {
|
||||
this.registerLoadHandler(() => {
|
||||
//Set the dropdown strategy to fixed, so that the dropdowns are not cut off by the overflow: hidden of the body.
|
||||
|
|
@ -328,4 +362,4 @@ class RegisterEventHelper {
|
|||
}
|
||||
}
|
||||
|
||||
export default new RegisterEventHelper();
|
||||
export default new RegisterEventHelper();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue