Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
7.7 KiB
Reference Data Import System
Overview
The Reference Data Import System allows multi-tenant organizations to import pre-defined standard reference data types into their tenant-specific tables. This feature provides consistency across deployments while maintaining tenant isolation.
Architecture
Database Structure
The system uses a two-tier approach:
- Standard Reference Tables - System-wide tables containing pre-defined reference data
- Tenant-Specific Tables - Per-tenant copies of reference data that can be customized
standard_* tables (system-wide)
↓ import
tenant tables (per-organization)
Standard Reference Tables
The following standard reference tables are available:
standard_boards- Organizational containers/boards for grouping categoriesstandard_service_categories- Categories for service catalog itemsstandard_categories- Ticket/project categories with parent-child relationshipsstandard_priorities- Ticket priority levelsstandard_statuses- Ticket status optionsstandard_service_types- Service billing typesstandard_interaction_types- Types of customer interactions
User Interface
Accessing Import Functionality
All reference data types that support importing include an "Import from Standard Types" button on their respective settings pages:
- Navigate to Settings → General → Ticketing Settings
- Select the appropriate tab (Priorities, Statuses, Boards, Categories, etc.)
- Click the "Import from Standard Types" button
Import Process
1. Selection Dialog
When clicking "Import from Standard Types", users see:
- A list of all available standard items
- Checkboxes to select individual items or select all via header checkbox
- Visual indicators:
- For boards: Active/Inactive switches and Default status
- For categories: Hierarchical display with parent-child relationships
- Display order for all items
2. Additional Options
Categories Import:
- Requires selecting a target board
- All imported categories will be assigned to the selected board
- Parent-child relationships are preserved
3. Conflict Resolution
If imported items conflict with existing data, users see:
Name Conflicts: When an item with the same name exists
- Skip the item
- Import with a new name (editable)
Order Conflicts: When the display order is already in use
- Import with suggested next available order
4. Import Confirmation
After successful import:
- Toast notification confirms success
- Table automatically refreshes to show new items
- Items maintain their relative ordering
Features
Parent-Child Relationships (Categories)
Categories support hierarchical organization:
- Parent categories can be assigned to different boards
- Subcategories inherit their parent's board
- Changing a parent's board updates all subcategories
- Visual indentation shows hierarchy
Display Ordering
All reference data types support custom display ordering:
- Order is preserved during import
- Conflicts are automatically resolved
- Subcategories are ordered within their parent
Board Assignment (Categories)
- Parent categories must have a board
- Subcategories inherit parent's board
- Board can be edited for parent categories only
- Warning shown when changing affects subcategories
Active/Default Flags
Boards:
is_inactive- Marks board as inactiveis_default- Sets default board for client portal- Only one board can be default at a time
Other Types:
- Most types include
is_activeor similar status flags - Inactive items can be hidden from selection lists
Implementation Details
Server Actions
The import system uses server actions for all operations:
// Get available standard data
const available = await getAvailableReferenceData(dataType);
// Check for conflicts before import
const conflicts = await checkImportConflicts(dataType, selectedIds, options);
// Import with conflict resolution
await importReferenceData(dataType, selectedIds, options, resolutions);
Database Schema
Standard tables include:
id(UUID) - Unique identifier*_name- Display namedescription- Optional descriptiondisplay_order- Sort ordercreated_at/updated_at- Timestamps
Tenant tables add:
tenant- Tenant identifiercreated_by- User who created the record- Additional tenant-specific fields
Migration
The standard reference data is populated via migration:
migrations/20250630140000_create_standard_reference_tables.cjs
This ensures consistent data across all deployments.
Best Practices
For Administrators
- Review Before Import: Check existing data to avoid duplicates
- Plan Channel Assignment: For categories, decide channel strategy first
- Maintain Naming Conventions: Use consistent naming across imports
- Order Management: Review display orders after import
For Developers
-
Adding New Reference Types:
- Create standard table via migration
- Add configuration to
referenceDataActions.ts - Implement UI component following existing patterns
- Include proper TypeScript interfaces
-
Customizing Import Behavior:
- Override
mapFieldsfor special field handling - Add custom validation in
validateImport - Implement special conflict resolution if needed
- Override
Supported Reference Types
Currently Implemented
-
Channels (
/settings/general/ticketing)- Import organizational groupings for categories
- Set active/inactive status
- Designate default channel for client portal
-
Categories (
/settings/general/ticketing)- Import with parent-child relationships
- Assign to channels
- Hierarchical display and ordering
-
Service Categories (
/settings/billing)- Import billing categories
- Used for service catalog organization
-
Priorities (
/settings/general/ticketing)- Import priority levels
- Set colors and ordering
-
Statuses (
/settings/general/ticketing)- Import ticket statuses
- Configure status types
-
Service Types (
/settings/billing)- Import billing methods
- Configure service billing types
-
Interaction Types (
/settings/general/ticketing)- Import customer interaction types
- Used for tracking communication methods
Adding New Types
To add import functionality to a new reference type:
- Create the standard table with migration
- Add type configuration to
referenceDataConfig - Update the component to include import button
- Test conflict resolution scenarios
Troubleshooting
Common Issues
"No standard items available to import"
- Check if migration has run successfully
- Verify standard table has data
Import fails with constraint error
- Check for required fields (e.g.,
created_by) - Ensure proper tenant context
Items not appearing after import
- Verify filter settings (channel filter for categories)
- Check if items were marked as inactive
Duplicate name errors
- Use conflict resolution dialog
- Consider unique naming strategy
Debug Tips
- Check browser console for detailed errors
- Verify server logs for constraint violations
- Inspect network tab for failed requests
- Review database for data integrity
Future Enhancements
Potential improvements to the import system:
-
Bulk Operations
- Export current configuration
- Import from CSV/JSON
- Copy between tenants
-
Template Management
- Save import selections as templates
- Share templates between organizations
-
Advanced Filtering
- Filter standard items by category
- Search within import dialog
- Preview before import
-
Audit Trail
- Track who imported what and when
- Rollback capabilities
- Change history