From 06b6a8c41115e2709328f1f3865bcc783b1a5cee Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 19 Jan 2016 18:14:23 +0100 Subject: [PATCH] Add missing JS to restrict contact list --- stages/static/js/avail_form.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 stages/static/js/avail_form.js diff --git a/stages/static/js/avail_form.js b/stages/static/js/avail_form.js new file mode 100644 index 0000000..42e6f81 --- /dev/null +++ b/stages/static/js/avail_form.js @@ -0,0 +1,18 @@ +django.jQuery(document).ready(function() { + django.jQuery('#id_corporation, .field-corporation select').change(function(ev) { + // Fill contact select + // Either in availability admin, or in stages admin with availability inlines + if (this.id == 'id_corporation') var sel = django.jQuery('#id_contact'); + else var sel = django.jQuery(this).closest('fieldset').find('.field-contact select'); + sel.html(''); + var id_corp = django.jQuery("option:selected", this).val(); + django.jQuery.getJSON('/corporation/' + id_corp + '/contacts/', function(data) { + django.jQuery.each(data, function(key, contact) { + var item = contact.first_name + ' ' + contact.last_name; + if (contact.role.length) item += ' (' + contact.role + ')'; + sel.append(django.jQuery("