Fix assemblee hub fallback and mobile sidebar CSS
This commit is contained in:
parent
38cf73a9ab
commit
df441bcc43
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Condomini;
|
||||
|
||||
use App\Filament\Pages\Strumenti\DocumentiArchivio;
|
||||
|
|
@ -12,6 +11,8 @@
|
|||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\QueryException;
|
||||
use UnitEnum;
|
||||
|
||||
class AssembleeHub extends Page
|
||||
|
|
@ -37,7 +38,7 @@ public static function canAccess(): bool
|
|||
$user = Auth::user();
|
||||
|
||||
return $user instanceof User
|
||||
&& $user->hasAnyRole(['super-admin', 'admin', 'amministratore', 'collaboratore']);
|
||||
&& $user->hasAnyRole(['super-admin', 'admin', 'amministratore', 'collaboratore']);
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
|
|
@ -68,42 +69,59 @@ protected function getHeaderActions(): array
|
|||
public function getStatsProperty(): array
|
||||
{
|
||||
$stabileId = (int) ($this->stabileAttivo?->id ?? 0);
|
||||
if ($stabileId <= 0) {
|
||||
if ($stabileId <= 0 || ! $this->canQueryAssemblee()) {
|
||||
return ['totale' => 0, 'convocate' => 0, 'in_calendario' => 0, 'con_verbale' => 0];
|
||||
}
|
||||
|
||||
$query = Assemblea::query()->where('stabile_id', $stabileId);
|
||||
try {
|
||||
$query = Assemblea::query()->where('stabile_id', $stabileId);
|
||||
|
||||
return [
|
||||
'totale' => (clone $query)->count(),
|
||||
'convocate' => (clone $query)->where('stato', 'convocata')->count(),
|
||||
'in_calendario'=> (clone $query)
|
||||
->where(function ($builder): void {
|
||||
$today = now();
|
||||
return [
|
||||
'totale' => (clone $query)->count(),
|
||||
'convocate' => (clone $query)->where('stato', 'convocata')->count(),
|
||||
'in_calendario' => (clone $query)
|
||||
->where(function ($builder): void {
|
||||
$today = now();
|
||||
|
||||
$builder->whereDate('data_prima_convocazione', '>=', $today->toDateString())
|
||||
->orWhereDate('data_seconda_convocazione', '>=', $today->toDateString());
|
||||
})
|
||||
->count(),
|
||||
'con_verbale' => (clone $query)->whereHas('verbale')->count(),
|
||||
];
|
||||
$builder->whereDate('data_prima_convocazione', '>=', $today->toDateString())
|
||||
->orWhereDate('data_seconda_convocazione', '>=', $today->toDateString());
|
||||
})
|
||||
->count(),
|
||||
'con_verbale' => (clone $query)->whereHas('verbale')->count(),
|
||||
];
|
||||
} catch (QueryException) {
|
||||
return ['totale' => 0, 'convocate' => 0, 'in_calendario' => 0, 'con_verbale' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAssembleeRowsProperty(): Collection
|
||||
{
|
||||
$stabileId = (int) ($this->stabileAttivo?->id ?? 0);
|
||||
if ($stabileId <= 0) {
|
||||
if ($stabileId <= 0 || ! $this->canQueryAssemblee()) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return Assemblea::query()
|
||||
->with(['verbale:id,assemblea_id'])
|
||||
->withCount(['ordineGiorno', 'convocazioni', 'presenze', 'documenti'])
|
||||
->where('stabile_id', $stabileId)
|
||||
->orderByDesc('data_seconda_convocazione')
|
||||
->orderByDesc('data_prima_convocazione')
|
||||
->orderByDesc('id')
|
||||
->limit(16)
|
||||
->get();
|
||||
try {
|
||||
return Assemblea::query()
|
||||
->with(['verbale:id,assemblea_id'])
|
||||
->withCount(['ordineGiorno', 'convocazioni', 'presenze', 'documenti'])
|
||||
->where('stabile_id', $stabileId)
|
||||
->orderByDesc('data_seconda_convocazione')
|
||||
->orderByDesc('data_prima_convocazione')
|
||||
->orderByDesc('id')
|
||||
->limit(16)
|
||||
->get();
|
||||
} catch (QueryException) {
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function canQueryAssemblee(): bool
|
||||
{
|
||||
try {
|
||||
return Schema::hasTable((new Assemblea())->getTable());
|
||||
} catch (QueryException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ public function panel(Panel $panel): Panel
|
|||
return $user instanceof User && $user->hasRole('fornitore');
|
||||
}),
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->discoverResources(in: app_path('Filament/Resources'), for : 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for : 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
SupportoDashboard::class,
|
||||
|
|
@ -111,7 +111,7 @@ public function panel(Panel $panel): Panel
|
|||
PrimaNotaModifica::class,
|
||||
ContoMastrino::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for : 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
TicketMobileOverview::class,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"isEntry": true
|
||||
},
|
||||
"resources/css/filament/admin/theme.css": {
|
||||
"file": "assets/theme-CDFysGCE.css",
|
||||
"file": "assets/theme-Cs5qngWh.css",
|
||||
"src": "resources/css/filament/admin/theme.css",
|
||||
"isEntry": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -23,20 +23,6 @@ .fi-main-ctn>main {
|
|||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.fi-sidebar {
|
||||
position: static !important;
|
||||
top: auto !important;
|
||||
align-self: stretch !important;
|
||||
height: auto !important;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.fi-sidebar-header {
|
||||
position: static !important;
|
||||
top: auto !important;
|
||||
z-index: 20 !important;
|
||||
}
|
||||
|
||||
.fi-main {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user