forked from vue-workflow-chart/vue-workflow-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
154 lines (146 loc) · 3.83 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
<div id="app">
<workflow-chart
:style="size"
:transitions="transitions"
:states="states"
:stateSemantics="stateSemantics"
:orientation="'horizontal'"
@state-click="onLabelClicked('state',$event)"
@transition-click="onLabelClicked('transition', $event)"
@size-change="sizeChanged" />
</div>
</template>
<script>
import WorkflowChart from '../src/components/WorkflowChart.vue';
export default {
name: "App",
components: {
WorkflowChart,
},
data: () => ({
states: [{
"id": "J4zloua",
"label": "Auditing",
}, {
"id": "Jcxrmx",
"label": "Released",
}, {
"id": "Tu2vqbl",
"label": "Verification by responsible",
}, {
"id": "static_state_deleted",
"label": "Deleted",
}, {
"id": "static_state_new",
"label": "New",
}],
transitions: [{
"id": "Dz2un1r",
"label": "ask for auditing",
"target": "J4zloua",
"source": "Tu2vqbl",
}, {
"id": "Ev0huzn",
"label": "restore",
"target": "static_state_new",
"source": "static_state_deleted",
}, {
"id": "Fst7op",
"label": "release",
"target": "Jcxrmx",
"source": "Tu2vqbl",
}, {
"id": "Lwed6qb",
"label": "discard draft",
"target": "static_state_deleted",
"source": "Tu2vqbl",
}, {
"id": "Mmpn8w",
"label": "discard request",
"target": "static_state_deleted",
"source": "J4zloua",
}, {
"id": "Qw136br",
"label": "delete",
"target": "static_state_deleted",
"source": "Jcxrmx",
}, {
"id": "Stf8g2b",
"label": "revise request",
"target": "J4zloua",
"source": "static_state_new",
}, {
"id": "Tznk4f5",
"label": "start new revision",
"target": "J4zloua",
"source": "Jcxrmx",
}, {
"id": "Usvtzqi",
"label": "release revision",
"target": "Tu2vqbl",
"source": "J4zloua",
}],
stateSemantics: [{
"classname": "delete",
"id":"static_state_deleted",
}],
size: { width: '0px', height: '0px' },
}),
created() {
const approveLabel = state => state.label === 'Released';
const semantic = item => ({ id: item.id, classname: 'approve' });
const approvedState = this.states.filter(approveLabel).map(semantic);
this.stateSemantics = [ ...this.stateSemantics, ...approvedState ];
},
methods: {
onLabelClicked(type, id) {
alert(`Clicked on ${type} with id: ${id}`);
},
sizeChanged(size) {
this.size = {
width: `${size.width}px`,
height: `${size.height}px`,
};
},
},
};
</script>
<style lang="scss">
@import '../src/styling.scss';
$approve-color: #1eb2a4;
$delete-color: #d64b61;
.vue-workflow-chart-state {
&-approve {
color: white;
background: $approve-color;
}
&-delete {
color: white;
background: $delete-color;
}
}
.vue-workflow-chart-transition-arrow {
&-approve {
fill: $approve-color;
}
&-delete {
fill: $delete-color;
}
}
.vue-workflow-chart-transition-path {
&-approve {
stroke: $approve-color;
}
&-delete {
stroke: $delete-color;
}
}
</style>
<style lang="scss" scoped>
#app {
display: flex;
justify-content: center;
padding-top: 100px;
}
</style>