@@ -4,7 +4,7 @@ import MessageDataBox from "./MessageDataBox.vue";
4
4
import SagaOutgoingTimeoutMessage from " ./SagaOutgoingTimeoutMessage.vue" ;
5
5
import SagaOutgoingMessage from " ./SagaOutgoingMessage.vue" ;
6
6
import { useSagaDiagramStore } from " @/stores/SagaDiagramStore" ;
7
- import { ref , watch } from " vue" ;
7
+ import { ref , watch , computed } from " vue" ;
8
8
9
9
// Import the images directly
10
10
import CommandIcon from " @/assets/command.svg" ;
@@ -21,6 +21,7 @@ const props = defineProps<{
21
21
const store = useSagaDiagramStore ();
22
22
const initiatingMessageRef = ref <HTMLElement | null >(null );
23
23
const isActive = ref (false );
24
+ const showAllProperties = ref (! props .update .showUpdatedPropertiesOnly );
24
25
25
26
// Watch for changes to selectedMessageId
26
27
watch (
@@ -41,6 +42,63 @@ watch(
41
42
}
42
43
}
43
44
);
45
+
46
+ // Function to toggle between showing all properties and only updated properties
47
+ const togglePropertyView = (event : Event , showAll : boolean ) => {
48
+ event .preventDefault ();
49
+ showAllProperties .value = showAll ;
50
+ // Instead of directly modifying the prop, we update our local view state
51
+ // props.update.showUpdatedPropertiesOnly = !showAll;
52
+ };
53
+
54
+ // Compute the properties to display based on the current state
55
+ const displayProperties = computed (() => {
56
+ const properties: { name: string ; value: string ; isNew: boolean }[] = [];
57
+ const state = props .update .stateAfterChange ;
58
+ const previousState = props .update .previousStateAfterChange || {};
59
+ const isFirstNode = props .update .IsFirstNode ;
60
+
61
+ // Function to check if a property has changed
62
+ const hasPropertyChanged = (key : string ) => {
63
+ if (isFirstNode ) return true ; // For the first node, all properties are "new"
64
+ return JSON .stringify (state [key ]) !== JSON .stringify (previousState [key ]);
65
+ };
66
+
67
+ // Function to format value differences
68
+ const formatValue = (key : string ) => {
69
+ const currentValue = state [key ];
70
+ if (isFirstNode || ! props .update .previousStateAfterChange ) {
71
+ return String (currentValue );
72
+ }
73
+
74
+ const prevValue = previousState [key ];
75
+ if (JSON .stringify (currentValue ) !== JSON .stringify (prevValue )) {
76
+ return ` ${prevValue } → ${currentValue } ` ;
77
+ }
78
+ return String (currentValue );
79
+ };
80
+
81
+ // Filter out standard keys like $type, Id, Originator, OriginalMessageId
82
+ const standardKeys = [" $type" , " Id" , " Originator" , " OriginalMessageId" ];
83
+
84
+ // Add all properties that should be displayed
85
+ for (const key in state ) {
86
+ if (standardKeys .includes (key )) continue ;
87
+
88
+ const propertyChanged = hasPropertyChanged (key );
89
+
90
+ // Skip unchanged properties when showing only updated properties
91
+ if (! showAllProperties .value && ! propertyChanged && ! isFirstNode ) continue ;
92
+
93
+ properties .push ({
94
+ name: isFirstNode ? ` ${key } (new) ` : key , // Add "(new)" suffix for first node
95
+ value: formatValue (key ),
96
+ isNew: isFirstNode || propertyChanged ,
97
+ });
98
+ }
99
+
100
+ return properties ;
101
+ });
44
102
</script >
45
103
46
104
<template >
@@ -90,18 +148,19 @@ watch(
90
148
<div class =" cell cell--center cell--center--border" >
91
149
<div :class =" { 'cell-inner': true, 'cell-inner-line': update.HasTimeout, 'cell-inner-center': !update.HasTimeout }" >
92
150
<div class =" saga-properties" >
93
- <a class =" saga-properties-link" href =" " >All Properties</a > /
94
- <a class =" saga-properties-link saga-properties-link--active" href =" " >Updated Properties</a >
151
+ <a class =" saga-properties-link" :class = " { 'saga-properties-link--active': showAllProperties } " href =" " @click = " (e) => togglePropertyView(e, true) " >All Properties</a > /
152
+ <a class =" saga-properties-link" :class = " { ' saga-properties-link--active': !showAllProperties } " href =" " @click = " (e) => togglePropertyView(e, false) " >Updated Properties</a >
95
153
</div >
96
154
97
155
<!-- Display saga properties if available -->
98
- <ul class =" saga-properties-list" >
99
- <li class =" saga-properties-list-item" >
100
- <span class =" saga-properties-list-text" title =" Property (new) " >Property (new) </span >
156
+ <ul class =" saga-properties-list" v-if = " displayProperties.length > 0 " >
157
+ <li class =" saga-properties-list-item" v-for = " (prop, index) in displayProperties " :key = " index " >
158
+ <span class =" saga-properties-list-text" : title =" prop.name " >{{ prop.name }} </span >
101
159
<span class =" saga-properties-list-text" >=</span >
102
- <span class =" saga-properties-list-text" title =" Sample Value " > Sample Value </span >
160
+ <span class =" saga-properties-list-text" : title =" prop.value " >{{ prop.value }} </span >
103
161
</li >
104
162
</ul >
163
+ <div v-else class =" no-properties" >No properties to display</div >
105
164
</div >
106
165
</div >
107
166
@@ -118,10 +177,6 @@ watch(
118
177
</template >
119
178
120
179
<style scoped>
121
- .block {
122
- /* block container style */
123
- }
124
-
125
180
.row {
126
181
display : flex ;
127
182
}
@@ -164,10 +219,6 @@ watch(
164
219
border-top : solid 2px #000000 ;
165
220
}
166
221
167
- .cell-inner {
168
- /* padding: 0.5rem; */
169
- }
170
-
171
222
.cell-inner-center {
172
223
padding : 0.5rem ;
173
224
}
@@ -322,6 +373,13 @@ watch(
322
373
display : block ;
323
374
}
324
375
376
+ .no-properties {
377
+ padding : 0.25rem ;
378
+ font-style : italic ;
379
+ font-size : 0.8rem ;
380
+ color : #666 ;
381
+ }
382
+
325
383
.saga-icon {
326
384
display : block ;
327
385
float : left ;
0 commit comments