🗑️ Remove election-related blade files no longer in use

This commit is contained in:
HolgerHatGarKeineNode
2026-01-17 23:26:05 +01:00
parent 220680ab3a
commit 0abbe69868
58 changed files with 4839 additions and 2930 deletions

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Livewire\Association\ProjectSupport\Form;
use App\Livewire\Forms\ProjectProposalForm;
use App\Support\NostrAuth;
use Livewire\Component;
use Livewire\WithFileUploads;
final class Create extends Component
{
use WithFileUploads;
public ProjectProposalForm $form;
public ?\Illuminate\Http\UploadedFile $image = null;
public bool $isAllowed = false;
public ?string $currentPubkey = null;
protected $listeners = [
'nostrLoggedIn' => 'handleNostrLoggedIn',
'nostrLoggedOut' => 'handleNostrLoggedOut',
];
public function mount(): void
{
if (NostrAuth::check()) {
$this->currentPubkey = NostrAuth::pubkey();
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
$this->isAllowed = true;
}
}
public function handleNostrLoggedIn($pubkey): void
{
NostrAuth::login($pubkey);
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
$this->isAllowed = true;
}
public function handleNostrLoggedOut(): void
{
$this->isAllowed = false;
$this->currentPubkey = null;
$this->currentPleb = null;
}
public function save(): \Illuminate\Http\RedirectResponse
{
$this->form->validate();
$projectProposal = \App\Models\ProjectProposal::query()->create([
...$this->form->all(),
'einundzwanzig_pleb_id' => $this->currentPleb->id,
]);
if ($this->image) {
$this->validate([
'image' => 'image|max:1024',
]);
$projectProposal
->addMedia($this->image->getRealPath())
->toMediaCollection('main');
}
return redirect()->route('association.projectSupport');
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Livewire\Association\ProjectSupport\Form;
use App\Livewire\Forms\ProjectProposalForm;
use App\Models\ProjectProposal;
use App\Support\NostrAuth;
use Livewire\Component;
use Livewire\WithFileUploads;
final class Edit extends Component
{
use WithFileUploads;
public ProjectProposalForm $form;
public ?ProjectProposal $projectProposal = null;
public ?\Illuminate\Http\UploadedFile $image = null;
public bool $isAllowed = false;
public ?string $currentPubkey = null;
protected $listeners = [
'nostrLoggedIn' => 'handleNostrLoggedIn',
'nostrLoggedOut' => 'handleNostrLoggedOut',
];
public function mount(ProjectProposal $projectProposal): void
{
if (NostrAuth::check()) {
$this->currentPubkey = NostrAuth::pubkey();
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
$this->isAllowed = true;
$this->form->fill($projectProposal->toArray());
$this->projectProposal = $projectProposal;
$this->image = $projectProposal->getFirstMedia('main');
}
}
public function handleNostrLoggedIn($pubkey): void
{
NostrAuth::login($pubkey);
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
$this->isAllowed = true;
}
public function handleNostrLoggedOut(): void
{
$this->isAllowed = false;
$this->currentPubkey = null;
$this->currentPleb = null;
}
public function save(): \Illuminate\Http\RedirectResponse
{
$this->form->validate();
if ($this->image && method_exists($this->image, 'temporaryUrl')) {
$this->validate([
'image' => 'nullable|image|max:1024',
]);
$this->projectProposal
->addMedia($this->image->getRealPath())
->toMediaCollection('main');
}
$this->projectProposal->update([
...$this->form->except('id', 'slug'),
]);
return redirect()->route('association.projectSupport');
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Livewire\Association\ProjectSupport;
use App\Models\ProjectProposal;
use App\Support\NostrAuth;
use Livewire\Component;
use WireUi\Actions\Notification;
final class Index extends Component
{
public string $activeFilter = 'all';
public string $search = '';
public \Illuminate\Database\Eloquent\Collection $projects;
public bool $isAllowed = false;
public ?string $currentPubkey = null;
public ?\App\Models\EinundzwanzigPleb $currentPleb = null;
protected $listeners = [
'nostrLoggedIn' => 'handleNostrLoggedIn',
'nostrLoggedOut' => 'handleNostrLoggedOut',
];
public function mount(): void
{
$this->loadProjects();
if (NostrAuth::check()) {
$this->currentPubkey = NostrAuth::pubkey();
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
$this->isAllowed = true;
}
}
public function updatedSearch(): void
{
$this->loadProjects();
}
public function loadProjects(): void
{
$this->projects = ProjectProposal::query()
->with([
'einundzwanzigPleb.profile',
'votes',
])
->where(function ($query) {
$query
->where('name', 'ilike', '%'.$this->search.'%')
->orWhere('description', 'ilike', '%'.$this->search.'%')
->orWhereHas('einundzwanzigPleb.profile', function ($q) {
$q->where('name', 'ilike', '%'.$this->search.'%');
});
})
->orderBy('created_at', 'desc')
->get();
}
public function handleNostrLoggedIn($pubkey): void
{
NostrAuth::login($pubkey);
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
$this->isAllowed = true;
}
public function handleNostrLoggedOut(): void
{
$this->isAllowed = false;
$this->currentPubkey = null;
$this->currentPleb = null;
}
public function confirmDelete($id): void
{
$notification = new Notification($this);
$notification->confirm([
'title' => 'Projektunterstützung löschen',
'message' => 'Bist du sicher, dass du diese Projektunterstützung löschen möchtest?',
'accept' => [
'label' => 'Ja, löschen',
'method' => 'delete',
'params' => $id,
],
]);
}
public function setFilter($filter): void
{
$this->activeFilter = $filter;
}
public function delete($id): void
{
ProjectProposal::query()->findOrFail($id)->delete();
$this->loadProjects();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Livewire\Association\ProjectSupport;
use App\Livewire\Forms\VoteForm;
use App\Models\ProjectProposal;
use App\Models\Vote;
use App\Support\NostrAuth;
use Livewire\Component;
final class Show extends Component
{
public VoteForm $form;
public ?ProjectProposal $projectProposal = null;
public bool $isAllowed = false;
public ?string $currentPubkey = null;
public ?\App\Models\EinundzwanzigPleb $currentPleb = null;
public bool $ownVoteExists = false;
public \Illuminate\Database\Eloquent\Collection $boardVotes;
public \Illuminate\Database\Eloquent\Collection $otherVotes;
protected $listeners = [
'nostrLoggedIn' => 'handleNostrLoggedIn',
'nostrLoggedOut' => 'handleNostrLoggedOut',
];
public function mount(ProjectProposal $projectProposal): void
{
$this->projectProposal = $projectProposal;
if (NostrAuth::check()) {
$this->currentPubkey = NostrAuth::pubkey();
$this->handleNostrLoggedIn($this->currentPubkey);
}
$this->boardVotes = $this->getBoardVotes();
$this->otherVotes = $this->getOtherVotes();
}
public function handleNostrLoggedIn($pubkey): void
{
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
$this->isAllowed = true;
$this->ownVoteExists = Vote::query()
->where('project_proposal_id', $this->projectProposal->id)
->where('einundzwanzig_pleb_id', $this->currentPleb->id)
->exists();
}
public function handleNostrLoggedOut(): void
{
$this->isAllowed = false;
$this->currentPubkey = null;
$this->currentPleb = null;
}
public function getBoardVotes(): \Illuminate\Database\Eloquent\Collection
{
return Vote::query()
->where('project_proposal_id', $this->projectProposal->id)
->whereHas('einundzwanzigPleb', fn ($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board')))
->get();
}
public function getOtherVotes(): \Illuminate\Database\Eloquent\Collection
{
return Vote::query()
->where('project_proposal_id', $this->projectProposal->id)
->whereDoesntHave(
'einundzwanzigPleb',
fn ($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board'))
)
->get();
}
public function approve(): void
{
Vote::query()->updateOrCreate([
'project_proposal_id' => $this->projectProposal->id,
'einundzwanzig_pleb_id' => $this->currentPleb->id,
], [
'value' => true,
]);
$this->form->reset();
$this->ownVoteExists = true;
$this->boardVotes = $this->getBoardVotes();
$this->otherVotes = $this->getOtherVotes();
}
public function notApprove(): void
{
$this->form->validate();
Vote::query()->updateOrCreate([
'project_proposal_id' => $this->projectProposal->id,
'einundzwanzig_pleb_id' => $this->currentPleb->id,
], [
'value' => false,
]);
$this->form->reset();
$this->ownVoteExists = true;
}
}