Skip to content

Commit df948f0

Browse files
authored
Add prefix for Metadata to show Activity Type in Timeline (#2542)
* Add prefix for metadata to show ActivityType in Timeline * Get rid of value var
1 parent 17dc79c commit df948f0

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

Diff for: src/lib/components/event/event-summary-row.svelte

+4-5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
{/if}
201201
</div>
202202
{/if}
203+
{#if primaryAttribute?.key}
204+
<EventDetailsRow {...primaryAttribute} {attributes} />
205+
{/if}
203206
{#if currentEvent?.userMetadata?.summary}
204207
<MetadataDecoder
205208
value={currentEvent.userMetadata.summary}
@@ -214,12 +217,8 @@
214217
{decodedValue}
215218
</Badge>
216219
</div>
217-
{:else}
218-
<EventDetailsRow {...primaryAttribute} {attributes} />
219220
{/if}
220221
</MetadataDecoder>
221-
{:else if primaryAttribute?.key}
222-
<EventDetailsRow {...primaryAttribute} {attributes} />
223222
{/if}
224223
{#if currentEvent?.links?.length}
225224
<EventLink
@@ -235,7 +234,7 @@
235234
{attributes}
236235
/>
237236
{/if}
238-
{#if compact && secondaryAttribute?.key}
237+
{#if compact && secondaryAttribute?.key && !currentEvent?.userMetadata?.summary}
239238
<EventDetailsRow {...secondaryAttribute} {attributes} />
240239
{/if}
241240
</td>

Diff for: src/lib/components/event/metadata-decoder.svelte

+14-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
1212
export let value: Payload | undefined = undefined;
1313
export let fallback: string = '';
14+
export let prefix: string = '';
1415
export let onDecode: (decodedValue: string) => void | undefined = undefined;
1516
17+
const maxLength = 100;
18+
1619
let decodedValue = '';
1720
1821
$: endpoint = getCodecEndpoint($page.data.settings);
@@ -28,6 +31,14 @@
2831
},
2932
};
3033
34+
const setPrefix = (metadata: string) => {
35+
if (prefix) {
36+
metadata = `${prefix} • ${metadata}`;
37+
}
38+
if (metadata.length < maxLength) return metadata;
39+
return metadata.slice(0, maxLength) + '...';
40+
};
41+
3142
$: decodePayload = async (_value: Payload | undefined) => {
3243
if (!_value) return fallback;
3344
if (decodedValue) return decodedValue;
@@ -38,11 +49,11 @@
3849
);
3950
4051
if (typeof metadata === 'string') {
52+
decodedValue = setPrefix(metadata);
4153
if (onDecode) {
42-
onDecode(metadata);
54+
onDecode(decodedValue);
4355
}
44-
decodedValue = metadata;
45-
return metadata;
56+
return decodedValue;
4657
}
4758
4859
decodedValue = fallback;

Diff for: src/lib/components/lines-and-dots/svg/timeline-graph-row.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import type { EventGroup } from '$lib/models/event-groups/event-groups';
77
import { setActiveGroup } from '$lib/stores/active-events';
88
import { getMillisecondDuration } from '$lib/utilities/format-time';
9+
import { isActivityTaskScheduledEvent } from '$lib/utilities/is-event-type';
910
1011
import {
1112
CategoryIcon,
@@ -129,6 +130,9 @@
129130
{:else}
130131
<MetadataDecoder
131132
value={group?.userMetadata?.summary}
133+
prefix={isActivityTaskScheduledEvent(group.initialEvent)
134+
? group?.displayName
135+
: ''}
132136
fallback={group?.displayName}
133137
let:decodedValue
134138
>

0 commit comments

Comments
 (0)