- Migrated custom node definitions from inline to individual `.vue` files for improved maintainability and production compatibility. - Updated `ProcessFlowCanvas.vue` to import new file-based node components and created a `customNodeTypes` object to manage node types. - Removed the deprecated `composables/processFlowNodes.js` and extracted shared styles into `composables/nodeStyles.js`. - Enhanced user experience by ensuring proper rendering and functionality of all node types in the process flow interface.
170 lines
3.8 KiB
Vue
170 lines
3.8 KiB
Vue
<script setup>
|
|
import { Handle, Position } from '@vue-flow/core'
|
|
|
|
// Define props that Vue Flow passes to custom nodes
|
|
const props = defineProps([
|
|
'id', // Node ID
|
|
'type', // Node type
|
|
'label', // Node label
|
|
'selected', // Selection state
|
|
'data' // Custom data object
|
|
])
|
|
|
|
// Computed for node label with fallback
|
|
const nodeLabel = computed(() => {
|
|
return props.label || (props.data && props.data.label) || 'Start'
|
|
})
|
|
|
|
// Handle node click event
|
|
const emit = defineEmits(['node-click'])
|
|
const onClick = () => {
|
|
emit('node-click', props.id)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
:class="['custom-node', 'node-start', { 'selected': selected }]"
|
|
@click="onClick"
|
|
>
|
|
<!-- Start node only has output handles -->
|
|
<!-- Right handle -->
|
|
<Handle
|
|
type="source"
|
|
:position="Position.Right"
|
|
class="handle-start-output handle-right"
|
|
:id="id + '-right'"
|
|
:style="{ zIndex: 1000 }"
|
|
:isConnectable="true"
|
|
:isValidConnection="() => true"
|
|
/>
|
|
|
|
<!-- Bottom handle -->
|
|
<Handle
|
|
type="source"
|
|
:position="Position.Bottom"
|
|
class="handle-start-output handle-bottom"
|
|
:id="id + '-bottom'"
|
|
:style="{ zIndex: 1000 }"
|
|
:isConnectable="true"
|
|
:isValidConnection="() => true"
|
|
/>
|
|
|
|
<div class="custom-node-content">
|
|
<div class="custom-node-icon">
|
|
<i class="material-icons text-green-600">play_arrow</i>
|
|
</div>
|
|
<div class="custom-node-label" :title="nodeLabel">{{ nodeLabel }}</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
/* Start node specific styling */
|
|
.node-start {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
background: #e8f5e9;
|
|
border: 1px solid #4CAF50;
|
|
position: relative;
|
|
color: #333;
|
|
font-size: 12px;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.node-start.selected {
|
|
border-color: #ff6b6b;
|
|
box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
|
|
}
|
|
|
|
.custom-node-content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100%;
|
|
padding: 0;
|
|
position: relative;
|
|
z-index: 2;
|
|
}
|
|
|
|
.custom-node-icon {
|
|
margin: 0;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.custom-node-icon .material-icons {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.custom-node-label {
|
|
position: absolute;
|
|
width: 60px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
top: 51px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
font-size: 10px;
|
|
font-weight: 500;
|
|
text-align: center;
|
|
}
|
|
|
|
/* Handle styles */
|
|
.handle-right {
|
|
right: -6px !important;
|
|
top: 50% !important;
|
|
transform: translateY(-50%) !important;
|
|
width: 12px !important;
|
|
height: 12px !important;
|
|
border-radius: 50% !important;
|
|
background: #fff !important;
|
|
border: 2px solid #4CAF50 !important;
|
|
opacity: 0;
|
|
transition: all 0.2s ease;
|
|
cursor: crosshair;
|
|
z-index: 100 !important;
|
|
position: absolute !important;
|
|
}
|
|
|
|
.handle-bottom {
|
|
bottom: -6px !important;
|
|
left: 50% !important;
|
|
transform: translateX(-50%) !important;
|
|
width: 12px !important;
|
|
height: 12px !important;
|
|
border-radius: 50% !important;
|
|
background: #fff !important;
|
|
border: 2px solid #4CAF50 !important;
|
|
opacity: 0;
|
|
transition: all 0.2s ease;
|
|
cursor: crosshair;
|
|
z-index: 100 !important;
|
|
position: absolute !important;
|
|
}
|
|
|
|
/* Show handles on hover and during connection */
|
|
.node-start:hover .handle-right,
|
|
.node-start:hover .handle-bottom {
|
|
opacity: 1;
|
|
}
|
|
|
|
.handle-right:hover {
|
|
transform: translateY(-50%) scale(1.1);
|
|
background: #4CAF50 !important;
|
|
border-color: #2E7D32 !important;
|
|
}
|
|
|
|
.handle-bottom:hover {
|
|
transform: translateX(-50%) scale(1.1);
|
|
background: #4CAF50 !important;
|
|
border-color: #2E7D32 !important;
|
|
}
|
|
</style> |