Modalise training item qualification edit

Also fixed some stuff
This commit is contained in:
2022-03-06 18:30:03 +00:00
parent 2869c9fcc3
commit 900002bf71
6 changed files with 52 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
<label for="supervisor" class="col-sm-2 col-form-label">Supervisor</label>
<select name="supervisor" id="supervisor_id" class="selectpicker col-sm-10" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials" required>
{% if supervisor %}
<option value="{{form.supervisor.value}}" selected="selected">{{ supervisor }}</option>
<option value="{{form.supervisor.value}}" selected>{{ supervisor }}</option>
{% endif %}
</select>

View File

@@ -5,6 +5,41 @@
{% load linkornone from filters %}
{% load button from filters %}
{% load colour_from_depth from tags %}
{% load static %}
{% block css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/selects.css' %}"/>
{% endblock %}
{% block preload_js %}
<script src="{% static 'js/selects.js' %}"></script>
{% endblock %}
{% block js %}
<script src="{% static 'js/tooltip.js' %}"></script>
<script>
$('document').ready(function(){
$('#edit').click(function (e) {
e.preventDefault();
var url = $(this).attr("href");
$.ajax({
url: url,
success: function(){
$link = $(this);
// Anti modal inception
if ($link.parents('#modal').length === 0) {
modaltarget = $link.data('target');
modalobject = "";
$('#modal').load(url, function (e) {
$('#modal').modal();
});
}
}
});
});
});
</script>
{% endblock %}
{% block content %}
<p class="text-muted text-right">Search by supervisor name, item name or item ID</p>{% include 'partials/list_search.html' %}
@@ -33,7 +68,7 @@
<td><a href="{{ object.supervisor.get_absolute_url}}">{{ object.supervisor }}</a></td>
<td>{{ object.notes }}</td>
{% if request.user.is_supervisor or perms.training.change_trainingitemqualification %}
<td>{% button 'edit' 'edit_qualification' object.pk %}</td>
<td>{% button 'edit' 'edit_qualification' object.pk id="edit" %}</td>
{% endif %}
</tr>
{% empty %}