feat(dashboard): add confirmations, fix UX issues, and optimize grid rendering
BREAKING CHANGE: applyDashboardConfig() now accepts optional second parameter for optimization Add auto-arrange confirmation dialog: - Add warning popup before auto-arranging widgets across all tabs - Follows same pattern as reset layout confirmation - Prevents accidental destructive operations Fix text selection interference: - Apply user-select: none to entire .rpg-widget in edit mode - Previously only applied to .rpg-widget-content - Prevents text selection when dragging widgets, especially in attribute boxes - Improves drag interaction on both desktop and mobile Fix edit controls visibility: - Add CSS rule to completely hide edit controls outside edit mode - Controls now properly hidden when not in edit mode - Settings button (⚙) kept for future widget configuration Fix input disabling in edit mode: - Call disableContentEditing() after tab switches in onTabChange() - Call disableContentEditing() in syncAllControls() - Ensures text fields remain non-editable in edit mode after all operations Fix resize grid background rendering: - Copy drag handler grid logic EXACTLY to resize handler - Use gridEngine.calculateGridHeight(widgets) instead of manual calculation - Add proper remToPixels() conversions for gap and rowHeight - Pass widgets array through initWidget() and startResize() - Grid now renders correctly during resize, matching drag behavior Optimize layout operations: - Add skipInitialSwitch option to applyDashboardConfig() - Prevents redundant clearGrid() calls during resetLayout() - Defers rendering until after layout calculations complete Files modified: - dashboardIntegration.js: Auto-arrange confirmation - dashboardManager.js: skipInitialSwitch option, input disabling, widgets array - editModeManager.js: Input disabling in syncAllControls() - resizeHandler.js: Grid rendering fixes with proper unit conversions - style.css: Text selection prevention, edit controls visibility
This commit is contained in:
@@ -705,7 +705,7 @@ export class DashboardManager {
|
||||
}, {
|
||||
minW: definition.minSize.w,
|
||||
minH: definition.minSize.h
|
||||
});
|
||||
}, allWidgets);
|
||||
|
||||
// Add edit mode controls
|
||||
if (this.editManager) {
|
||||
@@ -1104,6 +1104,11 @@ export class DashboardManager {
|
||||
});
|
||||
}
|
||||
|
||||
// Disable content editing if in edit mode
|
||||
if (this.editManager && this.editManager.isEditMode) {
|
||||
this.editManager.disableContentEditing();
|
||||
}
|
||||
|
||||
this.notifyChange('tabChanged', { tabId });
|
||||
}
|
||||
|
||||
@@ -1283,8 +1288,10 @@ export class DashboardManager {
|
||||
/**
|
||||
* Apply dashboard configuration
|
||||
* @param {Object} config - Dashboard configuration
|
||||
* @param {Object} options - Optional parameters
|
||||
* @param {boolean} options.skipInitialSwitch - Skip switching to first tab (caller will handle)
|
||||
*/
|
||||
applyDashboardConfig(config) {
|
||||
applyDashboardConfig(config, options = {}) {
|
||||
console.log('[DashboardManager] Applying dashboard config');
|
||||
|
||||
// Migrate emoji icons to Font Awesome
|
||||
@@ -1330,8 +1337,8 @@ export class DashboardManager {
|
||||
this.dashboard.defaultTab = this.dashboard.tabs[0].id;
|
||||
}
|
||||
|
||||
// Switch to first tab
|
||||
if (config.tabs.length > 0) {
|
||||
// Switch to first tab (unless caller will handle it)
|
||||
if (!options.skipInitialSwitch && config.tabs.length > 0) {
|
||||
this.switchTab(config.tabs[0].id);
|
||||
}
|
||||
|
||||
@@ -1418,7 +1425,8 @@ export class DashboardManager {
|
||||
});
|
||||
|
||||
await this.persistence.resetToDefault(this.defaultLayout);
|
||||
this.applyDashboardConfig(this.defaultLayout);
|
||||
// Skip initial switch in applyDashboardConfig since we'll switch after layout calculations
|
||||
this.applyDashboardConfig(this.defaultLayout, { skipInitialSwitch: true });
|
||||
|
||||
// Reset all widgets to default sizes
|
||||
const allWidgets = [];
|
||||
|
||||
Reference in New Issue
Block a user