updates to document handling and code editing features
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
class="text-green-500"/>
|
||||
</svg>
|
||||
<h1 class="text-3xl font-bold text-gray-800">
|
||||
{{ (isset($project) && $project->id) ? 'Editar Proyecto' : 'Nuevo Proyecto' }}
|
||||
{{ (isset($project) && $project->id) ? 'Editar Proyecto' : 'Nuevo Proyecto'}}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
Complete todos los campos obligatorios para registrar un nuevo usuario en el sistema.
|
||||
@endisset
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
@if(session('error'))
|
||||
@@ -87,18 +86,19 @@
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<!-- Referencia -->
|
||||
<tr>
|
||||
<td class="w-1/4 py-3 pr-4 align-top">
|
||||
<x-label for="reference" :value="__('Referencia')" />
|
||||
</td>
|
||||
<td class="py-3">
|
||||
<input type="text" name="reference" id="reference"
|
||||
<input type="text" name="reference" id="reference"
|
||||
value="{{ old('reference', $project->reference ?? '') }}"
|
||||
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none"
|
||||
maxlength="12"
|
||||
autofocus
|
||||
maxlength="12"
|
||||
autofocus
|
||||
wire:model.live="projectCode"
|
||||
required>
|
||||
<flux:tooltip content="Máximo: 12 caracteres" position="right">
|
||||
<flux:button icon="information-circle" size="sm" variant="ghost" />
|
||||
@@ -189,6 +189,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@livewire('project-name-coder')
|
||||
</div>
|
||||
|
||||
<div class="relative">
|
||||
@@ -203,6 +204,43 @@
|
||||
<div class="bg-white py-6">
|
||||
<table class="w-full mb-8">
|
||||
<tbody>
|
||||
|
||||
<!-- Mapa para Coordenadas -->
|
||||
<tr>
|
||||
<td class="w-1/4 py-3 pr-4 align-top">
|
||||
<x-label :value="__('Seleccione Ubicación')" />
|
||||
</td>
|
||||
<td class="py-3">
|
||||
<div id="map" class="h-100 border-2 border-gray-200"></div>
|
||||
<div class="grid grid-cols-2 gap-4 mt-2">
|
||||
<div>
|
||||
<x-label for="latitude" :value="__('Latitud')" />
|
||||
<input type="number"
|
||||
id="latitude"
|
||||
name="latitude"
|
||||
value="{{ old('latitude') }}"
|
||||
step="any"
|
||||
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||
</div>
|
||||
<div>
|
||||
<x-label for="longitude" :value="__('Longitud')" />
|
||||
<input type="number"
|
||||
id="longitude"
|
||||
name="longitude"
|
||||
value="{{ old('longitude') }}"
|
||||
step="any"
|
||||
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||
</div>
|
||||
</div>
|
||||
@error('latitude')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
@error('longitude')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Dirección -->
|
||||
<tr>
|
||||
<td class="w-1/4 py-3 pr-4 align-top">
|
||||
@@ -249,6 +287,7 @@
|
||||
|
||||
<div>
|
||||
<livewire:country-select :initialCountry="old('country')" />
|
||||
|
||||
@error('country')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
@@ -256,42 +295,6 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Mapa para Coordenadas -->
|
||||
<tr>
|
||||
<td class="w-1/4 py-3 pr-4 align-top">
|
||||
<x-label :value="__('Seleccione Ubicación')" />
|
||||
</td>
|
||||
<td class="py-3">
|
||||
<div id="map" class="h-80 border-2 border-gray-200"></div>
|
||||
<div class="grid grid-cols-2 gap-4 mt-2">
|
||||
<div>
|
||||
<x-label for="latitude" :value="__('Latitud')" />
|
||||
<input type="number"
|
||||
id="latitude"
|
||||
name="latitude"
|
||||
value="{{ old('latitude') }}"
|
||||
step="any"
|
||||
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||
</div>
|
||||
<div>
|
||||
<x-label for="longitude" :value="__('Longitud')" />
|
||||
<input type="number"
|
||||
id="longitude"
|
||||
name="longitude"
|
||||
value="{{ old('longitude') }}"
|
||||
step="any"
|
||||
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||
</div>
|
||||
</div>
|
||||
@error('latitude')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
@error('longitude')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -476,6 +479,8 @@
|
||||
map.on('click', function(e) {
|
||||
updateInputs(e.latlng.lat, e.latlng.lng);
|
||||
updateMarker(e.latlng);
|
||||
// Realizar reverse geocoding
|
||||
reverseGeocode(e.latlng.lat, e.latlng.lng);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -506,6 +511,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Función para reverse geocoding
|
||||
function reverseGeocode(lat, lng) {
|
||||
// Usar Nominatim API de OpenStreetMap para reverse geocoding
|
||||
fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data && data.address) {
|
||||
// Actualizar dirección completa
|
||||
const address = data.display_name || '';
|
||||
document.getElementById('address').value = address;
|
||||
|
||||
// Actualizar código postal
|
||||
const postalCode = data.address.postcode || '';
|
||||
document.getElementById('postal_code').value = postalCode;
|
||||
|
||||
// Actualizar provincia
|
||||
const province = data.address.state || data.address.region || data.address.county || '';
|
||||
document.getElementById('province').value = province;
|
||||
|
||||
// Actualizar país
|
||||
const country = data.address.country || '';
|
||||
const countryInput = document.querySelector('input[name="country"]');
|
||||
if (countryInput) {
|
||||
countryInput.value = country;
|
||||
// Disparar evento change para que Livewire lo detecte
|
||||
countryInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
|
||||
// También puedes actualizar otros campos si están disponibles
|
||||
console.log('Datos de geocoding:', data.address);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error en reverse geocoding:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// Inicializar el mapa
|
||||
window.onload = function() {
|
||||
initMap();
|
||||
|
||||
Reference in New Issue
Block a user