++ fix: aggiornamento dipendenze e correzione bug

This commit is contained in:
2026-04-12 18:07:59 +00:00
parent 9f9a3666c1
commit 5e98423e7a
13 changed files with 311 additions and 25 deletions

View File

@@ -21,8 +21,8 @@ class Registro extends Component
public string $filtroZona = '';
public string $filtroTipologia = '';
public string $filtroStato = ''; // aperte, chiuse
public string $sortField = 'assigned_at';
public string $sortDirection = 'desc';
public string $sortField = 'territorio_numero';
public string $sortDirection = 'asc';
// ─── Modal create/edit ──────────────────────────────────────
public bool $showModal = false;
@@ -149,6 +149,14 @@ class Registro extends Component
$this->showDeleteConfirm = false;
}
public function mount(): void
{
if ($this->filtroAnno === '') {
$annoCorrente = AnnoTeocratico::corrente();
$this->filtroAnno = (string) $annoCorrente->id;
}
}
public function render()
{
$query = Assegnazione::with(['territorio.zona', 'territorio.assegnazioneCorrente', 'proclamatore', 'annoTeocratico', 'campagna']);
@@ -171,7 +179,14 @@ class Registro extends Component
$query->whereHas('territorio', fn($q) => $q->where('tipologia_id', $this->filtroTipologia));
}
$query->orderBy($this->sortField, $this->sortDirection);
if ($this->sortField === 'territorio_numero') {
$dir = $this->sortDirection === 'asc' ? 'ASC' : 'DESC';
$query->orderByRaw(
"CAST((SELECT numero FROM territori WHERE territori.id = assegnazioni.territorio_id) AS UNSIGNED) $dir"
);
} else {
$query->orderBy($this->sortField, $this->sortDirection);
}
// In-memory search for encrypted proclamatore fields / territorio numero
if ($this->search !== '') {