diff options
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 39 | ||||
-rw-r--r-- | ishtar_common/static/media/styles.css | 9 | ||||
-rw-r--r-- | ishtar_common/templates/base.html | 6 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html | 93 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/base_shortcut_menu.html | 46 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/shortcut_menu.html | 84 | ||||
-rw-r--r-- | ishtar_common/templates/navbar.html | 2 | ||||
-rw-r--r-- | ishtar_common/views.py | 24 | ||||
-rw-r--r-- | scss/custom.scss | 7 |
9 files changed, 200 insertions, 110 deletions
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 @@ </head> <body{% if current_theme%} id='{{current_theme}}'{%endif%}> {% include "navbar.html" %} - {% if not reminders %}<div id="context-menu" class="navbar navbar-expand-lg"></div> - {% else %} -<div id="reminder"><h5>{% trans "Current items" %}</h5> + <div id="context-menu" class="navbar navbar-expand-lg"></div> + {% if reminders %} + <div id="reminder"><h5>{% trans "Current items" %}</h5> {% for lbl, value in reminders %} <p><strong class='lbl'>{{lbl}}{% trans ":"%}</strong> <span class='value'>{{value}}</span></p> {% 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 %} -<form method="post" action="{% url 'update-current-item' %}"> -<fieldset id='shortcut-menu'> -<span class="fa-stack short-menu-close"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-times fa-stack-1x fa-inverse"></i> -</span> -<span class="fa-stack short-menu-open"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-plus fa-stack-1x fa-inverse"></i> -</span> +{% block short_content %} <div class="short-menu-buttons btn-group" role="group"> - <button type="button" class="btn" id='short-menu-simple' title="{% trans 'Simple menu limited to your own items. Be careful only the last 100 items are displayed.' %}">{% trans "simple" %}</button> - <button type="button" class="btn btn-selected" id='short-menu-advanced' title="{% trans 'Advanced menu' %}">{% trans "advanced" %}</button> + <button type="button" class="btn btn-secondary" + id='short-menu-simple' title="{% trans 'Simple menu limited to your own items. Be careful only the last 100 items are displayed.' %}">{% trans "simple" %}</button> + <button type="button" class="btn btn-secondary active" id='short-menu-advanced' title="{% trans 'Advanced menu' %}">{% trans "advanced" %}</button> </div> -<div id='action_current_items'> -<p><i class="icon fa fa-thumb-tack fa-2x" aria-hidden="true" title="{% trans 'Pin an item in order to constrain default searches with this item. By default only your items are displayed. New created and modified items are auto-pin.' %}"></i></p> -<p> -<a href='' onclick='return activate_own_search();' class='activate_own_search{% if SHORTCUT_SEARCH == 'all' %} disabled{% endif %}'><i class="icon fa fa-user" aria-hidden="true" title="{% trans 'Search within my items' %}"></i></a> -<a href='' class='activate_all_search{% if SHORTCUT_SEARCH == 'own' %} disabled{% endif %}' onclick='return activate_all_search();'><i class="icon fa fa-users" aria-hidden="true" title="{% trans 'Search within all items' %}"></i></a> -</p> -<p> -<a href='' onclick='return load_shortcut_menu();' class='disabled'><i class="icon fa fa-2x fa-refresh" aria-hidden="true" title="{% trans 'Refresh menu' %}"></i></a> -</p> +<div id='action_current_items' class="btn-group" role="group"> + <button type="button" onclick='return activate_own_search();' + title="{% trans 'Search within my items' %}" + class='btn btn-secondary activate_own_search{% if SHORTCUT_SEARCH == "own" %} active{% endif %}'> + <i class="icon fa fa-user" aria-hidden="true"></i> + </button> + <button type="button" onclick='return activate_all_search();' + title="{% trans 'Search within all items' %}" + class='btn btn-secondary activate_all_search{% if SHORTCUT_SEARCH == "all" %} active{% endif %}'> + <i class="icon fa fa-users" aria-hidden="true"></i> + </button> + {% comment %} + <p> + <a href='' onclick='return load_shortcut_menu();' class='disabled'><i class="icon fa fa-2x fa-refresh" aria-hidden="true" title="{% trans 'Refresh menu' %}"></i></a> + </p> + {% endcomment %} </div> -<table id='current_items'> -{% for lbl, model_name, current, widget in menu %} -<tr> - <td><label for="current_{{model_name}}">{{lbl}}</label></td> - <td> - {{widget|safe}} - </td>{% with 'show-'|add:model_name as model_url%} - <td><a href='#' onclick='load_current_window("{% url model_url current %}", "{{model_name}}");' class='display_details'><i class="fa fa-info-circle" aria-hidden="true"></i></a></td> - <td><span class='disabled pin-action' onclick='$.get("{% url 'unpin' model_name %}", function(){load_shortcut_menu();});' title="{% trans 'Unpin' %}"> - <i class="fa fa-times"></i> - </span></td> - {% endwith %} -</tr> -{% endfor %} -</table> -</fieldset> -</form> -<script type='text/javascript'> +<p id='current_items'> + {% for lbl, model_name, current, widget in menu %} + <div class="form-group row"> + <label for="current_{{model_name}}" + class="col-sm-4 col-form-label">{{lbl}}</label> + <div class="col-sm-6"> + {{widget|safe}} + </div> + {% with 'show-'|add:model_name as model_url%} + <div class="col-sm-2"> + <a href='#' onclick='load_current_window("{% url model_url current %}", "{{model_name}}");' class='display_details'> + <i class="fa fa-info-circle" aria-hidden="true"></i> + </a> + <a href='#' + class='disabled pin-action text-danger' + onclick='$.get("{% url "unpin" model_name %}", function(){load_shortcut_menu();});' title="{% trans 'Unpin' %}"> + <i class="fa fa-times"></i> + </a> + </div> + {% endwith %} + </div> + </tr> + {% endfor %} +</p> +{% endblock %} + +{% block short_extrajs %} var advanced_menu = true; -{% if SHORTCUT_SHOW == 'off' %}var shortcut_menu_hide = true; -{% else %}var shortcut_menu_hide = false;{% endif %} -</script> -{% 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 %} +<button class="navbar-toggler" type="button" + data-toggle="collapse" data-target="#navbar-shortcut" + aria-controls="navbar-shortcut" aria-expanded="false" + aria-label="{% trans 'Toggle navigation' %}"> + <span class="navbar-toggler-icon"></span> +</button> +{% endcomment %} +<div class="navbar-collapse collapse justify-content-end"> + <ul class="navbar-nav" id="navbar-shortcut"> + <li class="nav-item"> + <ol class="breadcrumb"> + {% for lbl in current_selected_labels %} + <li class="breadcrumb-item">{{lbl}}</li> + {% empty %} + {% trans "No default selection" %} + {% endfor %} + </ol> + </li> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" + href="#" role="button" aria-haspopup="true" + id="dropdown-toggle-shortcut-menu"> + <i class="icon fa fa-thumb-tack fa-2x" aria-hidden="true" title="{% trans 'Pin an item in order to constrain default searches with this item. By default only your items are displayed. New created and modified items are auto-pin.' %}"></i> + </a> + <div id="shortcut-menu" class="dropdown-menu dropdown-menu-right"> + <form method="post" action="{% url 'update-current-item' %}"> + <h4>{% trans "Default selection" %}</h4> + {% block short_content %} + {% endblock %} + </form> + </div> + </li> + </ul> +</div> + +<script type='text/javascript'> +{% if SHORTCUT_SHOW == 'off' %}var shortcut_menu_hide = true; +{% else %}var shortcut_menu_hide = false;{% endif %} +{% block short_extrajs %} +{% endblock %} +</script> + +{% 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 %} -<div class="nav-item dropdown navbar-expand-lg navbar-collapse justify-content-end"> - <ul class="navbar-nav"> - <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" data-toggle="dropdown" - href="#" role="button" aria-haspopup="true"> - {% trans "Default selection" %} - <i class="icon fa fa-thumb-tack fa-2x" aria-hidden="true" title="{% trans 'Pin an item in order to constrain default searches with this item. By default only your items are displayed. New created and modified items are auto-pin.' %}"></i> - </a> - <div id="shortcut-menu" class="dropdown-menu dropdown-menu-right"> - <form method="post" action="{% url 'update-current-item' %}"> - - <div class="short-menu-buttons btn-group" role="group"> - <button type="button" class="btn btn-selected" id='short-menu-simple' title="{% trans 'Simple menu limited to your own items. Be careful only the last 100 items are displayed.' %}">{% trans "simple" %}</button> - <button type="button" class="btn" id='short-menu-advanced' title="{% trans 'Advanced menu' %}">{% trans "advanced" %}</button> - </div> - <div> - <table id='current_items'> - {% for lbl, model_name, main_cls, items in current_menu %} - <tr> - <td><label for="current_{{model_name}}">{{lbl}}</label></td> - <td> - <select class='{{main_cls}} chosen-select' id='current_{{model_name}}'> - <option class='normal' value=''>--</option> - {% for val, label, selected, cls in items %}<option{% if cls %} class='{{cls}}'{% endif %} value='{{val}}'{% if selected %} selected="selected"{% endif %}>{% ifequal cls 'basket' %} {% endifequal %}{% ifequal cls 'green' %} {% endifequal %}{% ifequal cls 'orange' %} {% endifequal %}{% ifequal cls 'red' %} {% endifequal %}{{label}}</option> - {% endfor %}</select> - </td>{% with 'show-'|add:model_name as model_url%} - <td><a href='#' onclick='load_current_window("{% url model_url 0 %}", "{{model_name}}");' class='display_details'><i class="fa fa-info-circle" aria-hidden="true"></i></a></td> - <td><span class='pin-action' onclick='$.get("{% url 'unpin' model_name %}", function(){load_shortcut_menu();});' title="{% trans 'Unpin' %}"> - <i class="fa fa-times"></i> - </span></td> - {% endwith %} - </tr> - {% endfor %} - </table> - </div> - </form> +{% block short_content %} +<div class="short-menu-buttons btn-group" role="group"> + <button type="button" class="btn btn-secondary active" + id='short-menu-simple' title="{% trans 'Simple menu limited to your own items. Be careful only the last 100 items are displayed.' %}">{% trans "simple" %}</button> + <button type="button" class="btn btn-secondary" id='short-menu-advanced' title="{% trans 'Advanced menu' %}">{% trans "advanced" %}</button> +</div> +<div> + <p class="alert alert-info mt-2"> + {% trans 'Simple menu limited to your own items. Be careful only the last 100 items are displayed.' %} + </p> + <p id='current_items'> + {% for lbl, model_name, main_cls, items in current_menu %} + <div class="form-group row"> + <label for="current_{{model_name}}" + class="col-sm-4 col-form-label">{{lbl}}</label> + <div class="col-sm-6"> + <select class='{{main_cls}} chosen-select' id='current_{{model_name}}'> + <option class='normal' value=''>--</option> + {% for val, label, selected, cls in items %}<option{% if cls %} class='{{cls}}'{% endif %} value='{{val}}'{% if selected %} selected="selected"{% endif %}>{% ifequal cls 'basket' %} {% endifequal %}{% ifequal cls 'green' %} {% endifequal %}{% ifequal cls 'orange' %} {% endifequal %}{% ifequal cls 'red' %} {% endifequal %}{{label}}</option> + {% endfor %}</select> + </div> + {% with 'show-'|add:model_name as model_url%} + <div class="col-sm-2"> + <a href='#' onclick='load_current_window("{% url model_url 0 %}", "{{model_name}}");' class='display_details'> + <i class="fa fa-info-circle" aria-hidden="true"></i></a> + <a href='#' + class='disabled pin-action text-danger' + onclick='$.get("{% url "unpin" model_name %}", function(){load_shortcut_menu();});' title="{% trans 'Unpin' %}"> + <i class="fa fa-times"></i> + </a> + </div> + {% endwith %} </div> - </li> - </ul> + {% endfor %} + </p> </div> -<script type='text/javascript'>var advanced_menu = false; -{% if SHORTCUT_SHOW == 'off' %}var shortcut_menu_hide = true; -{% else %}var shortcut_menu_hide = false;{% endif %} -</script> -{% 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 @@ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-actions" aria-controls="navbar-actions" aria-expanded="false" - aria-label="Toggle navigation"> + aria-label="{% trans 'Toggle navigation' %}"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse justify-content-end" id="navbar-actions"> diff --git a/ishtar_common/views.py b/ishtar_common/views.py index e49918d78..e8a7efb40 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -283,10 +283,18 @@ def shortcut_menu(request): if 'SHORTCUT_SHOW' in request.session else 'on' } + current_selected_labels = [] for lbl, model in CURRENT_ITEMS: model_name = model.SLUG current = model_name in request.session \ and request.session[model_name] + if current: + try: + item = model.objects.get(pk=int(current)) + item_label = shortify(unicode(item), 60) + current_selected_labels.append(item_label) + except model.DoesNotExist: + pass dct['menu'].append(( lbl, model_name, current or 0, JQueryAutoComplete( @@ -294,6 +302,7 @@ def shortcut_menu(request): model).render( model.SLUG + '-shortcut', value=current, attrs={'id': 'current_' + model.SLUG}))) + dct['current_selected_labels'] = current_selected_labels return render( request, 'ishtar/blocks/advanced_shortcut_menu.html', dct ) @@ -302,7 +311,9 @@ def shortcut_menu(request): 'SHORTCUT_SHOW': request.session['SHORTCUT_SHOW'] if 'SHORTCUT_SHOW' in request.session else 'off' } + current_selected_labels = [] current_selected_item = {} + labels = {} for lbl, model in CURRENT_ITEMS: new_selected_item = None model_name = model.SLUG @@ -310,6 +321,7 @@ def shortcut_menu(request): current = model_name in request.session and request.session[model_name] items = [] current_items = [] + labels[model_name] = {} for item, shortmenu_class in model.get_owns( request.user, menu_filtr=current_selected_item, limit=100, values=['id', 'cached_label'], get_short_menu_class=True): @@ -321,17 +333,21 @@ def shortcut_menu(request): continue current_items.append(pk) selected = pk == current + item_label = shortify(item['cached_label'], 60) if selected: cls = shortmenu_class new_selected_item = pk - items.append((pk, shortify(item['cached_label'], 60), + labels[model_name][str(pk)] = item_label + items.append((pk, item_label, selected, shortmenu_class)) # selected is not in owns - add it to the list if not new_selected_item and current: try: item = model.objects.get(pk=int(current)) new_selected_item = item.pk - items.append((item.pk, shortify(unicode(item), 60), + item_label = shortify(unicode(item), 60) + labels[model_name][str(item.pk)] = item_label + items.append((item.pk, item_label, True, item.get_short_menu_class(item.pk))) except (model.DoesNotExist, ValueError): pass @@ -339,6 +355,10 @@ def shortcut_menu(request): dct['current_menu'].append((lbl, model_name, cls, items)) if new_selected_item: current_selected_item[model_name] = new_selected_item + if str(new_selected_item) in labels[model_name]: + current_selected_labels.append( + labels[model_name][str(new_selected_item)]) + dct['current_selected_labels'] = current_selected_labels return render(request, 'ishtar/blocks/shortcut_menu.html', dct) diff --git a/scss/custom.scss b/scss/custom.scss index b97424674..7797f4c03 100644 --- a/scss/custom.scss +++ b/scss/custom.scss @@ -142,11 +142,16 @@ p.confirm-message{ padding: 1em; } -#context-menu a{ +#context-menu a.nav-link{ color: $dark-secondary-color; padding: 0.2rem 0.5rem; } +#context-menu .breadcrumb{ + margin-bottom: 0; + background-color: transparent; +} + #current_items{ width: 100%; } |