abite 7c30fc4a0c
feat: implement asset and component duplication feature (#79) (#93)
* feat: implement asset and component duplication feature (#79)

Add comprehensive duplication functionality allowing users to create multiple
copies of existing assets and components with sequential naming and sanitized data.

- **Duplicate Buttons**: Added duplicate buttons between Save/Cancel in asset and sub-asset modals
- **Smart Visibility**: Buttons only appear in edit mode (not when creating new items)
- **Sequential Naming**: Duplicates automatically named with incremental numbers (e.g., "Asset Name (1)", "Asset Name (2)")
- **Input Validation**: Users can create 1-100 duplicates with proper validation
- **Data Sanitization**: Excludes serial numbers, warranty info, files, and maintenance events from duplicates
- **Bulk Operations**: Efficient server-side bulk creation endpoints

- **public/index.html**:
  - Added duplicate buttons to asset and sub-asset modal form-actions
  - Added duplicate confirmation modal with count input
  - Updated help text to explain sequential naming and data exclusions

- **public/styles.css**:
  - Added styling for duplicate buttons with hover states
  - Added duplicate modal and input styling
  - Added responsive design support

- **public/managers/modalManager.js**:
  - Extended with complete duplication functionality
  - Added duplicate modal management methods
  - Implemented sequential naming logic
  - Added data sanitization for duplicates

- **public/script.js**:
  - Added duplicate modal to escape key handler
  - Added click-off-to-close functionality
  - Exposed refreshAllData for ModalManager access

- **server.js**:
  - Added `/api/assets/bulk` endpoint for bulk asset creation
  - Added `/api/subassets/bulk` endpoint for bulk sub-asset creation
  - Added validation for bulk operations (max 100 items)
  - Added notification support for bulk operations
  - Restored accidentally removed endpoints (settings, uploads, etc.)

- **Data Processing**: Strips sensitive data while preserving core asset information
- **Error Handling**: Comprehensive validation and user feedback
- **Performance**: Bulk server operations for efficiency
- **UX**: Loading states, success messages, keyboard shortcuts

Perfect for scenarios like:
- Creating multiple identical hard drives with different serial numbers
- Duplicating network equipment across locations
- Bulk adding similar components to inventory
- Setting up template assets for mass deployment

Resolves #79

* reorg styles.css

* Add properties grid to duplicate asset/subasset modal

* Add components and sub components duplication option to duplicate grid

* update file previews for subcomponents to support multiple file paths

* minor updates to duplicate modal styling

* update duplicate sub asset button icon

* Add duplicate button to asset / subasset actions

* apply svg styles to duplicate asset-actions buttons

* Fix component's sub component duplication

* Fix rendering proper asset / subasset after duplication

* refactor duplication/clone assets code into it's own manager class as well as closing asset modals after performing duplication

* fix asset navigation after duplicating an asset

---------

Co-authored-by: gitmotion <43588713+gitmotion@users.noreply.github.com>
2025-06-16 12:18:01 -07:00
..
2025-06-12 03:07:09 -07:00
2025-05-11 11:41:18 -07:00
2025-05-11 11:41:18 -07:00