From 5501c00c7ce52c71a397694d37886332a1f0f2ba Mon Sep 17 00:00:00 2001 From: Md Afiq Iskandar Date: Mon, 7 Jul 2025 16:45:00 +0800 Subject: [PATCH] Enhance Process Builder with Script Task Configuration - Introduced a new ScriptNodeConfiguration component for configuring JavaScript tasks within the process builder. - Added ScriptNodeConfigurationModal for user-friendly script task setup, including input and output variable management. - Updated process management logic to handle script variables directly within the process store, improving variable management and accessibility. - Enhanced existing components to support the new script task feature, ensuring seamless integration with the process flow. - Improved overall user experience with intuitive UI elements and clear documentation for the new functionality. --- assets/style/css/form/box.css | 2 +- components/ConditionalLogicEngine.vue | 16 +- components/FormBuilderComponents.vue | 8 +- components/FormBuilderFieldSettingsModal.vue | 530 ++++++++++-- components/RsCodeMirror.vue | 17 +- components/RsModal.vue | 2 +- .../process-flow/ApiNodeConfiguration.vue | 72 +- .../BusinessRuleNodeConfiguration.vue | 32 +- .../process-flow/FormNodeConfiguration.vue | 8 +- .../process-flow/GatewayConditionManager.vue | 2 +- .../NotificationNodeConfiguration.vue | 1 - .../process-flow/ProcessBuilderComponents.vue | 19 + .../process-flow/ProcessSettingsModal.vue | 11 +- .../process-flow/ScriptNodeConfiguration.vue | 453 ++++++++++ .../ScriptNodeConfigurationModal.vue | 113 +++ components/process-flow/VariableManager.vue | 32 +- composables/useToast.js | 8 +- error.vue | 7 +- pages/dashboard/index.vue | 807 +++++++++--------- pages/notifications/index.vue | 31 +- pages/process-builder/index.vue | 89 +- stores/processBuilder.js | 99 ++- 22 files changed, 1727 insertions(+), 632 deletions(-) create mode 100644 components/process-flow/ScriptNodeConfiguration.vue create mode 100644 components/process-flow/ScriptNodeConfigurationModal.vue diff --git a/assets/style/css/form/box.css b/assets/style/css/form/box.css index fe988a1..c07a0a1 100644 --- a/assets/style/css/form/box.css +++ b/assets/style/css/form/box.css @@ -3,7 +3,7 @@ } .formkit-fieldset-box { - @apply max-w-md border border-[rgb(var(--fk-border-color))] rounded-lg px-4 py-2; + @apply border-0 rounded-lg py-2; } .formkit-legend-box { diff --git a/components/ConditionalLogicEngine.vue b/components/ConditionalLogicEngine.vue index 474ef6a..b9f28cd 100644 --- a/components/ConditionalLogicEngine.vue +++ b/components/ConditionalLogicEngine.vue @@ -24,6 +24,20 @@ const emit = defineEmits(['script-generated']) const generatedScript = ref('') const isInitialized = ref(false) +// Helper function to map operators to valid JavaScript +const getJavaScriptOperator = (operator) => { + switch (operator) { + case 'and': + case 'AND': + return '&&' + case 'or': + case 'OR': + return '||' + default: + return '&&' // Default to AND if unknown operator + } +} + // Generate conditional logic script from form components const generateConditionalLogicScript = () => { const scriptsArray = [] @@ -65,7 +79,7 @@ const generateConditionalLogicScript = () => { default: return `getField('${field}') === '${value}'` } - }).join(` ${operator} `) + }).join(` ${getJavaScriptOperator(operator)} `) // Generate action functions const actionCode = action === 'show' ? `showField('${fieldName}')` : diff --git a/components/FormBuilderComponents.vue b/components/FormBuilderComponents.vue index 235a79b..e8805a9 100644 --- a/components/FormBuilderComponents.vue +++ b/components/FormBuilderComponents.vue @@ -659,7 +659,9 @@ const availableComponents = [ description: 'Section heading text', defaultProps: { value: 'Section Heading', - level: 2 + level: 2, + width: '100%', + gridColumn: 'span 12' } }, { @@ -669,7 +671,9 @@ const availableComponents = [ icon: 'material-symbols:text-snippet-outline', description: 'Paragraph of text', defaultProps: { - value: 'Enter some descriptive text here.' + value: 'Enter some descriptive text here.', + width: '100%', + gridColumn: 'span 12' } }, { diff --git a/components/FormBuilderFieldSettingsModal.vue b/components/FormBuilderFieldSettingsModal.vue index 30a42e6..2cc2747 100644 --- a/components/FormBuilderFieldSettingsModal.vue +++ b/components/FormBuilderFieldSettingsModal.vue @@ -58,65 +58,166 @@
-
+ +
- - - - + +
+
+ + Preview Change +
+
+
+ From: + {{ getComponentTypeName(component.type) }} +
+
+ To: + {{ getComponentTypeName(pendingTypeChange) }} +
+
+ Preserved: + {{ getPreservedProperties(component.type, pendingTypeChange).join(', ') }} +
+
+
+ + + Confirm Change + + + + Cancel + +
+
- + + - + + + + +
@@ -350,23 +451,7 @@ - - +