++ gruppo: i pulsanti per aggiungere territori e membri non restano disabilitati

Il conteggio delle spunte arrivava al server solo al clic: il pulsante
restava disabilitato. Ora e' sempre attivo e senza spunte avvisa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Francesco Picone
2026-10-19 17:56:54 +02:00
parent f48d0e96c0
commit 6489fb627d
2 changed files with 11 additions and 3 deletions

View File

@@ -64,6 +64,11 @@ class GruppoShow extends Component
public function aggiungiMembri(): void public function aggiungiMembri(): void
{ {
$ids = array_map('intval', $this->nuoviMembri); $ids = array_map('intval', $this->nuoviMembri);
if ($ids === []) {
$this->avvisaErrore('Spunta almeno un proclamatore.');
return;
}
$this->esegui(fn () => $this->servizio()->aggiungiMembri($this->gruppo, $ids), count($ids) . ' membri aggiunti.'); $this->esegui(fn () => $this->servizio()->aggiungiMembri($this->gruppo, $ids), count($ids) . ' membri aggiunti.');
$this->nuoviMembri = []; $this->nuoviMembri = [];
} }
@@ -77,6 +82,11 @@ class GruppoShow extends Component
public function aggiungiTerritori(): void public function aggiungiTerritori(): void
{ {
$ids = array_map('intval', $this->nuoviTerritori); $ids = array_map('intval', $this->nuoviTerritori);
if ($ids === []) {
$this->avvisaErrore('Spunta almeno un territorio.');
return;
}
$this->esegui(fn () => $this->servizio()->aggiungiAlPacchetto($this->gruppo, $ids), count($ids) . ' territori aggiunti al pacchetto.'); $this->esegui(fn () => $this->servizio()->aggiungiAlPacchetto($this->gruppo, $ids), count($ids) . ' territori aggiunti al pacchetto.');
$this->nuoviTerritori = []; $this->nuoviTerritori = [];
} }

View File

@@ -75,9 +75,7 @@
@endforeach @endforeach
</div> </div>
<div class="mt-3"> <div class="mt-3">
<x-btn variante="primary" wire:click="aggiungiTerritori" :disabled="count($nuoviTerritori) === 0"> <x-btn variante="primary" wire:click="aggiungiTerritori">Aggiungi i territori selezionati</x-btn>
Aggiungi {{ count($nuoviTerritori) ?: '' }} al pacchetto
</x-btn>
</div> </div>
@endif @endif
</div> </div>