From 52883f6f5d58dbe4adc9f47e0fdc969c62efb392 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 30 Jan 2018 17:14:07 +0100 Subject: UI: adapt shortcut menu --- ishtar_common/static/js/ishtar.js | 39 +++++---- ishtar_common/static/media/styles.css | 9 ++- ishtar_common/templates/base.html | 6 +- .../ishtar/blocks/advanced_shortcut_menu.html | 93 ++++++++++++---------- .../ishtar/blocks/base_shortcut_menu.html | 46 +++++++++++ .../templates/ishtar/blocks/shortcut_menu.html | 84 ++++++++++--------- ishtar_common/templates/navbar.html | 2 +- ishtar_common/views.py | 24 +++++- scss/custom.scss | 7 +- 9 files changed, 200 insertions(+), 110 deletions(-) create mode 100644 ishtar_common/templates/ishtar/blocks/base_shortcut_menu.html diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 0ac0a4e89..b1a9b61d5 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -62,7 +62,8 @@ var shortcut_menu_show_url = '/show-shortcut-menu/' function init_shortcut_menu(html){ close_wait(); $("#context-menu").html(html); - $(".chosen-select").chosen(); + $("#shortcut-menu .chosen-select").chosen(); + $("#shortcut-menu .chosen-container").css('width', '100%'); if (advanced_menu) { init_advanced_shortcut_fields(); } else { @@ -70,14 +71,16 @@ function init_shortcut_menu(html){ } $("#short-menu-advanced").click(function(){ $.get(url_path + activate_advanced_url, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#short-menu-simple").click(function(){ $.get(url_path + activate_simple_url, - load_shortcut_menu + load_opened_shortcut_menu ); }); + + /* $(".short-menu-close").click(function(){ $('#shortcut-menu div').hide(); $('#shortcut-menu table').hide(); @@ -98,43 +101,44 @@ function init_shortcut_menu(html){ $(".short-menu-close").hide(); $(".short-menu-open").show(); } + */ } function init_shortcut_fields(){ $("#current_file").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'file', value:$("#current_file").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#current_operation").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'operation', value:$("#current_operation").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#current_contextrecord").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'contextrecord', value:$("#current_contextrecord").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#current_find").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'find', value:$("#current_find").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#current_treatment").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'treatment', value:$("#current_treatment").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $("#current_treatmentfile").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'treatmentfile', value:$("#current_treatmentfile").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); } @@ -145,7 +149,7 @@ function init_advanced_shortcut_fields(){ 'title', $('#id_select_file-shortcut').val()); $.post('/' + url_path + 'update-current-item/', {item: "file", value:$("#id_file-shortcut").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $('#id_operation-shortcut').change(function(){ @@ -153,7 +157,7 @@ function init_advanced_shortcut_fields(){ 'title', $('#id_select_operation-shortcut').val()); $.post('/' + url_path + 'update-current-item/', {item: "operation", value:$("#id_operation-shortcut").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $('#id_contextrecord-shortcut').change(function(){ @@ -161,7 +165,7 @@ function init_advanced_shortcut_fields(){ 'title', $('#id_select_contextrecord-shortcut').val()); $.post('/' + url_path + 'update-current-item/', {item: "contextrecord", value:$("#id_contextrecord-shortcut").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); $('#id_find-shortcut').change(function(){ @@ -169,7 +173,7 @@ function init_advanced_shortcut_fields(){ 'title', $('#id_select_find-shortcut').val()); $.post('/' + url_path + 'update-current-item/', {item: "find", value:$("#id_find-shortcut").val()}, - load_shortcut_menu + load_opened_shortcut_menu ); }); } @@ -185,7 +189,11 @@ function display_info(msg){ }, 5000); } -function load_shortcut_menu(){ +function load_opened_shortcut_menu(){ + load_shortcut_menu(true); +} + +function load_shortcut_menu(opened){ if (!shortcut_url) return; $('.modal-progress').modal('show'); $.ajax({ @@ -193,6 +201,9 @@ function load_shortcut_menu(){ cache: false, success:function(html){ init_shortcut_menu(html); + if(opened){ + $("#dropdown-toggle-shortcut-menu").click(); + } }, error:function(XMLHttpRequest, textStatus, errorThrows){ close_wait(); diff --git a/ishtar_common/static/media/styles.css b/ishtar_common/static/media/styles.css index 6ff286c41..46d65f0ed 100644 --- a/ishtar_common/static/media/styles.css +++ b/ishtar_common/static/media/styles.css @@ -1,4 +1,3 @@ -#context-menu, #advanced-search-resume, #language-form{ display: none; @@ -99,6 +98,14 @@ div#foot{ width: 100%; } +/* shortcut menu */ + +.shortcut-title { + line-height: 2em; + vertical-align: top; + padding: 0 0.8em; +} + /* window */ .close-buttons{ position: absolute; diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index c9dfde974..b2f0b055c 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -56,9 +56,9 @@ {% include "navbar.html" %} - {% if not reminders %} - {% else %} -
{% trans "Current items" %}
+ + {% if reminders %} +
{% trans "Current items" %}
{% for lbl, value in reminders %}

{{lbl}}{% trans ":"%} {{value}}

{% endfor %} diff --git a/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html index cd7bf88f8..953b0ef40 100644 --- a/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html +++ b/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html @@ -1,49 +1,54 @@ +{% extends "ishtar/blocks/base_shortcut_menu.html" %} {% load i18n %} -{% if menu %} -
-
- - - - - - - - +{% block short_content %}
- - + +
-
-

-

- - -

-

- -

+
+ + + {% comment %} +

+ +

+ {% endcomment %}
- -{% for lbl, model_name, current, widget in menu %} - - - {% with 'show-'|add:model_name as model_url%} - - - {% endwith %} - -{% endfor %} -
- {{widget|safe}} - - -
-
-
- -{% endif %} +{% endblock %} diff --git a/ishtar_common/templates/ishtar/blocks/base_shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/base_shortcut_menu.html new file mode 100644 index 000000000..95e030b85 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/base_shortcut_menu.html @@ -0,0 +1,46 @@ +{% load i18n %} +{% if current_menu or menu %} +{% comment %} + +{% endcomment %} + + + + +{% endif %} diff --git a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html index 5a811ddf0..10113aa59 100644 --- a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html +++ b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html @@ -1,47 +1,43 @@ +{% extends "ishtar/blocks/base_shortcut_menu.html" %} {% load i18n %} -{% if current_menu %} - - -{% endif %} +{% endblock %} + +{% block short_extrajs %} +var advanced_menu = false; +{% endblock %} diff --git a/ishtar_common/templates/navbar.html b/ishtar_common/templates/navbar.html index 0f6036a6c..a5c135a59 100644 --- a/ishtar_common/templates/navbar.html +++ b/ishtar_common/templates/navbar.html @@ -9,7 +9,7 @@