diff --git a/components/process-flow/GatewayConditionManager.vue b/components/process-flow/GatewayConditionManager.vue index 4859de7..9e9c717 100644 --- a/components/process-flow/GatewayConditionManager.vue +++ b/components/process-flow/GatewayConditionManager.vue @@ -8,14 +8,7 @@ const props = defineProps({ }, availableVariables: { type: Array, - default: () => [ - { name: 'amount', label: 'Amount', type: 'number' }, - { name: 'status', label: 'Status', type: 'string' }, - { name: 'priority', label: 'Priority', type: 'string' }, - { name: 'requestType', label: 'Request Type', type: 'string' }, - { name: 'dueDate', label: 'Due Date', type: 'date' }, - { name: 'isUrgent', label: 'Is Urgent', type: 'boolean' } - ] + default: () => [] } }); @@ -83,13 +76,23 @@ const getInputTypeForVarType = (type) => { // Add new condition const addCondition = () => { + if (!props.availableVariables || !props.availableVariables.length) { + alert('No variables available. Please add a variable before creating a condition.'); + return; + } + const defaultVar = props.availableVariables[0]; + if (!defaultVar || !defaultVar.name) { + alert('Invalid variable format. Please make sure variables have proper name and type.'); + return; + } + const newCondition = { id: `condition-${Date.now()}`, variable: defaultVar.name, - operator: getOperatorsForType(defaultVar.type)[0].value, + operator: getOperatorsForType(defaultVar.type || 'string')[0].value, value: '', - valueType: defaultVar.type, + valueType: defaultVar.type || 'string', output: '', // Output path label (e.g., "Yes" or "No") }; @@ -126,10 +129,13 @@ const updateCondition = (index, field, value) => { const conditionText = (condition) => { if (!condition.variable || !condition.operator) return ''; - const variable = props.availableVariables.find(v => v.name === condition.variable); + const variable = props.availableVariables?.find(v => v.name === condition.variable); const operator = getOperatorsForType(variable?.type || 'string').find(op => op.value === condition.operator); - return `${variable?.label || condition.variable} ${operator?.label.split(' ')[0] || condition.operator} ${condition.value}`; + const variableName = variable?.label || variable?.name || condition.variable || 'Unknown variable'; + const operatorText = operator?.label?.split(' ')[0] || condition.operator || '='; + + return `${variableName} ${operatorText} ${condition.value}`; }; @@ -177,7 +183,7 @@ const conditionText = (condition) => { :key="variable.name" :value="variable.name" > - {{ variable.label }} + {{ variable.label || variable.name || 'Unnamed variable' }} diff --git a/components/process-flow/VariableManager.vue b/components/process-flow/VariableManager.vue index 91f2880..e949500 100644 --- a/components/process-flow/VariableManager.vue +++ b/components/process-flow/VariableManager.vue @@ -102,6 +102,7 @@ class="space-y-4" > { - return variableStore.getAllVariables.process; + // This was only returning process variables, let's fix it to return both process and global variables + const allVars = [ + ...variableStore.getAllVariables.process, + ...variableStore.getAllVariables.global + ]; + return allVars; }); // Methods diff --git a/pages/process-builder/index.vue b/pages/process-builder/index.vue index e96cf25..a745934 100644 --- a/pages/process-builder/index.vue +++ b/pages/process-builder/index.vue @@ -174,11 +174,25 @@ const nodeDefaultPath = computed({ // Computed for gateway available variables const gatewayAvailableVariables = computed(() => { - return variableStore.getAllVariables.process.map(v => ({ - name: v.name, - label: v.name, // or v.description || v.name - type: v.type + const processVars = variableStore.getAllVariables.process.map(v => ({ + name: v.name || 'unnamed', + label: v?.description + ? `${v.description} (${v.name || 'unnamed'}, process)` + : `${v.name || 'unnamed'} (process)` , + type: v.type || 'string', + scope: 'process' })); + const globalVars = variableStore.getAllVariables.global.map(v => ({ + name: v.name || 'unnamed', + label: v?.description + ? `${v.description} (${v.name || 'unnamed'}, global)` + : `${v.name || 'unnamed'} (global)` , + type: v.type || 'string', + scope: 'global' + })); + const allVars = [...processVars, ...globalVars]; + console.log('Gateway available variables:', allVars); + return allVars; }); // Handle node selection @@ -622,7 +636,7 @@ const onConditionsUpdated = (conditions) => {