Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Nov 14, 2024
1 parent 55f3736 commit de57913
Show file tree
Hide file tree
Showing 28 changed files with 383 additions and 277 deletions.
46 changes: 0 additions & 46 deletions app/Actions/CheckRecordHasIssues.php

This file was deleted.

25 changes: 0 additions & 25 deletions app/Actions/CheckVotable.php

This file was deleted.

60 changes: 0 additions & 60 deletions app/Actions/GenerateMappedVotablesList.php

This file was deleted.

19 changes: 18 additions & 1 deletion app/Filament/Admin/Resources/CandidateResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ class CandidateResource extends Resource
{
protected static ?string $model = Candidate::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-o-user';

protected static ?int $navigationSort = 21;

public static function getNavigationGroup(): ?string
{
return __('app.navigation.nomenclature');
}

public static function getModelLabel(): string
{
return __('app.candidate.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('app.candidate.label.plural');
}

public static function form(Form $form): Form
{
Expand Down
17 changes: 17 additions & 0 deletions app/Filament/Admin/Resources/CountryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ class CountryResource extends Resource

protected static bool $isScopedToTenant = false;

protected static ?int $navigationSort = 29;

public static function getNavigationGroup(): ?string
{
return __('app.navigation.nomenclature');
}

public static function getModelLabel(): string
{
return __('app.country.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('app.country.label.plural');
}

public static function form(Form $form): Form
{
return $form
Expand Down
20 changes: 18 additions & 2 deletions app/Filament/Admin/Resources/CountyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ class CountyResource extends Resource
{
protected static ?string $model = County::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-o-map';

protected static bool $isScopedToTenant = false;

protected static ?int $navigationSort = 28;

public static function getNavigationGroup(): ?string
{
return __('app.navigation.nomenclature');
}

public static function getModelLabel(): string
{
return __('app.county.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('app.county.label.plural');
}

public static function form(Form $form): Form
{
return $form
Expand Down Expand Up @@ -52,7 +69,6 @@ public static function table(Table $table): Table
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
]);
}

Expand Down
25 changes: 18 additions & 7 deletions app/Filament/Admin/Resources/LocalityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,27 @@ class LocalityResource extends Resource
{
protected static ?string $model = Locality::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-o-map-pin';

protected static bool $isScopedToTenant = false;

protected static ?int $navigationSort = 27;

public static function getNavigationGroup(): ?string
{
return __('app.navigation.nomenclature');
}

public static function getModelLabel(): string
{
return __('app.locality.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('app.locality.label.plural');
}

public static function form(Form $form): Form
{
return $form
Expand Down Expand Up @@ -85,12 +102,6 @@ public static function table(Table $table): Table
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

Expand Down
9 changes: 8 additions & 1 deletion app/Filament/Admin/Resources/PartyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ class PartyResource extends Resource
{
protected static ?string $model = Party::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-o-user-group';

protected static ?int $navigationSort = 20;

public static function getNavigationGroup(): ?string
{
return __('app.navigation.nomenclature');
}

public static function getModelLabel(): string
{
Expand Down
14 changes: 10 additions & 4 deletions app/Filament/Admin/Resources/RecordResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use App\Filament\Admin\Resources\RecordResource\Pages;
use App\Models\Record;
use App\Models\Result;
use App\Tables\Columns\LocationColumn;
use Filament\Resources\Resource;
use Filament\Tables\Columns\TextColumn;
Expand All @@ -19,14 +18,19 @@ class RecordResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function getNavigationGroup(): ?string
{
return __('app.navigation.election_data');
}

public static function getModelLabel(): string
{
return __('app.result.label.singular');
return __('app.record.label.singular');
}

public static function getPluralModelLabel(): string
{
return __('app.result.label.plural');
return __('app.record.label.plural');
}

public static function table(Table $table): Table
Expand All @@ -36,6 +40,8 @@ public static function table(Table $table): Table
->columns([
LocationColumn::make('location'),

TextColumn::make('part'),

TextColumn::make('eligible_voters_total')
->label(__('app.field.eligible_voters_total'))
->numeric()
Expand Down Expand Up @@ -107,7 +113,7 @@ public static function table(Table $table): Table
])
->paginated([10, 25, 50, 100])
->deferLoading()
->recordClasses(fn (Result $result) => $result->has_issues ? 'bg-warning-50 dark:bg-warning-400/10' : null);
->recordClasses(fn (Record $record) => $record->has_issues ? 'bg-warning-50 dark:bg-warning-400/10' : null);
}

public static function getRelations(): array
Expand Down
5 changes: 5 additions & 0 deletions app/Filament/Admin/Resources/TurnoutResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class TurnoutResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function getNavigationGroup(): ?string
{
return __('app.navigation.election_data');
}

public static function getModelLabel(): string
{
return __('app.turnout.label');
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Imports/SimpleCandidateImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Filament\Imports;

use App\Actions\CheckVotable;
use App\Models\Candidate;
use App\Models\Party;
use App\Services\RecordService;
use Carbon\CarbonInterface;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
Expand All @@ -33,7 +33,7 @@ public function getJobRetryUntil(): ?CarbonInterface

public function resolveRecord(): Candidate|Party
{
static::$model = app(CheckVotable::class)->isIndependentCandidate($this->data['name'])
static::$model = RecordService::isIndependentCandidate($this->data['name'])
? Candidate::class
: Party::class;

Expand All @@ -45,7 +45,7 @@ public function resolveRecord(): Candidate|Party

protected function afterValidate(): void
{
$this->data['name'] = app(CheckVotable::class)->getName($this->data['name']);
$this->data['name'] = RecordService::getName($this->data['name']);
}

public static function getCompletedNotificationBody(Import $import): string
Expand Down
Loading

0 comments on commit de57913

Please sign in to comment.