feat: implementar modal gestión capas y limpieza de stubs duplicados

This commit is contained in:
2026-05-08 09:01:00 +02:00
parent 199fb487c2
commit 7461bd9124
11 changed files with 121 additions and 705 deletions
+12 -7
View File
@@ -58,6 +58,9 @@ class LayerManager extends Component
private function emitInitialLayersData()
{
$layersData = $this->layers->map(function($layer) {
// Usar el color guardado en BD o el color del formulario
$color = $layer->color ?: ($this->layerColor ?: '#3b82f6');
// Construir FeatureCollection a partir de los features de esta capa
$features = $layer->features->map(function($feature) {
return [
@@ -76,13 +79,13 @@ class LayerManager extends Component
$geojson = [
'type' => 'FeatureCollection',
'features' => $features,
'style' => ['color' => $this->layerColor ?: '#3b82f6'] // Podrías guardar el color en la tabla layers
'style' => ['color' => $color]
];
return [
'id' => $layer->id,
'geojson' => $geojson,
'color' => $geojson['style']['color'],
'color' => $color,
];
});
@@ -132,16 +135,17 @@ class LayerManager extends Component
];
})->values()->toArray();
$color = $this->selectedLayer->color ?: ($this->layerColor ?: '#3b82f6');
$geojson = [
'type' => 'FeatureCollection',
'features' => $features,
'style' => ['color' => $this->layerColor ?: '#3b82f6']
'style' => ['color' => $color]
];
$this->dispatch('layerSelectedForEdit', [
'layerId' => $layerId,
'geojson' => $geojson,
'color' => $geojson['style']['color'],
'color' => $color,
]);
session()->flash('info', 'Editando capa: ' . $this->selectedLayer->name);
}
@@ -192,13 +196,14 @@ class LayerManager extends Component
return;
}
$geojson['style'] = ['color' => $this->layerColor ?: '#3b82f6'];
$layerColor = $this->layerColor ?: '#3b82f6';
$geojson['style'] = ['color' => $layerColor];
$layer = Layer::create([
'project_id' => $this->project->id,
'phase_id' => $this->phase->id,
'name' => $this->layerName,
//'geojson_data' => $geojson,
'color' => $layerColor,
'original_file' => $originalPath,
'uploaded_by' => $user->id,
]);
@@ -232,9 +237,9 @@ class LayerManager extends Component
'project_id' => $this->project->id,
'phase_id' => $this->phase->id,
'name' => $this->layerName ?: 'Nueva capa',
'color' => $this->layerColor ?: '#3b82f6',
'original_file' => null,
'uploaded_by' => $user->id,
// Opcional: guarda el color en una columna 'color' de la tabla layers
]);
$this->loadLayers();
$this->visibleLayers[] = $layer->id;