feat(unita-immobiliare): FHD screen width optimization, Condomino vs Inquilino role toggle buttons, and tab deduplication (task-d095b0e23b)
This commit is contained in:
parent
1c31fed982
commit
23741f453b
|
|
@ -98,6 +98,8 @@ public static function canAccess(): bool
|
||||||
|
|
||||||
public string $tab = 'riepilogo';
|
public string $tab = 'riepilogo';
|
||||||
|
|
||||||
|
public string $condInquilActive = 'C';
|
||||||
|
|
||||||
public array $millesimiPerTabella = [];
|
public array $millesimiPerTabella = [];
|
||||||
|
|
||||||
public array $dirittiProprieta = [];
|
public array $dirittiProprieta = [];
|
||||||
|
|
@ -791,7 +793,16 @@ public function getEstrattoContoNominativoDettaglioProperty(): array
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $selectedItem) {
|
if (! $selectedItem) {
|
||||||
$selectedItem = end($timeline);
|
$roleTarget = $this->condInquilActive === 'I' ? 'Inquilino' : 'Condomino / Proprietario';
|
||||||
|
foreach ($timeline as $t) {
|
||||||
|
if (($t['ruolo'] ?? '') === $roleTarget) {
|
||||||
|
$selectedItem = $t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $selectedItem) {
|
||||||
|
$selectedItem = end($timeline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$idCond = $selectedItem['id_cond'] ?? 0;
|
$idCond = $selectedItem['id_cond'] ?? 0;
|
||||||
|
|
@ -1204,6 +1215,18 @@ public function getUnitaOptions(): array
|
||||||
return $this->unitaOptionsCache;
|
return $this->unitaOptionsCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCondInquilActive(string $role): void
|
||||||
|
{
|
||||||
|
$role = strtoupper(trim($role));
|
||||||
|
if (in_array($role, ['C', 'CONDOMINO', 'CONDOMINI'], true)) {
|
||||||
|
$this->condInquilActive = 'C';
|
||||||
|
$this->estrattoTipo = 'condomini';
|
||||||
|
} elseif (in_array($role, ['I', 'INQUILINO', 'INQUILINI'], true)) {
|
||||||
|
$this->condInquilActive = 'I';
|
||||||
|
$this->estrattoTipo = 'inquilini';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function setEstrattoTipo(string $tipo): void
|
public function setEstrattoTipo(string $tipo): void
|
||||||
{
|
{
|
||||||
$tipo = strtolower(trim($tipo));
|
$tipo = strtolower(trim($tipo));
|
||||||
|
|
@ -1211,7 +1234,8 @@ public function setEstrattoTipo(string $tipo): void
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->estrattoTipo = $tipo;
|
$this->estrattoTipo = $tipo;
|
||||||
|
$this->condInquilActive = $tipo === 'inquilini' ? 'I' : 'C';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<x-filament-panels::page>
|
<x-filament-panels::page>
|
||||||
<div class="mx-auto max-w-7xl space-y-4">
|
<div class="w-full max-w-full space-y-4 px-2 lg:px-6">
|
||||||
{{-- BARRA PULSANTINI ICONICI COMPATTI UNIFICATA (SENZA SCROLL ORIZZONTALE) --}}
|
{{-- BARRA NAVIGAZIONE UNIFICATA E COMPATTA --}}
|
||||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-slate-200 bg-white/80 p-2 shadow-xs backdrop-blur-xs">
|
<div class="mb-2 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-slate-200 bg-white/80 p-2 shadow-xs backdrop-blur-xs">
|
||||||
<div class="flex flex-wrap items-center gap-1.5">
|
<div class="flex flex-wrap items-center gap-1.5">
|
||||||
<a href="{{ \App\Filament\Pages\Gescon\StabiliArchivio::getUrl(panel: 'admin-filament') }}"
|
<a href="{{ \App\Filament\Pages\Gescon\StabiliArchivio::getUrl(panel: 'admin-filament') }}"
|
||||||
|
|
@ -29,35 +29,6 @@ class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-sl
|
||||||
<span>Catasto</span>
|
<span>Catasto</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Sotto-Tab della pagina corrente --}}
|
|
||||||
<div class="flex flex-wrap items-center gap-1">
|
|
||||||
<button type="button" wire:click="setTab('riepilogo')"
|
|
||||||
class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition {{ $tab === 'riepilogo' ? 'bg-indigo-700 text-white shadow-md ring-2 ring-indigo-500/20 font-semibold' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
|
||||||
<span>📊</span>
|
|
||||||
<span>Riepilogo</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" wire:click="setTab('nominativi')"
|
|
||||||
class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition {{ $tab === 'nominativi' ? 'bg-indigo-700 text-white shadow-md ring-2 ring-indigo-500/20 font-semibold' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
|
||||||
<span>👥</span>
|
|
||||||
<span>Nominativi & Subentri</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" wire:click="setTab('estratto_conto')"
|
|
||||||
class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition {{ $tab === 'estratto_conto' ? 'bg-indigo-700 text-white shadow-md ring-2 ring-indigo-500/20 font-semibold' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
|
||||||
<span>🧾</span>
|
|
||||||
<span>Estratto Conto & Pagamenti</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" wire:click="setTab('millesimi')"
|
|
||||||
class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition {{ $tab === 'millesimi' ? 'bg-indigo-700 text-white shadow-md ring-2 ring-indigo-500/20 font-semibold' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
|
||||||
<span>📐</span>
|
|
||||||
<span>Tabelle Millesimali</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" wire:click="setTab('catasto')"
|
|
||||||
class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition {{ $tab === 'catasto' ? 'bg-indigo-700 text-white shadow-md ring-2 ring-indigo-500/20 font-semibold' : 'bg-slate-100 text-slate-600 hover:bg-slate-200' }}">
|
|
||||||
<span>🏛️</span>
|
|
||||||
<span>Catasto</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@php
|
@php
|
||||||
|
|
@ -71,7 +42,7 @@ class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-me
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
{{-- CONTROLLI COMPATTI SELEZIONE UNITÀ & VISTA --}}
|
{{-- CONTROLLI COMPATTI SELEZIONE UNITÀ & PULSANTI RUOLO CONDOMINO / INQUILINO --}}
|
||||||
<div class="mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-slate-200 bg-white p-2.5 shadow-xs">
|
<div class="mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-slate-200 bg-white p-2.5 shadow-xs">
|
||||||
<div class="flex flex-wrap items-center gap-2.5">
|
<div class="flex flex-wrap items-center gap-2.5">
|
||||||
<a href="{{ $this->getBackUrl() }}" class="inline-flex items-center gap-1 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-600 transition hover:bg-slate-100 hover:text-slate-900">
|
<a href="{{ $this->getBackUrl() }}" class="inline-flex items-center gap-1 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-600 transition hover:bg-slate-100 hover:text-slate-900">
|
||||||
|
|
@ -97,6 +68,20 @@ class="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-me
|
||||||
<span class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-400 opacity-50">Succ. →</span>
|
<span class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-400 opacity-50">Succ. →</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- SELETTORE ESPLICITO RUOLO CONDOMINO / INQUILINO --}}
|
||||||
|
<div class="flex items-center gap-1 rounded-lg border border-slate-200 bg-slate-100 p-1">
|
||||||
|
<button type="button" wire:click="setCondInquilActive('C')"
|
||||||
|
class="inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-bold transition {{ ($condInquilActive ?? 'C') === 'C' ? 'bg-amber-600 text-white shadow-xs' : 'text-slate-600 hover:text-slate-900' }}">
|
||||||
|
<span>🏢</span>
|
||||||
|
<span>Condomino (Proprietari)</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" wire:click="setCondInquilActive('I')"
|
||||||
|
class="inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-bold transition {{ ($condInquilActive ?? 'C') === 'I' ? 'bg-indigo-600 text-white shadow-xs' : 'text-slate-600 hover:text-slate-900' }}">
|
||||||
|
<span>👤</span>
|
||||||
|
<span>Inquilino</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
|
|
||||||
52
tests/Feature/UnitaCondominoInquilinoRoleToggleTest.php
Normal file
52
tests/Feature/UnitaCondominoInquilinoRoleToggleTest.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Pages\UnitaImmobiliarePage;
|
||||||
|
use App\Models\Stabile;
|
||||||
|
use App\Models\UnitaImmobiliare;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
|
test('unita immobiliare page allows toggling between condomino and inquilino role', function () {
|
||||||
|
DB::table('amministratori')->insertOrIgnore([
|
||||||
|
'id' => 1,
|
||||||
|
'nome' => 'Admin',
|
||||||
|
'cognome' => 'Test',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::factory()->create();
|
||||||
|
if (method_exists($user, 'assignRole')) {
|
||||||
|
\Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin', 'guard_name' => 'web']);
|
||||||
|
$user->assignRole('admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
$stabile = Stabile::create([
|
||||||
|
'amministratore_id' => 1,
|
||||||
|
'codice_stabile' => '0013',
|
||||||
|
'denominazione' => 'Stabile Test 0013',
|
||||||
|
'indirizzo' => 'Via Ottaviano 105',
|
||||||
|
'citta' => 'Roma',
|
||||||
|
'cap' => '00192',
|
||||||
|
'provincia' => 'RM',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$unita = UnitaImmobiliare::create([
|
||||||
|
'stabile_id' => $stabile->id,
|
||||||
|
'scala' => 'A',
|
||||||
|
'interno' => '1',
|
||||||
|
'codice_unita' => '0013-A-1',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Livewire::actingAs($user)
|
||||||
|
->test(UnitaImmobiliarePage::class, ['unita_id' => $unita->id])
|
||||||
|
->assertSet('condInquilActive', 'C')
|
||||||
|
->assertSet('estrattoTipo', 'condomini')
|
||||||
|
->call('setCondInquilActive', 'I')
|
||||||
|
->assertSet('condInquilActive', 'I')
|
||||||
|
->assertSet('estrattoTipo', 'inquilini')
|
||||||
|
->call('setCondInquilActive', 'C')
|
||||||
|
->assertSet('condInquilActive', 'C')
|
||||||
|
->assertSet('estrattoTipo', 'condomini');
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user