-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8cc3a5
commit 45baeae
Showing
19 changed files
with
373 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
app/Filament/Resources/ProjectResource/RelationManagers/ActivitiesRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\ProjectResource\RelationManagers; | ||
|
||
use App\Filament\Resources\OrganizationResource\Actions\Tables\Activity\ApproveActivityAction; | ||
use App\Filament\Resources\OrganizationResource\Actions\Tables\Activity\RejectActivityAction; | ||
use App\Filament\Resources\OrganizationResource\Actions\Tables\Activity\ViewActivityAction; | ||
use App\Filament\Resources\UserResource; | ||
use App\Models\Activity; | ||
use Carbon\Carbon; | ||
use Filament\Forms; | ||
use Filament\Forms\Components\DatePicker; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Filters\Filter; | ||
use Filament\Tables\Filters\Layout; | ||
use Filament\Tables\Filters\SelectFilter; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class ActivitiesRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'activities'; | ||
|
||
// protected static ?string $recordTitleAttribute = 'description'; | ||
|
||
public static function getTitle(): string | ||
{ | ||
return __('activity.label.plural'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('description') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('created_at') | ||
->label(__('activity.column.created_at')) | ||
->sortable(), | ||
|
||
TextColumn::make('changed_field') | ||
->label(__('activity.column.changed_field')) | ||
->formatStateUsing( | ||
fn ($state) => __('project.labels.' . $state) | ||
), | ||
|
||
TextColumn::make('causer.name') | ||
->label(__('activity.column.causer')) | ||
->description( | ||
fn (Activity $record) => $record->causer?->role->label() | ||
) | ||
->url( | ||
fn (Activity $record) => $record->causer | ||
? UserResource::getUrl('view', $record->causer) | ||
: null | ||
) | ||
->sortable(), | ||
|
||
TextColumn::make('status') | ||
->label(__('activity.column.status')), | ||
]) | ||
->filters([ | ||
Filter::make('created_at') | ||
->columns() | ||
->form([ | ||
DatePicker::make('logged_from') | ||
->label(__('activity.filter.logged_from')) | ||
->placeholder( | ||
fn ($state): string => today() | ||
->setDay(17) | ||
->setMonth(11) | ||
->subYear() | ||
->toFormattedDate() | ||
), | ||
|
||
DatePicker::make('logged_until') | ||
->label(__('activity.filter.logged_until')) | ||
->placeholder( | ||
fn ($state): string => today() | ||
->toFormattedDate() | ||
), | ||
]) | ||
->query( | ||
fn (Builder $query, array $data) => $query->betweenDates( | ||
data_get($data, 'logged_from'), | ||
data_get($data, 'logged_until'), | ||
) | ||
) | ||
->indicateUsing( | ||
fn (array $data) => collect(['logged_from', 'logged_until']) | ||
->mapWithKeys(function (string $filter) use ($data) { | ||
$value = data_get($data, $filter); | ||
|
||
if (! \is_null($value)) { | ||
$value = __("activity.indicator.{$filter}", [ | ||
'date' => Carbon::parse($value)->toFormattedDate(), | ||
]); | ||
} | ||
|
||
return [$filter => $value]; | ||
}) | ||
->filter() | ||
->all() | ||
), | ||
|
||
// SelectFilter::make('causer_id') | ||
// ->relationship('causer', 'name'), | ||
|
||
// SelectFilter::make('changed_field'), | ||
]) | ||
->filtersLayout(Layout::AboveContent) | ||
->actions([ | ||
ViewActivityAction::make(), | ||
|
||
ApproveActivityAction::make(), | ||
|
||
RejectActivityAction::make(), | ||
]); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/Filament/Resources/ProjectResource/RelationManagers/DonationsRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\ProjectResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
class DonationsRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'donations'; | ||
|
||
protected static ?string $recordTitleAttribute = 'uuid'; | ||
|
||
public static function getTitle(): string | ||
{ | ||
return __('donation.label.plural'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('uuid') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('uuid'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\CreateAction::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/Filament/Resources/ProjectResource/RelationManagers/VolunteersRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\ProjectResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
class VolunteersRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'volunteers'; | ||
|
||
protected static ?string $recordTitleAttribute = 'full_name'; | ||
|
||
public static function getTitle(): string | ||
{ | ||
return __('volunteer.label.plural'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('full_name') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('full_name'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\CreateAction::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Forms\Components; | ||
|
||
use App\Filament\Resources\OrganizationResource; | ||
use App\Filament\Resources\UserResource; | ||
use App\Models\User; | ||
use Filament\Forms\Components\Field; | ||
use Illuminate\Support\Collection; | ||
|
||
class Link extends Field | ||
{ | ||
protected string $view = 'forms.components.user-link'; | ||
|
||
protected string $type = 'user'; | ||
|
||
public function getUsers(): Collection | ||
{ | ||
return $this->getRecord() | ||
->users | ||
->map(fn (User $user) => [ | ||
'name' => $user->name, | ||
'url' => UserResource::getUrl('view', $user), | ||
]); | ||
} | ||
|
||
public function getOrganization(): Collection | ||
{ | ||
return collect([])->push(['name' => $this->getRecord()->organization->name, 'url' => OrganizationResource::getUrl('view', $this->getRecord()->organization)]); | ||
} | ||
|
||
public function type(string $type): self | ||
{ | ||
$this->type = $type; | ||
|
||
return $this; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function getLinks(): Collection | ||
{ | ||
if ($this->type === 'user') { | ||
return $this->getUsers(); | ||
} | ||
|
||
return $this->getOrganization(); | ||
} | ||
} |
Oops, something went wrong.