Md Afiq Iskandar b8431c1a65 Refactor Process Flow Nodes to File-Based Components and Update Styles
- 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.
2025-07-21 11:47:16 +08:00

170 lines
3.7 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) || 'End'
})
// Handle node click event
const emit = defineEmits(['node-click'])
const onClick = () => {
emit('node-click', props.id)
}
</script>
<template>
<div
:class="['custom-node', 'node-end', { 'selected': selected }]"
@click="onClick"
>
<!-- End node only has input handles -->
<!-- Top handle -->
<Handle
type="target"
:position="Position.Top"
class="handle-end-input handle-top"
:id="id + '-top'"
:style="{ zIndex: 1000 }"
:isConnectable="true"
:isValidConnection="() => true"
/>
<!-- Left handle -->
<Handle
type="target"
:position="Position.Left"
class="handle-end-input handle-left"
:id="id + '-left'"
:style="{ zIndex: 1000 }"
:isConnectable="true"
:isValidConnection="() => true"
/>
<div class="custom-node-content">
<div class="custom-node-icon">
<i class="material-icons text-red-600">stop</i>
</div>
<div class="custom-node-label" :title="nodeLabel">{{ nodeLabel }}</div>
</div>
</div>
</template>
<style scoped>
/* End node specific styling */
.node-end {
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: #ffebee;
border: 1px solid #f44336;
position: relative;
color: #333;
font-size: 12px;
transition: all 0.2s;
}
.node-end.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;
bottom: -29px;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
font-weight: 500;
text-align: center;
}
/* Handle styles */
.handle-top {
top: -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 #2196F3 !important;
opacity: 0;
transition: all 0.2s ease;
cursor: crosshair;
z-index: 100 !important;
position: absolute !important;
}
.handle-left {
left: -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 #2196F3 !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-end:hover .handle-top,
.node-end:hover .handle-left {
opacity: 1;
}
.handle-top:hover {
transform: translateX(-50%) scale(1.1);
background: #2196F3 !important;
border-color: #1565C0 !important;
}
.handle-left:hover {
transform: translateY(-50%) scale(1.1);
background: #2196F3 !important;
border-color: #1565C0 !important;
}
</style>