Collection Set Operations - Vue Window Implementation
Overview
Replaced dialog-based collection set operations with a proper Vue window interface. This provides better UX with:
- Visual collection selection
- Operation previews (item counts)
- Backup option
- Better error handling
- Modern, consistent UI
Implementation
New Files Created
app/render/vue/windows/CollectionSetOperations/CollectionSetOperations.vue
- Main Vue component with reactive UI
- Handles 4 operations: add, remove, intersect, addAll
- Shows preview statistics before execution
- Success/error feedback
app/render/vue/windows/CollectionSetOperations/main.js
- Vue app initialization
- Mounts component to DOM
app/render/vue/windows/CollectionSetOperations/preload.js
- IPC bridge for secure renderer-main communication
- Exposes: getCollections, getCollectionItems, executeCollectionOperation
app/render/vue/windows/CollectionSetOperations/index.html
- Entry point for Vue window
Modified Files
app/main/ipc/collectionHandlers.js
- Added
collection:executeSetOperationIPC handler - Validates input, executes operation, returns results
- Supports optional user backup (in addition to automatic backup)
- Added
app/main/windows/windowManager.js
- Added
createCollectionSetOperationsWindow()function - Passes operation type and target collection via URL params
- Manages window lifecycle
- Added
app/main/main.js
- Added
collectionSetOperationsto windowRefs - Replaced 4 long dialog-based functions with simple window openers
- Each function now just validates and opens the Vue window
- Added
vite.config.js
- Added
collectionSetOperationsto window paths mapping
- Added
Operations Supported
1. Add Items from Collection (Union)
- Menu: Collections > Add Items from Collection
- Operation: Adds all items from source collection to target
- Duplicates: Automatically skipped
2. Remove Items (in Collection) (Difference)
- Menu: Collections > Remove Items (in Collection)
- Operation: Removes items that exist in source from target
- Non-existent: Items in source but not in target are ignored
3. Intersect with Collection
- Menu: Collections > Intersect with Collection
- Operation: Keeps only items that exist in both collections
- Result: Target contains only common items
4. Add All Archive Items
- Menu: Collections > Add All Archive Items
- Operation: Adds every item from the archive to target
- Duplicates: Automatically skipped
Technical Details
URL Parameters
Window receives operation details via query params:
file:///.../collectionSetOperations/index.html?operation=add&targetCollection=favoritesIPC Communication
From Renderer:
javascript
window.electronAPI.executeCollectionOperation({
operation: 'add', // 'add', 'remove', 'intersect', 'addAll'
targetCollection: 'key',
sourceCollection: 'key', // not needed for 'addAll'
createBackup: true
})From Main:
javascript
{
success: true,
message: "Added 5 items...",
addedCount: 5,
skippedCount: 2,
backupFile: "favorites_backup_20250101_120000.json"
}Backup Strategy
- Automatic Backup: CollectionsClass methods create timestamped backups before modifications
- Optional User Backup: Checkbox in UI creates additional backup collection
- Backup Location:
collections/{collectionKey}_backup_{timestamp}.json
Testing
Prerequisites
- Have at least 2 collections created
- Collections should have some overlapping and some unique items
Test Cases
Test 1: Add Items from Collection
- Select a target collection from dropdown
- Menu: Collections > Add Items from Collection
- Select source collection
- Verify preview shows correct counts
- Click "Add Items"
- Verify success message and counts
- Verify target collection updated in main window
Test 2: Remove Items
- Create two collections with some common items
- Select target from dropdown
- Menu: Collections > Remove Items (in Collection)
- Select source collection
- Verify preview shows items to remove
- Click "Remove Items"
- Verify common items removed from target
Test 3: Intersect
- Create collections with partial overlap
- Select target collection
- Menu: Collections > Intersect with Collection
- Select source collection
- Verify preview shows kept/removed counts
- Click "Apply Intersection"
- Verify only common items remain
Test 4: Add All Archive Items
- Select a collection
- Menu: Collections > Add All Archive Items
- Verify preview shows items to add
- Click "Add All Items"
- Verify collection now contains all archive items
Test 5: Error Handling
- Try operations with no collection selected
- Verify friendly error dialog
- Try operation with only one collection existing
- Verify appropriate message
Test 6: Backup Verification
- Enable "Create backup" checkbox
- Execute any operation
- Check collection dropdown for backup collection
- Verify backup contains pre-operation state
Benefits Over Old Implementation
Before (Dialog-based)
- ❌ Multiple blocking dialogs
- ❌ No visual preview
- ❌ Poor UX for collection selection
- ❌ Limited error feedback
- ❌ Inconsistent with rest of app
After (Vue Window)
- ✅ Single unified window
- ✅ Live preview of operation results
- ✅ Dropdown selection with item counts
- ✅ Clear success/error messages
- ✅ Matches PersonManager, MediaManager patterns
- ✅ Optional user backup in addition to automatic
Future Enhancements
- Preview Details: Show actual item lists before execution
- Undo Support: Quick undo button to restore from backup
- Multiple Source Selection: Add from multiple collections at once
- Operation History: Track recent set operations
- Progress Bar: For large collections
- Dry Run Mode: Show what would happen without executing
