diff --git a/app/Livewire/Association/Election/Show.php b/app/Livewire/Association/Election/Show.php
index b6e0185..19d4ee9 100644
--- a/app/Livewire/Association/Election/Show.php
+++ b/app/Livewire/Association/Election/Show.php
@@ -4,7 +4,9 @@ namespace App\Livewire\Association\Election;
use App\Models\EinundzwanzigPleb;
use App\Models\Election;
+use App\Models\Profile;
use App\Support\NostrAuth;
+use Livewire\Attributes\Computed;
use Livewire\Component;
use swentel\nostr\Event\Event as NostrEvent;
use swentel\nostr\Filter\Filter;
@@ -39,12 +41,149 @@ final class Show extends Component
public bool $isNotClosed = true;
+ public array $positions = [
+ 'presidency' => ['icon' => 'fa-crown', 'title' => 'Präsidium'],
+ 'board' => ['icon' => 'fa-users', 'title' => 'Vizepräsidium'],
+ ];
+
protected $listeners = [
'nostrLoggedIn' => 'handleNostrLoggedIn',
'nostrLoggedOut' => 'handleNostrLoggedOut',
'echo:votes,.newVote' => 'handleNewVote',
];
+ #[Computed]
+ public function loadedEvents(): array
+ {
+ return collect($this->events)
+ ->map(function ($event) {
+ $profile = Profile::query()
+ ->where('pubkey', $event['pubkey'])
+ ->first()
+ ?->toArray();
+ $votedFor = Profile::query()
+ ->where('pubkey', str($event['content'])->before(',')->toString())
+ ->first()
+ ?->toArray();
+
+ return [
+ 'id' => $event['id'],
+ 'kind' => $event['kind'],
+ 'content' => $event['content'],
+ 'pubkey' => $event['pubkey'],
+ 'tags' => $event['tags'],
+ 'created_at' => $event['created_at'],
+ 'profile' => $profile,
+ 'votedFor' => $votedFor,
+ 'type' => str($event['content'])->after(',')->toString(),
+ ];
+ })
+ ->sortByDesc('created_at')
+ ->unique(fn ($event) => $event['pubkey'].$event['type'])
+ ->values()
+ ->toArray();
+ }
+
+ #[Computed]
+ public function loadedBoardEvents(): array
+ {
+ return collect($this->boardEvents)
+ ->map(function ($event) {
+ $profile = Profile::query()
+ ->where('pubkey', $event['pubkey'])
+ ->first()
+ ?->toArray();
+ $votedFor = Profile::query()
+ ->where('pubkey', str($event['content'])->before(',')->toString())
+ ->first()
+ ?->toArray();
+
+ return [
+ 'id' => $event['id'],
+ 'kind' => $event['kind'],
+ 'content' => $event['content'],
+ 'pubkey' => $event['pubkey'],
+ 'tags' => $event['tags'],
+ 'created_at' => $event['created_at'],
+ 'profile' => $profile,
+ 'votedFor' => $votedFor,
+ 'type' => str($event['content'])->after(',')->toString(),
+ ];
+ })
+ ->sortByDesc('created_at')
+ ->values()
+ ->toArray();
+ }
+
+ #[Computed]
+ public function electionConfig(): array
+ {
+ $loadedEvents = $this->loadedEvents();
+
+ return collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR))
+ ->map(function ($c) use ($loadedEvents) {
+ $candidates = Profile::query()
+ ->whereIn('pubkey', $c['c'])
+ ->get()
+ ->map(function ($p) use ($loadedEvents, $c) {
+ $votedClass = ' bg-green-500/20 text-green-700';
+ $notVotedClass = ' bg-gray-500/20 text-gray-100';
+ $hasVoted = $loadedEvents
+ ->filter(fn ($e) => $e['type'] === $c['type'] && $e['pubkey'] === $this->currentPubkey)
+ ->firstWhere('votedFor.pubkey', $p->pubkey);
+
+ return [
+ 'pubkey' => $p->pubkey,
+ 'name' => $p->name,
+ 'picture' => $p->picture,
+ 'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
+ ];
+ });
+
+ return [
+ 'type' => $c['type'],
+ 'c' => $c['c'],
+ 'candidates' => $candidates,
+ ];
+ })
+ ->toArray();
+ }
+
+ #[Computed]
+ public function electionConfigBoard(): array
+ {
+ $loadedBoardEvents = $this->loadedBoardEvents();
+
+ return collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR))
+ ->map(function ($c) use ($loadedBoardEvents) {
+ $candidates = Profile::query()
+ ->whereIn('pubkey', $c['c'])
+ ->get()
+ ->map(function ($p) use ($loadedBoardEvents, $c) {
+ $votedClass = ' bg-green-500/20 text-green-700';
+ $notVotedClass = ' bg-gray-500/20 text-gray-100';
+ $hasVoted = $loadedBoardEvents
+ ->filter(fn ($e) => $e['type'] === $c['type'] && $e['pubkey'] === $this->currentPubkey)
+ ->firstWhere('votedFor.pubkey', $p->pubkey);
+
+ return [
+ 'pubkey' => $p->pubkey,
+ 'name' => $p->name,
+ 'picture' => $p->picture,
+ 'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
+ 'hasVoted' => $hasVoted,
+ ];
+ });
+
+ return [
+ 'type' => $c['type'],
+ 'c' => $c['c'],
+ 'candidates' => $candidates,
+ ];
+ })
+ ->toArray();
+ }
+
public function mount(Election $election): void
{
$this->election = $election;
diff --git a/app/Livewire/Changelog.php b/app/Livewire/Changelog.php
index 46e63bb..8104dcc 100644
--- a/app/Livewire/Changelog.php
+++ b/app/Livewire/Changelog.php
@@ -2,6 +2,7 @@
namespace App\Livewire;
+use Illuminate\Support\Facades\Process;
use Livewire\Component;
final class Changelog extends Component
@@ -10,7 +11,9 @@ final class Changelog extends Component
public function mount(): void
{
- $output = shell_exec('git log -n1000 --pretty=format:"%H|%s|%an|%ad" --date=format:"%Y-%m-%d %H:%M:%S"');
+ $process = Process::fromShellCommandline('git log -n1000 --pretty=format:"%H|%s|%an|%ad" --date=format:"%Y-%m-%d %H:%M:%S"');
+ $process->run();
+ $output = $process->getOutput();
$lines = explode("\n", trim($output));
$entries = [];
diff --git a/resources/views/livewire/association/election/admin.blade.php b/resources/views/livewire/association/election/admin.blade.php
index b3d1411..4b7a27a 100644
--- a/resources/views/livewire/association/election/admin.blade.php
+++ b/resources/views/livewire/association/election/admin.blade.php
@@ -1,12 +1,12 @@
- ['icon' => 'fa-crown', 'title' => 'Präsidium'],
'board' => ['icon' => 'fa-users', 'title' => 'Vorstandsmitglieder'],
];
- ?>
+ @endphp
-
+ @if($isAllowed)
@@ -16,16 +16,16 @@
- Wahl des Vorstands year); ?>
+ Wahl des Vorstands {{ $election->year }}
-
+ @endphp
@@ -33,11 +33,11 @@
class="flex flex-col bg-white dark:bg-gray-800 shadow-sm rounded-xl">
+ class="fa-sharp-duotone fa-solid {{ $president['icon'] }} w-5 h-5 fill-current text-white mr-4">{{ $president['title'] }}
-
+
@@ -46,11 +46,11 @@
class="flex flex-col bg-white dark:bg-gray-800 shadow-sm rounded-xl">
+ class="fa-sharp-duotone fa-solid {{ $board['icon'] }} w-5 h-5 fill-current text-white mr-4">{{ $board['title'] }}
-
+
@@ -59,7 +59,7 @@
-
+ @else
-
+ @endif
diff --git a/resources/views/livewire/association/election/index.blade.php b/resources/views/livewire/association/election/index.blade.php
index f1e0f03..856d5cd 100644
--- a/resources/views/livewire/association/election/index.blade.php
+++ b/resources/views/livewire/association/election/index.blade.php
@@ -1,23 +1,23 @@
-
+ @if($isAllowed)
-
-
+ @foreach($elections as $election)
+
-
+ {{ $election['year'] }}
-
-
+
-
+ @endforeach
-
+ @else
-
+ @endif
diff --git a/resources/views/livewire/association/election/show.blade.php b/resources/views/livewire/association/election/show.blade.php
index 7f0f33d..732b96a 100644
--- a/resources/views/livewire/association/election/show.blade.php
+++ b/resources/views/livewire/association/election/show.blade.php
@@ -2,69 +2,11 @@
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Wahlen ' . $election->year, description: 'Wahlen des Vereins im Jahr ' . $election->year)"
>
-
+ @if($isAllowed)
- ['icon' => 'fa-crown', 'title' => 'Präsidium'],
- 'board' => ['icon' => 'fa-users', 'title' => 'Vizepräsidium'],
- ];
- $loadedEvents = collect($events)
- ->map(function($event) {
- $profile = \App\Models\Profile::query()
- ->where('pubkey', $event['pubkey'])
- ->first()
- ?->toArray();
- $votedFor = \App\Models\Profile::query()
- ->where('pubkey', str($event['content'])->before(',')->toString())
- ->first()
- ?->toArray();
-
- return [
- 'id' => $event['id'],
- 'kind' => $event['kind'],
- 'content' => $event['content'],
- 'pubkey' => $event['pubkey'],
- 'tags' => $event['tags'],
- 'created_at' => $event['created_at'],
- 'profile' => $profile,
- 'votedFor' => $votedFor,
- 'type' => str($event['content'])->after(',')->toString(),
- ];
- })
- ->sortByDesc('created_at')
- ->unique(fn ($event) => $event['pubkey'] . $event['type'])
- ->values();
- $loadedBoardEvents = collect($boardEvents)
- ->map(function($event) {
- $profile = \App\Models\Profile::query()
- ->where('pubkey', $event['pubkey'])
- ->first()
- ?->toArray();
- $votedFor = \App\Models\Profile::query()
- ->where('pubkey', str($event['content'])->before(',')->toString())
- ->first()
- ?->toArray();
-
- return [
- 'id' => $event['id'],
- 'kind' => $event['kind'],
- 'content' => $event['content'],
- 'pubkey' => $event['pubkey'],
- 'tags' => $event['tags'],
- 'created_at' => $event['created_at'],
- 'profile' => $profile,
- 'votedFor' => $votedFor,
- 'type' => str($event['content'])->after(',')->toString(),
- ];
- })
- ->sortByDesc('created_at')
- ->values();
- ?>
-
-
+
-
+ @foreach($plebs as $pleb)
-
+ class="text-sm font-semibold text-gray-800 dark:text-gray-100 truncate">{{ $pleb['profile']['name'] ?? $pleb['pubkey'] }}
+ :color="\App\Enums\AssociationStatus::from($pleb['association_status'])->color()"
+ :label="\App\Enums\AssociationStatus::from($pleb['association_status'])->label()"/>
- $p): ?>
- filter(fn ($e) => $e['pubkey'] === $pleb['pubkey'])->firstWhere('type', $name);
- ?>
+ @foreach($positions as $name => $p)
+ @php
+ $votedResult = $this->loadedEvents->filter(fn ($e) => $e['pubkey'] === $pleb['pubkey'])->firstWhere('type', $name);
+ @endphp
-
-
-
+ wire:key="p_{{ $name }}">
+ @if($votedResult)
+
+ @endif
-
+ @endforeach
-
+ @endforeach
@@ -204,64 +146,7 @@
-
-
- candidates, true, 512, JSON_THROW_ON_ERROR))
- ->map(function ($c) use ($loadedEvents, $currentPubkey) {
- $candidates = \App\Models\Profile::query()
- ->whereIn('pubkey', $c['c'])
- ->get()
- ->map(function ($p) use ($loadedEvents, $c, $currentPubkey) {
- $votedClass = ' bg-green-500/20 text-green-700';
- $notVotedClass = ' bg-gray-500/20 text-gray-100';
- $hasVoted = $loadedEvents
- ->filter(fn($e) => $e['type'] === $c['type'] && $e['pubkey'] === $currentPubkey)
- ->firstWhere('votedFor.pubkey', $p->pubkey);
-
- return [
- 'pubkey' => $p->pubkey,
- 'name' => $p->name,
- 'picture' => $p->picture,
- 'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
- ];
- });
-
- return [
- 'type' => $c['type'],
- 'c' => $c['c'],
- 'candidates' => $candidates,
- ];
- });
- $electionConfigBoard = collect(json_decode($election->candidates, true, 512, JSON_THROW_ON_ERROR))
- ->map(function ($c) use ($loadedBoardEvents, $currentPubkey) {
- $candidates = \App\Models\Profile::query()
- ->whereIn('pubkey', $c['c'])
- ->get()
- ->map(function ($p) use ($loadedBoardEvents, $c, $currentPubkey) {
- $votedClass = ' bg-green-500/20 text-green-700';
- $notVotedClass = ' bg-gray-500/20 text-gray-100';
- $hasVoted = $loadedBoardEvents
- ->filter(fn($e) => $e['type'] === $c['type'] && $e['pubkey'] === $currentPubkey)
- ->firstWhere('votedFor.pubkey', $p->pubkey);
-
- return [
- 'pubkey' => $p->pubkey,
- 'name' => $p->name,
- 'picture' => $p->picture,
- 'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
- 'hasVoted' => $hasVoted,
- ];
- });
-
- return [
- 'type' => $c['type'],
- 'c' => $c['c'],
- 'candidates' => $candidates,
- ];
- });
- ?>
-
+ @if($currentPubkey)
-
-
+ @empty
Keine News vorhanden.
-
+ @endforelse
@@ -145,43 +142,36 @@
-
+ @if($canEdit)
News anlegen
-
-
- getBag($__errorProps ?? 'default');
-if ($__bag->has($__errorArgs)) :
-if (isset($message)) { $__messageOriginal = $message; }
-$message = $__bag->first($__errorArgs); ?>
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ @error('file')
+ {{ $message }}
+ @enderror
+
+
+
+
+
+
+
+
+
+
-
+ @endif
@@ -199,7 +189,7 @@ unset($__errorArgs, $__bag); ?>
-
+ @else
@@ -212,6 +202,6 @@ unset($__errorArgs, $__bag); ?>
-
+ @endif
diff --git a/resources/views/livewire/association/profile.blade.php b/resources/views/livewire/association/profile.blade.php
index 561d880..ef209a5 100644
--- a/resources/views/livewire/association/profile.blade.php
+++ b/resources/views/livewire/association/profile.blade.php
@@ -199,10 +199,10 @@
-
-
-
+
+
+
-
+
Ich informiere mich selbst in der News Sektion und gebe keine E-Mail Adresse raus.
@@ -249,9 +250,9 @@
@if($showEmail)
-
-
+
+
diff --git a/resources/views/livewire/association/project-support/form/create.blade.php b/resources/views/livewire/association/project-support/form/create.blade.php
index 71838e7..73ae201 100644
--- a/resources/views/livewire/association/project-support/form/create.blade.php
+++ b/resources/views/livewire/association/project-support/form/create.blade.php
@@ -1,102 +1,74 @@
-
+