Skip to content

Commit

Permalink
fix: add election banner (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Dec 6, 2024
1 parent fc95d39 commit 196c5c9
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 309 deletions.
25 changes: 17 additions & 8 deletions app/Filament/Admin/Resources/ElectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public static function form(Form $form): Form
->label(__('app.field.has_lists'))
->default(false),

Toggle::make('properties.show_threshold')
->label(__('app.field.show_threshold'))
->default(false),

TextInput::make('properties.total_seats')
->label(__('app.field.total_seats'))
->nullable()
->numeric(),

Select::make('properties.default_tab')
->label(__('app.field.default_tab'))
->options(DefaultElectionPage::options())
Expand Down Expand Up @@ -151,14 +160,10 @@ public static function form(Form $form): Form
->columnSpanFull()
->nullable(),

Toggle::make('properties.show_threshold')
->label(__('app.field.show_threshold'))
->default(false),

TextInput::make('properties.total_seats')
->label(__('app.field.total_seats'))
->nullable()
->numeric(),
TextInput::make('properties.alert')
->label(__('app.field.alert'))
->columnSpanFull()
->nullable(),
]);
}

Expand Down Expand Up @@ -216,6 +221,10 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('locality')
->label(__('app.field.locality')),
]),

TextEntry::make('properties.alert')
->label(__('app.field.alert'))
->columnSpanFull(),
]),

Infolists\Components\Section::make()
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/VotesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function getForLevel(

$data = [
'name' => $votable->acronym ?? $votable->name,
'image' => $votable->getFirstMegetFirstMediaUrl('default', 'thumb'),
'image' => $votable->getFirstMediaUrl('default', 'thumb'),
'votes' => (int) ensureNumeric($vote->votes),
'percent' => percent($vote->votes, $total),
'color' => hex2rgb($votable->color),
Expand Down
29 changes: 29 additions & 0 deletions app/View/Components/Election/Alert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace App\View\Components\Election;

use App\Models\Election;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Alert extends Component
{
public ?string $alert = null;

public function __construct(Election $election)
{
$this->alert = data_get($election, 'properties.alert');
}

public function shouldRender(): bool
{
return filled($this->alert);
}

public function render(): View
{
return view('components.election.alert');
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"laravel/telescope": "^5.2",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.5",
"phpunit/phpunit": "^11.4",
"spatie/laravel-ignition": "^2.8"
"phpunit/phpunit": "^11.5",
"spatie/laravel-ignition": "^2.9"
},
"autoload": {
"files": [
Expand Down
Loading

0 comments on commit 196c5c9

Please sign in to comment.