From a9e2b04477c968db7d4e255a2755523fd9bf9527 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 10 Apr 2019 14:12:18 +0200 Subject: Popup: BS style - Container: improve creation form - prevent container creation when the same reference exists - autocopy reference to location --- ishtar_common/static/forms/container.js | 13 +++++++++ ishtar_common/static/js/ishtar.js | 2 +- ishtar_common/templates/window.html | 51 ++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 ishtar_common/static/forms/container.js (limited to 'ishtar_common') diff --git a/ishtar_common/static/forms/container.js b/ishtar_common/static/forms/container.js new file mode 100644 index 000000000..517b3b86d --- /dev/null +++ b/ishtar_common/static/forms/container.js @@ -0,0 +1,13 @@ +$(document).ready(function(){ + var location_changed = false; + + $("#id_select_responsible").on("autocompleteselect", function(event, ui) { + if (location_changed) return; + $("#id_select_location").val(ui.item.label); + $("#id_location").val(ui.item.id); + }); + + $("#id_select_location").on("autocompleteselect", function(event, ui){ + location_changed = true; + }); +}); diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 0aac181ab..910ee92d0 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -672,7 +672,7 @@ function load_url(url, callback){ function open_window(url){ var newwindow = window.open( - url, '_blank', 'height=400,width=600,scrollbars=yes'); + url, '_blank', 'height=500,width=600,scrollbars=yes'); if (window.focus) {newwindow.focus()} return false; } diff --git a/ishtar_common/templates/window.html b/ishtar_common/templates/window.html index dcb4d4084..dc94b4aae 100644 --- a/ishtar_common/templates/window.html +++ b/ishtar_common/templates/window.html @@ -12,36 +12,47 @@ + {{form.media}} - + - + {% block extra_head %} {% endblock %} - -{% if new_item_label %} + + {% endif %} -
-

{{title}}

-
{% csrf_token %} - - {% for field in form %} - - - - {% endfor %} - -
{{ field.label_tag }}{{ field.errors }}{{field|safe}}
-
-
+$("#cancel-btn").click(function(){ + close(); +}); + - - -- cgit v1.2.3