Mapa: panel de fases con acceso a gestionar capas y progreso, editor funcional, saveFeatureProgress, onTemplateChange
This commit is contained in:
@@ -37,7 +37,9 @@ class ProjectMap extends Component
|
||||
{
|
||||
$this->project = $project;
|
||||
// Cargar fases con sus capas y los features de esas capas (para mostrarlos en el mapa)
|
||||
$this->phases = $project->phases()->with(['layers.features'])->get();
|
||||
$this->phases = $project->phases()->with(['layers' => function ($q) {
|
||||
$q->withCount('features');
|
||||
}, 'layers.features'])->get();
|
||||
// Por defecto mostrar todas las capas activas (todas las fases que tengan alguna capa con features)
|
||||
$this->activeLayers = $this->phases->pluck('id')->toArray();
|
||||
$this->loadTemplates();
|
||||
@@ -216,6 +218,34 @@ class ProjectMap extends Component
|
||||
$this->dispatch('notify', 'Template asignado al elemento');
|
||||
}
|
||||
|
||||
/**
|
||||
* Guardar progreso y responsable del feature seleccionado.
|
||||
*/
|
||||
public function saveFeatureProgress()
|
||||
{
|
||||
if (!$this->selectedFeature) return;
|
||||
|
||||
$this->selectedFeature->progress = min(100, max(0, (int)$this->editProgress));
|
||||
$this->selectedFeature->responsible = $this->editResponsible;
|
||||
$this->selectedFeature->save();
|
||||
|
||||
// Recalcular progreso de la fase
|
||||
$phase = Phase::find($this->selectedFeature->layer->phase_id);
|
||||
$phase->progress_percent = $phase->features()->avg('progress') ?: 0;
|
||||
$phase->save();
|
||||
|
||||
$this->dispatch('progressUpdated', $phase->id, $phase->progress_percent);
|
||||
$this->dispatch('notify', 'Progreso guardado');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cuando cambia el template seleccionado, reiniciar el formulario.
|
||||
*/
|
||||
public function onTemplateChange()
|
||||
{
|
||||
$this->resetInspectionForm();
|
||||
}
|
||||
|
||||
public function toggleFullscreen()
|
||||
{
|
||||
$this->formFullscreen = !$this->formFullscreen;
|
||||
|
||||
Reference in New Issue
Block a user