Skip to content

Commit

Permalink
Merge pull request #785 from JoshKisb/main
Browse files Browse the repository at this point in the history
update reports
  • Loading branch information
curtisdelicata authored Jun 14, 2024
2 parents 3342508 + ca2def9 commit 83c1f36
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/Filament/Resources/PersonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PersonResource extends Resource

protected static ?string $navigationGroup = 'Person';

protected static ?string $tenantRelationshipName = 'People';
// protected static ?string $tenantRelationshipName = 'People';

public static function form(Form $form): Form
{
Expand Down
16 changes: 14 additions & 2 deletions app/Livewire/DabovilleReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace App\Livewire;

use App\Models\Person;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Livewire\Component;
Expand All @@ -10,9 +14,10 @@
use Filament\Forms\Form;
use Illuminate\Contracts\View\View;

class DabovilleReport extends Component implements HasForms
class DabovilleReport extends Component implements HasForms, HasActions
{
use InteractsWithForms;
use InteractsWithActions;

public ?array $data = [];

Expand All @@ -26,12 +31,19 @@ public function form(Form $form): Form
return $form
->schema([
Select::make('person')
->hiddenLabel()
->options(Person::all()->pluck('name', 'id'))
->placeholder('Select a Person:'),

])
->statePath('data');
}

public function generateAction(): Action
{
return Action::make('generate')
->action(fn () => null);
}

public function generateReport(): void
{
dd($this->form->getState());
Expand Down
62 changes: 62 additions & 0 deletions app/Livewire/DevillierReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace App\Livewire;

use App\Models\Person;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Livewire\Component;

class DevillierReport extends Component implements HasForms, HasActions
{

use InteractsWithForms;
use InteractsWithActions;

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
Select::make('person')
->hiddenLabel()
->options(Person::all()->pluck('name', 'id'))
->placeholder('Select a Person:')
->native(false),
Select::make('generation')
->hiddenLabel()
->placeholder('Select Generation')
->options([1, 2, 3, 4, 5])
->native(false)
])
->statePath('data')
;
}

public function generateAction(): Action
{
return Action::make('generate')
->action(fn () => null);
}

public function generateReport(): void
{
dd($this->form->getState());
}

public function render()
{
return view('livewire.devilliers-report');
}
}
5 changes: 5 additions & 0 deletions app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public function persons(): HasMany
return $this->hasMany(Person::class);
}

public function people(): HasMany
{
return $this->hasMany(Person::class);
}

public function person_alias(): HasMany
{
return $this->hasMany(PersonAlia::class);
Expand Down
1 change: 1 addition & 0 deletions public/build/assets/app-DFfNwTug.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/build/assets/theme-Je01-uoY.css

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions resources/css/dashboard.css

This file was deleted.

1 change: 1 addition & 0 deletions resources/css/filament/admin/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/**/*.blade.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/de-villiers-report-page.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<x-filament-panels::page>

<livewire:devillier-report />
</x-filament-panels::page>
40 changes: 15 additions & 25 deletions resources/views/livewire/daboville-report.blade.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
<div>
<form wire:submit.prevent="generateReport">
<div class="flex">
{{ $this->form }}
<button type="submit" class="btn btn-primary">Generate Report</button>
<div class="flex items-end">
<div class="flex-1 pr-2">{{ $this->form }}</div>
<div>{{ $this->generateAction }}</div>
</div>
</form>

<div wire:loading>
<div class="flex justify-center text-center mt-3" wire:loading>
Generating report...
</div>

@if(!empty($reportData))
<table class="table mt-4">
<thead>
<tr>
<th>d'Aboville Number</th>
<th>Name</th>
<th>Birth Date</th>
<th>Death Date</th>
</tr>
</thead>
<tbody>
@foreach($reportData as $data)
<tr>
<td>{{ $data['number'] }}</td>
<td>{{ $data['name'] }}</td>
<td>{{ $data['birth'] ?? 'N/A' }}</td>
<td>{{ $data['death'] ?? 'N/A' }}</td>
</tr>
@endforeach
</tbody>
</table>
@if (!empty($reportData))
<div v-for="data in reportLevels">
<div :style="`margin: 8px 6px 8px ${data.level * 42}px; display: flex`">
<span :style="`width: ${(data.level * 5) + 20}px;`">{{data.label}}</span>
<span>{{ data.person.firstNames }}</span>
</div>
<div v-if="data.person.spouse && data.person.children" :style="`margin: 8px 0px 16px ${(data.level * 42)}px; display: flex`">
<span :style="`padding: 0 8px 0px ${(data.level * 5) + 20}px`">sp</span>
<span>{{ data.person.spouse.firstNames }}</span>
</div>
</div>
@endif
</div>
16 changes: 5 additions & 11 deletions resources/views/livewire/devilliers-report.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<div>
<form wire:submit.prevent="generateReport(selectedPersonId)">
<div class="form-group">
<label for="personSelect">Select a Person:</label>
<select id="personSelect" class="form-control" wire:model="selectedPersonId">
<option value="">--Choose--</option>
@foreach(\App\Models\Person::all() as $person)
<option value="{{ $person->id }}">{{ $person->name }}</option>
@endforeach
</select>
<form wire:submit.prevent="generateReport">
<div class="flex items-end">
<div class="flex-1 pr-2">{{ $this->form }}</div>
{{-- <div>{{ $this->generateAction }}</div> --}}
</div>
<button type="submit" class="btn btn-primary">Generate Report</button>
</form>

<div wire:loading>
<div class="flex justify-center text-center mt-3" wire:loading>
Generating report...
</div>

Expand Down
1 change: 0 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default defineConfig({
laravel([
"resources/css/app.css",
"resources/js/app.js",
"resources/css/dashboard.css",
'resources/css/filament/admin/theme.css',
]),
viteStaticCopy({
Expand Down

0 comments on commit 83c1f36

Please sign in to comment.