🚀 feat(profile): update video visibility based on user login state in profile page

🎨 style(app): reorder script includes for better organization in app layout

 feat(plebTable): implement confirmation dialogs for accepting and deleting entries in Pleb table
This commit is contained in:
fsociety
2024-10-07 12:49:47 +02:00
parent 140809c142
commit 5e830a83a7
3 changed files with 59 additions and 11 deletions

View File

@@ -16,9 +16,11 @@ use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridFields; use PowerComponents\LivewirePowerGrid\PowerGridFields;
use PowerComponents\LivewirePowerGrid\PowerGridComponent; use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Traits\WithExport; use PowerComponents\LivewirePowerGrid\Traits\WithExport;
use WireUi\Traits\WireUiActions;
final class EinundzwanzigPlebTable extends PowerGridComponent final class EinundzwanzigPlebTable extends PowerGridComponent
{ {
use WireUiActions;
use WithExport; use WithExport;
public string $sortField = 'application_for'; public string $sortField = 'application_for';
@@ -139,8 +141,37 @@ final class EinundzwanzigPlebTable extends PowerGridComponent
return []; return [];
} }
#[\Livewire\Attributes\On('edit')] #[\Livewire\Attributes\On('accept')]
public function edit($rowId): void public function accept($rowId): void
{
$pleb = EinundzwanzigPleb::query()
->with('profile')
->findOrFail($rowId);
$this->dialog()->confirm([
'title' => 'Bist du sicher?',
'description' => 'Möchtest du ' . $pleb->profile->name . ' wirklich akzeptieren?',
'acceptLabel' => 'Ja, akzeptieren',
'method' => 'acceptPleb',
'params' => $rowId,
]);
}
#[\Livewire\Attributes\On('delete')]
public function delete($rowId): void
{
$pleb = EinundzwanzigPleb::query()
->with('profile')
->findOrFail($rowId);
$this->dialog()->confirm([
'title' => 'Bist du sicher?',
'description' => 'Möchtest du ' . $pleb->profile->name . ' wirklich löschen?',
'acceptLabel' => 'Ja, lösche',
'method' => 'deletePleb',
'params' => $rowId,
]);
}
public function acceptPleb($rowId)
{ {
$pleb = EinundzwanzigPleb::query()->findOrFail($rowId); $pleb = EinundzwanzigPleb::query()->findOrFail($rowId);
$for = $pleb->application_for; $for = $pleb->application_for;
@@ -154,16 +185,33 @@ final class EinundzwanzigPlebTable extends PowerGridComponent
$this->fillData(); $this->fillData();
} }
public function deletePleb($rowId)
{
$pleb = EinundzwanzigPleb::query()->findOrFail($rowId);
$pleb->application_for = null;
$pleb->application_text = null;
$pleb->save();
$this->fillData();
}
public function actions(EinundzwanzigPleb $row): array public function actions(EinundzwanzigPleb $row): array
{ {
return [ return [
Button::add('edit') Button::add('delete')
->slot('Approve') ->slot('Löschen')
->id()
->class(
'btn bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-red-500',
)
->dispatch('delete', ['rowId' => $row->id]),
Button::add('accept')
->slot('Akzeptieren')
->id() ->id()
->class( ->class(
'btn bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-green-500', 'btn bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-green-500',
) )
->dispatch('edit', ['rowId' => $row->id]), ->dispatch('accept', ['rowId' => $row->id]),
]; ];
} }
@@ -171,7 +219,7 @@ final class EinundzwanzigPlebTable extends PowerGridComponent
{ {
return [ return [
// Hide button edit for ID 1 // Hide button edit for ID 1
Rule::button('edit') Rule::button('accept')
->when(fn($row) => $row->application_for === null) ->when(fn($row) => $row->application_for === null)
->hide(), ->hide(),
]; ];

View File

@@ -6,11 +6,11 @@
<title>{{ $title ?? 'Page Title' }}</title> <title>{{ $title ?? 'Page Title' }}</title>
@livewireStyles @livewireStyles
@wireUiScripts
@stack('scripts')
@vite(['resources/js/app.js','resources/css/app.css']) @vite(['resources/js/app.js','resources/css/app.css'])
@googlefonts @googlefonts
<script src="https://kit.fontawesome.com/866fd3d0ab.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/866fd3d0ab.js" crossorigin="anonymous"></script>
@wireUiScripts
@stack('scripts')
</head> </head>
<body <body
class="font-sans antialiased bg-gray-100 dark:bg-[#222222] text-gray-600 dark:text-gray-400" class="font-sans antialiased bg-gray-100 dark:bg-[#222222] text-gray-600 dark:text-gray-400"
@@ -18,6 +18,8 @@
x-data="{ sidebarOpen: false, sidebarExpanded: localStorage.getItem('sidebar-expanded') == 'true', inboxSidebarOpen: false }" x-data="{ sidebarOpen: false, sidebarExpanded: localStorage.getItem('sidebar-expanded') == 'true', inboxSidebarOpen: false }"
x-init="$watch('sidebarExpanded', value => localStorage.setItem('sidebar-expanded', value))" x-init="$watch('sidebarExpanded', value => localStorage.setItem('sidebar-expanded', value))"
> >
<x-dialog />
<x-notifications />
<script> <script>
if (localStorage.getItem('sidebar-expanded') == 'true') { if (localStorage.getItem('sidebar-expanded') == 'true') {
document.querySelector('body').classList.add('sidebar-expanded'); document.querySelector('body').classList.add('sidebar-expanded');

View File

@@ -340,15 +340,13 @@ $loadEvents = function () {
</div> </div>
@endif @endif
</div> </div>
<div class="mt-8 flex"> <div class="mt-8 flex" x-show="!$store.nostr.user">
<div class="w-full sm:w-1/2"> <div class="w-full sm:w-1/2">
<h2 class="text-xl leading-snug text-[#1B1B1B] dark:text-gray-100 font-bold mb-1"> <h2 class="text-xl leading-snug text-[#1B1B1B] dark:text-gray-100 font-bold mb-1">
Nsec.app Tutorial (sicheres Anmelden mit Nsec) Nsec.app Tutorial (sicheres Anmelden mit Nsec)
</h2> </h2>
<video class="aspect-video rounded-lg shadow-sm" <video class="aspect-video rounded-lg shadow-sm"
x-show="!$store.nostr.user"
src="https://v.nostr.build/bomfuwLnOTIDrP4y.mp4" src="https://v.nostr.build/bomfuwLnOTIDrP4y.mp4"
autoplay
playsinline playsinline
controls/> controls/>
</div> </div>