feat: Enhance DashboardConfigurePage with drag-and-drop functionality and improved widget search
- Added drag-and-drop support for widget reordering in the dashboard configuration. - Introduced a new search input for filtering widgets, enhancing user experience. - Updated layout editor with a new function to move widgets between indices. - Improved responsiveness by implementing viewport detection for drag-and-drop features. - Refactored state management for better handling of widget visibility and search functionality.
This commit is contained in:
1 parent
e4e2f23d7f
commit
ff95ef63c7
2 files changed
+286
-84
No files matched your search
@@ -25,3 +25,17 @@ export function toggleWidget(layout, index) {
|
||||
if (!anyOn) return layout
|
||||
return { ...layout, widgets: next }
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschiebt eine Zeile von fromIndex nach dropIndex (Indizes im vollen layout.widgets).
|
||||
* Semantik wie üblich: Element landet an Position dropIndex (nach Entfernen an der alten Stelle).
|
||||
*/
|
||||
export function moveWidgetToIndex(layout, fromIndex, dropIndex) {
|
||||
if (!layout?.widgets?.length) return layout
|
||||
if (fromIndex < 0 || fromIndex >= layout.widgets.length) return layout
|
||||
if (dropIndex < 0 || dropIndex > layout.widgets.length) return layout
|
||||
if (fromIndex === dropIndex) return layout
|
||||
const next = [...layout.widgets]
|
||||
next.splice(dropIndex, 0, next.splice(fromIndex, 1)[0])
|
||||
return { ...layout, widgets: next }
|
||||
}
|
||||
Reference in new issue
Block a user