Skip to content

Commit 5d12144

Browse files
krlmrrKarl MurrayOrrison
authored
[ADVAPP-2101]: Introduce a projects report in the report library (#2026)
* [ADVAPP-2101]: Get the features working * [ADVAPP-2101]: Add unit test * [ADVAPP-2101]: Fix linitng error * Update app-modules/report/src/Filament/Widgets/ProjectManagementTable.php Co-authored-by: Kevin Ullyott <Orrison@users.noreply.github.com> * [ADVAPP-2101]: Fix linitng error --------- Co-authored-by: Karl Murray <karl.murray@canyongbs.com> Co-authored-by: Kevin Ullyott <Orrison@users.noreply.github.com>
1 parent 75bcf5d commit 5d12144

4 files changed

Lines changed: 206 additions & 1 deletion

File tree

app-modules/report/src/Abstract/ProjectManagementReport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class ProjectManagementReport extends Dashboard
4444
{
4545
use HasFiltersForm;
4646

47-
protected string $view = 'filament.pages.coming-soon';
47+
protected string $view = 'report::filament.pages.report';
4848

4949
public static function canAccess(): bool
5050
{

app-modules/report/src/Filament/Pages/ProjectReport.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
namespace AdvisingApp\Report\Filament\Pages;
3838

3939
use AdvisingApp\Report\Abstract\ProjectManagementReport;
40+
use AdvisingApp\Report\Filament\Widgets\ProjectManagementTable;
4041
use App\Filament\Clusters\ReportLibrary;
4142
use UnitEnum;
4243

@@ -53,4 +54,13 @@ class ProjectReport extends ProjectManagementReport
5354
protected static ?int $navigationSort = 210;
5455

5556
protected static string $routePath = 'project-report';
57+
58+
protected string $cacheTag = 'project-management-report-cache';
59+
60+
public function getWidgets(): array
61+
{
62+
return [
63+
ProjectManagementTable::make(['cacheTag' => $this->cacheTag]),
64+
];
65+
}
5666
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
namespace AdvisingApp\Report\Filament\Widgets;
38+
39+
use AdvisingApp\Project\Models\Project;
40+
use AdvisingApp\Report\Filament\Widgets\Concerns\InteractsWithPageFilters;
41+
use Filament\Support\Enums\Width;
42+
use Filament\Tables\Columns\TextColumn;
43+
use Filament\Tables\Table;
44+
use Filament\Widgets\TableWidget as BaseWidget;
45+
use Illuminate\Database\Eloquent\Builder;
46+
use Livewire\Attributes\Locked;
47+
use Livewire\Attributes\On;
48+
49+
class ProjectManagementTable extends BaseWidget
50+
{
51+
use InteractsWithPageFilters;
52+
53+
#[Locked]
54+
public string $cacheTag;
55+
56+
protected static ?string $heading = 'Projects';
57+
58+
protected static bool $isLazy = false;
59+
60+
protected static ?string $pollingInterval = null;
61+
62+
protected int | string | array $columnSpan = [
63+
'sm' => 12,
64+
'md' => 12,
65+
'lg' => 12,
66+
];
67+
68+
public function mount(string $cacheTag): void
69+
{
70+
$this->cacheTag = $cacheTag;
71+
}
72+
73+
#[On('refresh-widgets')]
74+
public function refreshWidget(): void {}
75+
76+
public function table(Table $table): Table
77+
{
78+
$startDate = $this->getStartDate();
79+
$endDate = $this->getEndDate();
80+
81+
return $table
82+
->query(
83+
Project::query()
84+
->when($startDate && $endDate, function (Builder $query) use ($startDate, $endDate): void {
85+
$query->whereBetween('created_at', [$startDate, $endDate]);
86+
})
87+
)
88+
->columns([
89+
TextColumn::make('name')
90+
->label('Project Name')
91+
->searchable(),
92+
TextColumn::make('created_at')
93+
->label('Created At')
94+
->dateTime('M d, Y h:i A'),
95+
TextColumn::make('managerUsers.name')
96+
->label('Managers')
97+
->formatStateUsing(fn ($record) => $record->managerUsers->count())
98+
->searchable(),
99+
TextColumn::make('auditorUsers.name')
100+
->label('Auditors')
101+
->formatStateUsing(fn ($record) => $record->auditorUsers->count())
102+
->searchable(),
103+
TextColumn::make('files_count')
104+
->label('Files')
105+
->counts('files'),
106+
TextColumn::make('pipelines_count')
107+
->label('Pipelines')
108+
->counts('pipelines'),
109+
TextColumn::make('milestones_count')
110+
->label('Milestones')
111+
->counts('milestones'),
112+
TextColumn::make('tasks_count')
113+
->label('Tasks')
114+
->counts('tasks'),
115+
])
116+
->paginated([5])
117+
->filtersFormWidth(Width::Small);
118+
}
119+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
use AdvisingApp\Project\Models\Project;
38+
use AdvisingApp\Report\Filament\Widgets\ProjectManagementTable;
39+
use App\Models\User;
40+
41+
use function Pest\Laravel\actingAs;
42+
use function Pest\Livewire\livewire;
43+
44+
it('returns projects created within the given date range', function () {
45+
$startDate = now()->subDays(10);
46+
$endDate = now()->subDays(5);
47+
48+
$user = User::factory()->create();
49+
actingAs($user);
50+
51+
$project1 = Project::factory()->create([
52+
'created_at' => $startDate,
53+
]);
54+
55+
$project2 = Project::factory()->create([
56+
'created_at' => $endDate,
57+
]);
58+
$project3 = Project::factory()->create([
59+
'created_at' => now()->subDays(20),
60+
]);
61+
62+
$filters = [
63+
'startDate' => $startDate->toDateString(),
64+
'endDate' => $endDate->toDateString(),
65+
];
66+
67+
livewire(ProjectManagementTable::class, [
68+
'cacheTag' => 'project-management-report-cache',
69+
'pageFilters' => $filters,
70+
])
71+
->assertCanSeeTableRecords(collect([
72+
$project1,
73+
$project2,
74+
]))
75+
->assertCanNotSeeTableRecords(collect([$project3]));
76+
});

0 commit comments

Comments
 (0)