From 3f452a46a37f05129ecd4edefadf913861e8daab Mon Sep 17 00:00:00 2001 From: Afiq Date: Wed, 6 Aug 2025 13:06:29 +0800 Subject: [PATCH] Enhance Button Configuration and Link Functionality in Form Builder - Introduced new settings for button components in the FormBuilderFieldSettingsModal, allowing users to configure link types (none, custom URL, process link) and corresponding URLs or process IDs. - Added functionality to dynamically generate button links based on user selections, improving the flexibility of button actions in the form builder. - Updated ComponentPreview.vue to conditionally render buttons as links or regular buttons based on the new configuration options. - Enhanced the form builder interface to include fields for specifying the number of rows for textareas, improving usability and customization. - Implemented fetching of published processes for linking, ensuring users can select from available processes when configuring button actions. --- components/ComponentPreview.vue | 37 +++++- components/FormBuilderFieldSettingsModal.vue | 129 +++++++++++++++++++ pages/form-builder/index.vue | 90 ++++++++++++- 3 files changed, 253 insertions(+), 3 deletions(-) diff --git a/components/ComponentPreview.vue b/components/ComponentPreview.vue index a138c07..ca0b492 100644 --- a/components/ComponentPreview.vue +++ b/components/ComponentPreview.vue @@ -32,7 +32,8 @@ :accept="component.props.accept || undefined" :max="component.props.max || undefined" :mask="component.props.mask || undefined" :digits="component.props.digits || undefined" :multiple="component.props.multiple || undefined" :maxSize="component.props.maxSize || undefined" - :maxFiles="component.props.maxFiles || undefined" :classes="component.type === 'checkbox' ? { + :maxFiles="component.props.maxFiles || undefined" :rows="component.type === 'textarea' ? (component.props.rows || 3) : undefined" + :classes="component.type === 'checkbox' ? { wrapper: 'mb-1', options: 'space-y-0.5' } : {}" :class="{ @@ -335,7 +336,21 @@ {{ component.props.label }} - + + + {{ component.props.buttonText || component.props.label || 'Button' }} + + + + + + {{ component.props.buttonText || component.props.label || 'Button' }} @@ -1245,6 +1260,24 @@ const saveNestedComponentSettings = (updatedComponent) => { // Close the modal closeNestedSettingsModal(); }; + +// Button link functionality +const getButtonLink = () => { + if (!props.component || props.component.type !== 'button') return null; + + const { linkType, linkUrl, linkProcessId, linkTarget } = props.component.props; + + if (linkType === 'url' && linkUrl) { + return linkUrl; + } + + if (linkType === 'process' && linkProcessId) { + // Generate the process workflow URL + return `${window.location.origin}/workflow/${linkProcessId}`; + } + + return null; +};