Skip to content

Commit eeffc73

Browse files
authored
Merge pull request #453 from cronxco/claude/improve-day-view-collapse-018GdvisVas7cZQAz4uMcth9
Improve day view activity collapse behavior
2 parents b2bee9b + ed34d6f commit eeffc73

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

resources/views/livewire/day.blade.php

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,21 @@
804804
return $groups;
805805
});
806806
807+
// Computed helper: initial collapsed state (auto-collapse groups with 4+ events)
808+
$initialCollapsedGroups = computed(function () {
809+
$groups = $this->groupedEvents;
810+
$collapsed = [];
811+
812+
foreach ($groups as $group) {
813+
// Auto-collapse if 4 or more events in group
814+
if (count($group['events']) >= 4) {
815+
$collapsed[$group['key']] = true;
816+
}
817+
}
818+
819+
return $collapsed;
820+
});
821+
807822
// Computed helper: are all groups currently expanded?
808823
$areAllGroupsExpanded = computed(function () {
809824
$groups = $this->groupedEvents;
@@ -1001,7 +1016,7 @@ class="btn-ghost btn-sm"
10011016
$hour = $userTime->format('H');
10021017
$showHourMarker = $previousHour !== $hour;
10031018
$previousHour = $hour;
1004-
$isCollapsed = ($this->collapsedGroups[$eventGroup['key']] ?? false);
1019+
$isCollapsed = ($this->collapsedGroups[$eventGroup['key']] ?? $this->initialCollapsedGroups[$eventGroup['key']] ?? false);
10051020
@endphp
10061021

10071022
<!-- Hour marker inside spine -->
@@ -1030,9 +1045,22 @@ class="btn-ghost btn-sm"
10301045
<div class="{{ $isCollapsed ? 'py-3' : '' }}">
10311046
<div class="min-w-0">
10321047
@if ($isCollapsed)
1048+
@php $firstEvent = $eventGroup['events'][0]; @endphp
10331049
<div class="truncate">
1034-
<span class="font-semibold">{{ $eventGroup['formatted_action'] }}</span>
1035-
<span class="text-base-content/90">{{ ' ' . $eventGroup['count'] . ' ' . $eventGroup['object_type_plural'] }}</span>
1050+
<span class="font-semibold">{{ $this->formatAction($firstEvent->action) }}</span>
1051+
@if (should_display_action_with_object($firstEvent->action, $firstEvent->service))
1052+
@if ($firstEvent->target)
1053+
<span class="font-bold">{{ ' ' . $firstEvent->target->title }}</span>
1054+
@elseif ($firstEvent->actor)
1055+
<span class="font-bold">{{ ' ' . $firstEvent->actor->title }}</span>
1056+
@endif
1057+
@endif
1058+
@if ($eventGroup['count'] > 1)
1059+
<span class="text-base-content/70">{{ ' + ' . ($eventGroup['count'] - 1) . ' other' . ($eventGroup['count'] > 2 ? 's' : '') }}</span>
1060+
@endif
1061+
</div>
1062+
<div class="mt-1 text-sm text-base-content/70">
1063+
{{ to_user_timezone($firstEvent->time, auth()->user())->format('H:i') }}
10361064
</div>
10371065
@else
10381066
@php $firstEvent = $eventGroup['events'][0]; @endphp
@@ -1070,11 +1098,9 @@ class="btn-ghost btn-sm"
10701098
</div>
10711099
</div>
10721100
<div class="{{ $isCollapsed ? 'py-3' : 'py-2' }} text-right pr-2">
1073-
@if (! $isCollapsed)
1074-
@php $firstEvent = $eventGroup['events'][0]; @endphp
1075-
@if (! is_null($firstEvent->value))
1076-
<span class="text-lg font-bold {{ $this->valueColorClass($firstEvent) }}">{!! $this->formatValueDisplay($firstEvent) !!}</span>
1077-
@endif
1101+
@php $displayEvent = $eventGroup['events'][0]; @endphp
1102+
@if (! is_null($displayEvent->value))
1103+
<span class="text-lg font-bold {{ $this->valueColorClass($displayEvent) }}">{!! $this->formatValueDisplay($displayEvent) !!}</span>
10781104
@endif
10791105
</div>
10801106
</div>

0 commit comments

Comments
 (0)