- Implemented complete API system with REST endpoints for all process operations, including CRUD functionality. - Added support for direct process linking via URL parameters, improving navigation and usability. - Enhanced save functionality with success/error notifications and improved state management. - Fixed navigation issues, including unsaved changes detection and automatic URL synchronization. - Resolved Vue Flow interference, allowing for seamless connector dragging between nodes. - Ensured backward compatibility for legacy process definitions, automatically upgrading them. - Introduced comprehensive toast notifications for user feedback on all operations. - Optimized performance by reducing re-renders and improving memory management. - Enhanced error handling with robust validation and graceful recovery throughout the system. - Updated UI consistency across form builder and process builder management interfaces.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
// Initialize Prisma client
|
|
const prisma = new PrismaClient();
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Get the process ID from the route parameter
|
|
const processId = getRouterParam(event, 'id');
|
|
|
|
if (!processId) {
|
|
return {
|
|
success: false,
|
|
error: 'Process ID is required'
|
|
};
|
|
}
|
|
|
|
// Check if the ID is a UUID or numeric ID
|
|
const isUUID = processId.length === 36 && processId.includes('-');
|
|
|
|
// Find the process by UUID or ID
|
|
const process = await prisma.process.findFirst({
|
|
where: isUUID
|
|
? { processUUID: processId }
|
|
: { processID: parseInt(processId) },
|
|
include: {
|
|
creator: {
|
|
select: {
|
|
userID: true,
|
|
userFullName: true,
|
|
userUsername: true
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
if (!process) {
|
|
return {
|
|
success: false,
|
|
error: 'Process not found'
|
|
};
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
process
|
|
};
|
|
} catch (error) {
|
|
console.error('Error fetching process:', error);
|
|
|
|
return {
|
|
success: false,
|
|
error: 'Failed to fetch process',
|
|
details: process.env.NODE_ENV === 'development' ? error.message : undefined
|
|
};
|
|
}
|
|
});
|