mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Add current location to a visit popup as a fallback
This commit is contained in:
parent
6f842e8143
commit
6e773b6b51
1 changed files with 12 additions and 2 deletions
|
|
@ -1358,11 +1358,15 @@ export class VisitsManager {
|
||||||
<span class="label-text text-sm font-medium">Location</span>
|
<span class="label-text text-sm font-medium">Location</span>
|
||||||
</label>
|
</label>
|
||||||
<select class="select select-bordered select-sm w-full bg-base-200 text-base-content" name="place">
|
<select class="select select-bordered select-sm w-full bg-base-200 text-base-content" name="place">
|
||||||
${possiblePlaces.map(place => `
|
${possiblePlaces.length > 0 ? possiblePlaces.map(place => `
|
||||||
<option value="${place.id}" ${place.id === visit.place.id ? 'selected' : ''}>
|
<option value="${place.id}" ${place.id === visit.place.id ? 'selected' : ''}>
|
||||||
${place.name}
|
${place.name}
|
||||||
</option>
|
</option>
|
||||||
`).join('')}
|
`).join('') : `
|
||||||
|
<option value="${visit.place.id}" selected>
|
||||||
|
${visit.place.name || 'Current Location'}
|
||||||
|
</option>
|
||||||
|
`}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 mt-4 pt-2 border-t border-base-300">
|
<div class="flex gap-2 mt-4 pt-2 border-t border-base-300">
|
||||||
|
|
@ -1431,6 +1435,12 @@ export class VisitsManager {
|
||||||
const newName = event.target.querySelector('input').value;
|
const newName = event.target.querySelector('input').value;
|
||||||
const selectedPlaceId = event.target.querySelector('select[name="place"]').value;
|
const selectedPlaceId = event.target.querySelector('select[name="place"]').value;
|
||||||
|
|
||||||
|
// Validate that we have a valid place_id
|
||||||
|
if (!selectedPlaceId || selectedPlaceId === '') {
|
||||||
|
showFlashMessage('error', 'Please select a valid location');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the selected place name from the dropdown
|
// Get the selected place name from the dropdown
|
||||||
const selectedOption = event.target.querySelector(`select[name="place"] option[value="${selectedPlaceId}"]`);
|
const selectedOption = event.target.querySelector(`select[name="place"] option[value="${selectedPlaceId}"]`);
|
||||||
const selectedPlaceName = selectedOption ? selectedOption.textContent.trim() : '';
|
const selectedPlaceName = selectedOption ? selectedOption.textContent.trim() : '';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue