/** * Workflow Step Component Registry * * This module handles the dynamic loading and registration of workflow step components. * It provides a centralized way to map workflow types and steps to their corresponding Vue components. */ // Import all step components import FotoFirstStep1 from './steps/FotoFirstStep1.vue'; import FotoFirstStep2 from './steps/FotoFirstStep2.vue'; import FotoFirstStep3 from './steps/FotoFirstStep3.vue'; import FotoFirstStep4 from './steps/FotoFirstStep4.vue'; import BulkImportStep1 from './steps/BulkImportStep1.vue'; import BulkImportStep6 from './steps/BulkImportStep6.vue'; /** * Component registry mapping workflow types and steps to components * Format: 'workflowType-step' -> Component */ const componentRegistry = { // Foto First Import Workflow components 'foto-first-bulk-import-1': FotoFirstStep1, 'foto-first-bulk-import-2': FotoFirstStep2, 'foto-first-bulk-import-3': FotoFirstStep3, 'foto-first-bulk-import-4': FotoFirstStep4, // Bulk Item Import Workflow components 'import-items-1': BulkImportStep1, 'import-items-6': BulkImportStep6, // Additional steps can be added as needed // 'import-items-2': BulkImportStep2, // 'import-items-3': BulkImportStep3, // ... etc }; /** * Get a step component for a given workflow type and step * @param {string} workflowType - The workflow type identifier * @param {string|number} step - The step identifier * @returns {Object|null} Vue component or null if not found */ export function getStepComponent(workflowType, step) { const componentKey = `${workflowType}-${step}`; return componentRegistry[componentKey] || null; } /** * Register a new step component * @param {string} workflowType - The workflow type identifier * @param {string|number} step - The step identifier * @param {Object} component - The Vue component */ export function registerStepComponent(workflowType, step, component) { const componentKey = `${workflowType}-${step}`; componentRegistry[componentKey] = component; } /** * Get all registered components for a workflow type * @param {string} workflowType - The workflow type identifier * @returns {Object} Object with step numbers as keys and components as values */ export function getWorkflowComponents(workflowType) { const workflowComponents = {}; Object.keys(componentRegistry).forEach(key => { if (key.startsWith(`${workflowType}-`)) { const step = key.replace(`${workflowType}-`, ''); workflowComponents[step] = componentRegistry[key]; } }); return workflowComponents; } /** * Check if a step component exists for a workflow type and step * @param {string} workflowType - The workflow type identifier * @param {string|number} step - The step identifier * @returns {boolean} True if component exists, false otherwise */ export function hasStepComponent(workflowType, step) { const componentKey = `${workflowType}-${step}`; return componentKey in componentRegistry; } /** * Get all registered workflow types * @returns {Array} Array of workflow type identifiers */ export function getRegisteredWorkflowTypes() { const workflowTypes = new Set(); Object.keys(componentRegistry).forEach(key => { const parts = key.split('-'); if (parts.length >= 2) { // Reconstruct workflow type (everything except the last part which is the step) const workflowType = parts.slice(0, -1).join('-'); workflowTypes.add(workflowType); } }); return Array.from(workflowTypes); } export default { getStepComponent, registerStepComponent, getWorkflowComponents, hasStepComponent, getRegisteredWorkflowTypes };