fix(map): selectFeature event handling - unify payload format for map click and feature table
- FeatureTable: dispatch { featureId } object instead of raw ID
- ProjectMap: selectFeature listener accepts both formats (direct ID or { featureId })
- project-map.blade.php: move selectFeature inside livewire:init handler so Livewire.emit is available
- Added logging for debugging
Fixes: 'Livewire.emit is not a function' on map click and 'Only arrays and Traversables can be unpacked' on table button
This commit is contained in:
@@ -69,15 +69,17 @@ class FeatureTable extends DataTableComponent
|
||||
->html(),
|
||||
|
||||
Column::make('Acciones')
|
||||
->label(fn ($row) =>
|
||||
'<div class="flex justify-end">'
|
||||
. '<button wire:click="$dispatch(\'map-select-feature\', ' . $row->id . ')"'
|
||||
. 'class="btn btn-xs btn-primary gap-1" title="Editar elemento">'
|
||||
. '<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>'
|
||||
. 'Abrir'
|
||||
. '</button>'
|
||||
. '</div>')
|
||||
->html(),
|
||||
->label(function ($row) {
|
||||
$id = $row->id;
|
||||
return '<div class="flex justify-end">'
|
||||
. '<button wire:click="$dispatch(\'map-select-feature\', { featureId: ' . $id . ' })"'
|
||||
. 'class="btn btn-xs btn-primary gap-1" title="' . e(__('Editar elemento')) . '">'
|
||||
. '<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>'
|
||||
. e(__('Abrir'))
|
||||
. '</button>'
|
||||
. '</div>';
|
||||
})
|
||||
->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))),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user