- Add MaterialTypeManagementDialog component for managing material type keywords - Add MaterialsTypeToBeDeletedDAO for database operations - Add material-type-handler IPC handlers - Update CleanerPage with type management button - Add database fix scripts for AUTO_INCREMENT - Update documentation for settings partial save and validation flow Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
1.6 KiB
1.6 KiB
Settings Partial Save Feature
Overview
The settings system now implements partial save functionality to prevent unintended overwrites of configuration values.
How It Works
- Field Whitelist: Only fields exposed in the UI can be modified
- Deep Merge: Updates are merged with existing config, preserving unmodified fields
- Backup & Rollback: Config is backed up before save; failures trigger automatic rollback
Editable Fields
Currently editable via UI:
erp.url- ERP system URLerp.username- ERP login usernameerp.password- ERP login password
Adding New Editable Fields
To add a new field to the UI:
- Add field to whitelist in
src/main/services/config/config-manager.ts:
const UI_EDITABLE_FIELDS: string[] = [
'erp.url',
'erp.username',
'erp.password',
'database.dbType' // Add new field here
]
- Add UI input in
src/renderer/src/pages/SettingsPage.tsx - Update
handleSaveSettingsto include the new field
API
savePartialSettings(settings: Partial)
Saves only the provided fields, preserving all existing configuration.
Returns: { success: boolean, error?: string }
Validation:
- Checks whitelist before applying changes
- Returns error for unauthorized fields
Error Handling
- Unauthorized field: Returns error message listing invalid fields
- Save failure: Automatically restores from backup
- Backup failure: Logs warning, continues with save
Backup File
Location: .env.backup (in project root)
Created before every save operation. Used for rollback on failure.