- Introduced a new submit button configuration in the form builder, allowing users to enable/disable the default submit button and customize its label, category, and color. - Updated VariableBrowser.vue to support object property path input for variables, including validation and error handling for property paths. - Enhanced ApiNodeConfiguration.vue to prevent object path creation for output and error variables. - Improved workflow page to respect form builder submit button settings, ensuring consistent behavior across the application. - Added helper functions for managing submit button styles and variants, enhancing the overall user experience.
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
import { PrismaClient } from '@prisma/client';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
// Initialize Prisma client
|
|
const prisma = new PrismaClient();
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Parse the request body
|
|
const body = await readBody(event);
|
|
|
|
// Validate required fields
|
|
if (!body.formName) {
|
|
return {
|
|
success: false,
|
|
error: 'Form name is required'
|
|
};
|
|
}
|
|
|
|
// Create a new form in the database
|
|
const form = await prisma.form.create({
|
|
data: {
|
|
formUUID: uuidv4(),
|
|
formName: body.formName,
|
|
formDescription: body.formDescription || null,
|
|
formComponents: body.components || [],
|
|
formStatus: body.status || 'active',
|
|
formCreatedBy: body.createdBy || null, // In a real app, this would come from the authenticated user
|
|
customScript: body.customScript || null,
|
|
customCSS: body.customCSS || null,
|
|
formEvents: body.formEvents || null,
|
|
scriptMode: body.scriptMode || 'safe',
|
|
submitButton: body.submitButton || null
|
|
}
|
|
});
|
|
|
|
return {
|
|
success: true,
|
|
form
|
|
};
|
|
} catch (error) {
|
|
console.error('Error creating form:', error);
|
|
|
|
return {
|
|
success: false,
|
|
error: 'Failed to create form',
|
|
details: process.env.NODE_ENV === 'development' ? error.message : undefined
|
|
};
|
|
}
|
|
});
|