Skip to content

Commit 51ea649

Browse files
author
Marc Geurts
committed
Improved PeopleLog
1 parent beee47e commit 51ea649

File tree

13 files changed

+89
-10
lines changed

13 files changed

+89
-10
lines changed

app/Livewire/Peoplelog.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,42 @@ final class Peoplelog extends Component
1313
{
1414
use WithPagination;
1515

16-
public $perPage = 50;
16+
public $perPage = 25;
17+
18+
public $subjectTypeFilter = 'all';
1719

1820
// -----------------------------------------------------------------------
1921
public function render(): View
2022
{
2123
$timezone = session('timezone', 'UTC');
2224

23-
$activities = Activity::with('causer')
25+
$query = Activity::with('causer')
2426
->where('log_name', 'person_couple')
2527
->where('team_id', auth()->user()->currentTeam->id)
26-
->where('updated_at', '>=', today()->startOfMonth()->subMonths(1))
28+
->where('updated_at', '>=', today()->startOfMonth()->subMonths(1));
29+
30+
// Apply subject_type filter if not 'all'
31+
if ($this->subjectTypeFilter !== 'all') {
32+
$query->where('subject_type', $this->subjectTypeFilter);
33+
}
34+
35+
$activities = $query
2736
->orderBy('updated_at', 'desc')
2837
->paginate($this->perPage);
2938

39+
// Get distinct subject types for the filter dropdown
40+
$subjectTypes = Activity::where('log_name', 'person_couple')
41+
->where('team_id', auth()->user()->currentTeam->id)
42+
->where('updated_at', '>=', today()->startOfMonth()->subMonths(1))
43+
->distinct()
44+
->pluck('subject_type')
45+
->map(fn ($type) => class_basename($type))
46+
->sort()
47+
->values()
48+
->toArray();
49+
3050
// Transform only the current page data
31-
$logs = $activities->getCollection()->map(function ($record) use ($timezone) {
51+
$logs = $activities->getCollection()->map(function ($record) use ($timezone): array {
3252
$event = $record->event;
3353

3454
return [
@@ -46,11 +66,17 @@ public function render(): View
4666
// Replace the collection with transformed data
4767
$activities->setCollection($logs);
4868

49-
return view('livewire.peoplelog', compact('activities'));
69+
return view('livewire.peoplelog', compact('activities', 'subjectTypes'));
70+
}
71+
72+
// Reset pagination when filter changes
73+
public function updatedSubjectTypeFilter(): void
74+
{
75+
$this->resetPage();
5076
}
5177

52-
// Optional: Method to change per page
53-
public function updatedPerPage()
78+
// Reset pagination when per page changes
79+
public function updatedPerPage(): void
5480
{
5581
$this->resetPage();
5682
}

lang/de/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'log_viewer' => 'Protokollbetrachter',
1818

1919
// Labels
20+
'all' => 'Alle',
21+
'filter' => 'Filter',
2022
'api_tokens' => 'API-Token',
2123
'attention' => 'Achtung',
2224
'contact' => 'Kontakt',

lang/en/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'log_viewer' => 'Log Viewer',
1818

1919
// Labels
20+
'all' => 'All',
21+
'filter' => 'Filter',
2022
'api_tokens' => 'API tokens',
2123
'attention' => 'Attention',
2224
'contact' => 'Contact',

lang/es/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
'useful_links' => 'Enlaces útiles',
1515
'impressum' => 'Impresión',
1616
'log_viewer' => 'Visor de registros',
17+
'all' => 'Todos',
18+
'filter' => 'Filtrar',
1719
'api_tokens' => 'tokens API',
1820
'attention' => 'Atención',
1921
'contact' => 'Contacto',

lang/fr/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
'useful_links' => 'Liens utiles',
1515
'impressum' => 'Mentions légales',
1616
'log_viewer' => 'Visionneuse de journaux',
17+
'all' => 'Tous',
18+
'filter' => 'Filtrer',
1719
'api_tokens' => 'Jetons API',
1820
'attention' => 'Attention',
1921
'contact' => 'Contact',

lang/hi/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
'useful_links' => 'उपयोगी कड़ियां',
1515
'impressum' => 'इम्प्रैसेम',
1616
'log_viewer' => 'लॉग देखने वाला',
17+
'all' => 'सभी',
18+
'filter' => 'फ़िल्टर',
1719
'api_tokens' => 'एपीआई टोकन',
1820
'attention' => 'ध्यान',
1921
'contact' => 'संपर्क',

lang/id/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'log_viewer' => 'Penampil Log',
1818

1919
// Labels
20+
'all' => 'Semua',
21+
'filter' => 'Filter',
2022
'api_tokens' => 'Token API',
2123
'attention' => 'Perhatian',
2224
'contact' => 'Kontak',

lang/nl/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'log_viewer' => 'Log Viewer',
1818

1919
// Labels
20+
'all' => 'Alles',
21+
'filter' => 'Filter',
2022
'api_tokens' => 'API tokens',
2123
'attention' => 'Aandacht',
2224
'contact' => 'Contact',

lang/pt/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
'useful_links' => 'Links úteis',
1515
'impressum' => 'Impressão',
1616
'log_viewer' => 'Visualizador de registros',
17+
'all' => 'Todos',
18+
'filter' => 'Filtrar',
1719
'api_tokens' => 'Tokens de API',
1820
'attention' => 'Atenção',
1921
'contact' => 'Contato',

lang/tr/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'log_viewer' => 'Günlük Görüntüleyici',
1818

1919
// Etiketler
20+
'all' => 'Tümü',
21+
'filter' => 'Filtre',
2022
'api_tokens' => 'API Jetonları',
2123
'attention' => 'Dikkat',
2224
'contact' => 'İletişim',

0 commit comments

Comments
 (0)