diff --git a/app/Livewire/Projects/FeatureTable.php b/app/Livewire/Projects/FeatureTable.php
index dee1d76..d0336a6 100644
--- a/app/Livewire/Projects/FeatureTable.php
+++ b/app/Livewire/Projects/FeatureTable.php
@@ -69,15 +69,17 @@ class FeatureTable extends DataTableComponent
->html(),
Column::make('Acciones')
- ->label(fn ($row) =>
- '
'
- . '
'
- . '
')
- ->html(),
+ ->label(function ($row) {
+ $id = $row->id;
+ return ''
+ . '
'
+ . '
';
+ })
+ ->html(),
];
}
@@ -102,4 +104,4 @@ class FeatureTable extends DataTableComponent
->filter(fn (Builder $query, string $value) => $query->whereHas('layer', fn ($l) => $l->where('phase_id', $value))),
];
}
-}
+}
\ No newline at end of file
diff --git a/app/Livewire/Projects/ProjectMap.php b/app/Livewire/Projects/ProjectMap.php
index d06cad6..8f17082 100644
--- a/app/Livewire/Projects/ProjectMap.php
+++ b/app/Livewire/Projects/ProjectMap.php
@@ -228,6 +228,13 @@ class ProjectMap extends Component
#[On('map-select-feature')]
public function selectFeature($featureId)
{
+ \Log::info('map-select-feature received', ['payload' => $featureId]);
+
+ // Handle both formats: direct ID or { featureId: X }
+ if (is_array($featureId) && isset($featureId['featureId'])) {
+ $featureId = $featureId['featureId'];
+ }
+
$this->selectedFeature = null;
$feature = Feature::with(['template', 'layer.phase'])->find($featureId);
if (!$feature) return;
diff --git a/resources/views/livewire/projects/project-map.blade.php b/resources/views/livewire/projects/project-map.blade.php
index 5bd25cc..90d8b9f 100644
--- a/resources/views/livewire/projects/project-map.blade.php
+++ b/resources/views/livewire/projects/project-map.blade.php
@@ -724,10 +724,6 @@
}
}
- function selectFeature(featureId) {
- Livewire.emit('map-select-feature', featureId);
- }
-
function getUserLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((pos) => {
@@ -743,6 +739,12 @@
document.addEventListener('livewire:init', function () {
setTimeout(initMap, 50);
+ // Define selectFeature here so Livewire is guaranteed to be available
+ window.selectFeature = function(featureId) {
+ console.log('selectFeature called with:', featureId);
+ Livewire.emit('map-select-feature', { featureId: featureId });
+ };
+
Livewire.on('layersUpdated', (activeIds) => {
const ids = Array.isArray(activeIds) ? activeIds[0] : activeIds;
for (let id in layers) {