2023-11-01 18:46:27 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block title %}
|
|
|
|
Edit SAR record
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
|
2023-10-30 14:48:00 +00:00
|
|
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
|
2023-11-01 18:46:27 +00:00
|
|
|
|
|
|
|
<h2>Edit SAR Call</h2>
|
|
|
|
<div class="container mt-5">
|
|
|
|
<h2>Edit SAR Call</h2>
|
|
|
|
<form action="{{ url_for('edit_sar', id=sar_call.id) }}" method="post" enctype="multipart/form-data">
|
|
|
|
<div class="form-group">
|
2023-11-12 20:06:15 +00:00
|
|
|
<div>
|
|
|
|
<label for="status">Status:</label>
|
|
|
|
<select name="status" id="status" class="form-control">
|
|
|
|
{% for status in statuses %}
|
|
|
|
<option value="{{ status.id }}" {% if status.id == sar_call.status %}selected{% endif %}>
|
|
|
|
{{ status.name }}
|
|
|
|
</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
2023-11-01 18:46:27 +00:00
|
|
|
<label for="start_date">Start Date:</label>
|
|
|
|
<input type="date" name="start_date" class="form-control" value="{{ sar_call.start_date }}" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="finish_date">Finish Date:</label>
|
2023-11-12 20:06:15 +00:00
|
|
|
<div>
|
2023-11-14 10:07:43 +00:00
|
|
|
<button type="button" id="today_button" class="btn btn-secondary">Today</button>
|
2023-11-12 20:06:15 +00:00
|
|
|
</div>
|
2023-11-14 10:07:43 +00:00
|
|
|
<input type="date" name="finish_date" id="finish_date" class="form-control"
|
|
|
|
value="{{ sar_call.finish_date }}">
|
2023-11-01 18:46:27 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="category">Category:</label>
|
2023-11-12 20:06:15 +00:00
|
|
|
<select name="category" id="category" class="form-control">
|
|
|
|
{% for category in categories %}
|
|
|
|
<option value="{{ category.id }}" {% if category.id == sar_call.category %}selected{% endif %}>
|
|
|
|
{{ category.name }}
|
|
|
|
</option>
|
2023-11-01 18:46:27 +00:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="coordinates">Geographical Coordinates:</label>
|
2023-11-12 20:06:15 +00:00
|
|
|
<input type="text" name="longitude" class="form-control" value="{{ sar_call.longitude }}" required>
|
|
|
|
<input type="text" name="latitude" class="form-control" value="{{ sar_call.latitude }}" required>
|
2023-11-01 18:46:27 +00:00
|
|
|
</div>
|
|
|
|
|
2023-11-14 10:07:43 +00:00
|
|
|
<div class="form-group">
|
2023-11-12 20:06:15 +00:00
|
|
|
<label for="title">Title:</label>
|
|
|
|
<input type="text" name="title" class="form-control" value="{{ sar_call.title }}" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2023-11-01 18:46:27 +00:00
|
|
|
<div class="form-group">
|
|
|
|
<label for="description">Description:</label>
|
|
|
|
<textarea name="description" class="form-control">{{ sar_call.description }}</textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2023-11-12 20:06:15 +00:00
|
|
|
<label for="description_hidden">Hidden Description:</label>
|
|
|
|
<textarea name="description_hidden" class="form-control">{{ sar_call.description_hidden }}</textarea>
|
2023-11-01 18:46:27 +00:00
|
|
|
</div>
|
|
|
|
|
2023-11-14 10:07:43 +00:00
|
|
|
{# <!-- GPX Track Fields (You can expand upon this based on the previous discussion about multiple tracks) -->#}
|
|
|
|
{# <div class="form-group">#}
|
|
|
|
{# <label for="gpx_file">Upload GPX Track:</label>#}
|
|
|
|
{# <input type="file" name="gpx_file">#}
|
|
|
|
{# </div>#}
|
2023-11-01 18:46:27 +00:00
|
|
|
|
|
|
|
<button type="submit" class="btn btn-primary">Update</button>
|
|
|
|
</form>
|
|
|
|
<div id="map" style="width: 600px; height: 400px;"></div>
|
|
|
|
<script>
|
2023-11-18 19:34:23 +00:00
|
|
|
var map = L.map('map').setView([60.19,20.37], 13); // Default to London, adjust as needed
|
2023-11-01 18:46:27 +00:00
|
|
|
|
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
var marker;
|
|
|
|
|
|
|
|
map.on('click', function (e) {
|
|
|
|
if (marker) {
|
|
|
|
map.removeLayer(marker);
|
|
|
|
}
|
|
|
|
marker = L.marker(e.latlng).addTo(map);
|
|
|
|
document.querySelector('input[name="latitude"]').value = e.latlng.lat;
|
|
|
|
document.querySelector('input[name="longitude"]').value = e.latlng.lng;
|
|
|
|
});
|
|
|
|
|
|
|
|
// If editing, set the marker to the existing coordinates
|
|
|
|
var latInput = document.querySelector('input[name="latitude"]');
|
|
|
|
var lngInput = document.querySelector('input[name="longitude"]');
|
|
|
|
if (latInput.value && lngInput.value) {
|
|
|
|
marker = L.marker([latInput.value, lngInput.value]).addTo(map);
|
|
|
|
}
|
|
|
|
</script>
|
2023-11-14 10:07:43 +00:00
|
|
|
<script>
|
|
|
|
document.getElementById('today_button').addEventListener('click', function () {
|
|
|
|
var today = new Date();
|
|
|
|
var dd = String(today.getDate()).padStart(2, '0');
|
|
|
|
var mm = String(today.getMonth() + 1).padStart(2, '0'); // January is 0!
|
|
|
|
var yyyy = today.getFullYear();
|
|
|
|
today = yyyy + '-' + mm + '-' + dd;
|
|
|
|
document.getElementById('finish_date').value = today;
|
|
|
|
});
|
|
|
|
</script>
|
2023-11-12 20:06:15 +00:00
|
|
|
|
2023-11-01 18:46:27 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<{% endblock %}
|