1
0
Fork 0

Add enhanced confirmation for station deletion

environments/stage/deployments/234
Pierros Papadeas 2018-12-04 11:31:24 +02:00
parent f9af2c0231
commit 46d5533066
No known key found for this signature in database
GPG Key ID: 8DB97129D9982991
3 changed files with 30 additions and 5 deletions

View File

@ -14,11 +14,12 @@ $(document).ready(function() {
var station_info = $('#station-info').data();
// Confirm station deletion
var message = 'Do you really want to delete this Ground Station?';
var actions = $('#station-delete');
if (actions.length) {
actions[0].addEventListener('click', function(e) {
if (! confirm(message)) {
if ($('#delete-confirm-id').val() != station_info.id ) {
$('#delete-confirm-id').val('');
$('#delete-confirm-id').attr('placeholder', 'Wrong ID!');
e.preventDefault();
}
});

View File

@ -92,7 +92,7 @@
<input type="checkbox" name="testing" {% if form.testing.value %}checked="True"{% endif %} {% if not station.id %}disabled{% endif %}>
Testing?
<span class="glyphicon glyphicon-question-sign" aria-hidden="true" data-toggle="tooltip"
title="Make sure you Station is performing well for a period of time before you lift the Testing flag"></span>
title="Make sure you station is performing well for a period of time before you remove the Testing flag"></span>
</label>
</div>
</div>

View File

@ -30,9 +30,8 @@
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit
</a>
<a class="btn btn-danger" id="station-delete" href="{% url 'base:station_delete' id=station.id %}">
<a class="btn btn-danger delete-modal-reveal" data-toggle="modal" data-target="#delete-modal">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
Delete
</a>
{% endif %}
</h2>
@ -278,6 +277,7 @@
</div>
</div>
<!-- Map Modal -->
<div id="modal-lightbox" class="modal-lightbox">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
@ -286,6 +286,30 @@
<img src="{{ station.get_image }}" class="station-full-image" alt="{{ station.name }}">
</div>
<!-- Delete Modal -->
<div class="modal" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="delete-modal">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Do you really want to delete the ground station?</h4>
</div>
<div class="modal-body">
<p>WARNING: You are about to delete your ground station.</p>
<p>Please enter the ID of your station below to confirm the action.</p>
<input value="" id="delete-confirm-id" type="text" class="form-control" name="delete-confirm-id" placeholder="Enter your station ID to proceed with deletion">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a class="btn btn-danger" id="station-delete" href="{% url 'base:station_delete' id=station.id %}">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
Delete
</a>
</div>
</div>
</div>
</div>
{% include 'includes/satellite.html' %}
{% include 'includes/legend.html' %}
{% endblock content %}