Commit dd4160ab authored by Daniel W Bond's avatar Daniel W Bond

use the autocomplete select library used by django for schedule selection

parent 43d26a96
Pipeline #2173 canceled with stage
{% extends "admin/base_site.html" %}
{% block extrahead %}
{{ block.super }}
<!-- neither jQuery proper nor Django's version is loaded by default on this page -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
{% endblock %}
{% block extrastyle %}
{{ block.super }}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
{% endblock %}
{% block title %}
Set main schedule for multiple facilities
{{ block.super }}
......@@ -17,12 +29,14 @@ Set main schedule for multiple facilities
{% block content %}
<form action="" method="post">
{% csrf_token %}
<label>Schedule</label>
<select name="schedule">
{% for schedule in schedules %}
<option value={{ schedule.pk }} >{{ schedule }}</option>
{% endfor %}
</select>
<label for="id_label_single">
Schedule
<select name="schedule" class="select2-basic-single" id="id_label_single">
{% for schedule in schedules %}
<option value={{ schedule.pk }} >{{ schedule }}</option>
{% endfor %}
</select>
</label>
<p>Set this as the main schedule for all of these facilities?</p>
<ul>
......@@ -34,4 +48,23 @@ Set main schedule for multiple facilities
<input type="hidden" name="action" value="assign_bulk_schedules" />
<input type="submit" name="bulk_schedule" value="Yes, I'm sure" />
</form>
<script>
/**
Django's admin inferface uses this library for its new autocompletion selects
Unfortunately, use of that specific widget and the associated support attributes
are limited to admin.ModelAdmin change views
See
https://docs.djangoproject.com/en/2.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields
https://docs.djangoproject.com/en/2.0/ref/contrib/admin/#reversing-admin-urls
for more information
**/
$(document).ready(function() {
$('.select2-basic-single').select2({
});
});
</script>
{% endblock %}
{% extends "admin/base_site.html" %}
{% block extrahead %}
{{ block.super }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
{% endblock %}
{% block extrastyle %}
{{ block.super }}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
{% endblock %}
{% block title %}
Add special schedule to multiple facilities
{{ block.super }}
......@@ -17,12 +28,14 @@ Add special schedule to multiple facilities
{% block content %}
<form action="" method="post">
{% csrf_token %}
<label>Special Schedule</label>
<select name="special_schedule">
{% for schedule in schedules %}
<option value={{ schedule.pk }} >{{ schedule }}</option>
{% endfor %}
</select>
<label for="id_label_single">
Special Schedule
<select name="special_schedule" class="select2-basic-single" id="id_label_single">
{% for schedule in schedules %}
<option value={{ schedule.pk }} >{{ schedule }}</option>
{% endfor %}
</select>
</label>
<p>Add this special schedule to all of these facilities?</p>
<ul>
......@@ -34,4 +47,11 @@ Add special schedule to multiple facilities
<input type="hidden" name="action" value="assign_bulk_special_schedules" />
<input type="submit" name="bulk_special_schedule" value="Yes, I'm sure" />
</form>
<script>
$(document).ready(function() {
$('.select2-basic-single').select2({
});
});
</script>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment