mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-29 18:59:57 +00:00
edit function uses popup instead of redirect
This commit is contained in:
@@ -61,7 +61,10 @@
|
||||
<td><small class="fs-6">{{ plate.id }}</small></td>
|
||||
<td><small class="fs-6">{{ plate.plate }}</small></td>
|
||||
<td>
|
||||
<a href="{{ url_for('dash.edit', plate=plate.plate) }}" class="btn btn-sm btn-secondary">Edit</a>
|
||||
<a href="#" class="btn btn-sm btn-secondary"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#editNumberplateModal"
|
||||
onclick="setEditPlate('{{ plate.id }}', '{{ plate.plate }}')">Edit</a>
|
||||
<form method="POST" action="{{ url_for('dash.delete_plate', plate=plate.plate) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this numberplate?');">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Delete</button>
|
||||
</form>
|
||||
@@ -75,6 +78,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="editNumberplateModal" tabindex="-1" aria-labelledby="editNumberplateModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form id="editNumberplateForm" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editNumberplateModalLabel">Edit Numberplate</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="mb-3">
|
||||
{{ form.numberplate.label }} {{ form.numberplate(class="form-control") }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-secondary">Save changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function setEditPlate(id, plate) {
|
||||
// Set the form action to the correct URL for editing
|
||||
document.getElementById('editNumberplateForm').action = '/dash/edit/' + plate;
|
||||
// Set the value of the numberplate input
|
||||
document.querySelector('#editNumberplateForm input[name="numberplate"]').value = plate;
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
@@ -20,7 +20,7 @@
|
||||
{{ form.numberplate.label }} {{ form.numberplate(class="form-input") }}
|
||||
</div>
|
||||
<div class="button-container">
|
||||
{{ form.submit(class="submit-btn") }}
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,8 @@ def dashboard():
|
||||
.limit(50)
|
||||
.all()
|
||||
)
|
||||
return render_template("dashboard.html", plates=Plates, logs=logs)
|
||||
form = npForm()
|
||||
return render_template("dashboard.html", plates=Plates, logs=logs, form=form)
|
||||
|
||||
|
||||
@dash_blueprint.route("/add", methods=["GET", "POST"])
|
||||
|
||||
Reference in New Issue
Block a user