diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/models_common.py | 7 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 29 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_nav.html | 13 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/forms/modify_relations.html | 1 |
4 files changed, 41 insertions, 9 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index de1de3a91..d4a8cb521 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1290,7 +1290,14 @@ class FullSearch(models.Model): datas = [data] if json_field.value_type == "MC": datas = data + new_datas = [] for d in datas: + # flatify lists + if not isinstance(d, (list, tuple)): + new_datas.append(d) + continue + new_datas += [v for v in d if v not in (None, "")] + for d in new_datas: for lang in ("simple", settings.ISHTAR_SEARCH_LANGUAGE): with connection.cursor() as cursor: cursor.execute("SELECT to_tsvector(%s, %s)", [lang, d]) diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 624d1902b..cb3638e1c 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -528,7 +528,6 @@ $(document).ready(function(){ register_wait_button(); $(".help-text-parent").click(function(){ if ($(this).is(":visible")) { - console.log($(this).attr("id")); $("[aria-controls='" + $(this).attr("id") + "']").click(); } }); @@ -545,9 +544,14 @@ var register_modal_on_close = function(){ modal_on_close[this.id] = undefined; $("#" + this.id).on('hide.bs.modal', function() { if (modal_on_close[this.id] !== undefined){ - modal_on_close[this.id](); + parameters = {} + if (modal_on_close[this.id + "-window-id"]) parameters["window-id"] = modal_on_close[this.id + "-window-id"]; + if (modal_on_close[this.id + "-window-tab"]) parameters["window-tab"] = modal_on_close[this.id + "-window-tab"]; + modal_on_close[this.id](parameters); // reinitialize after call modal_on_close[this.id] = undefined; + modal_on_close[this.id + "-window-id"] = undefined; + modal_on_close[this.id + "-window-tab"] = undefined; } }); } @@ -1044,7 +1048,9 @@ function toggle_window_menu(){ var register_qa = function(){ $(".btn-qa").click(function(){ let target = $(this).attr('data-target'); - dt_qa_open(target); + let window_id = $(this).attr('data-window'); + let window_tab = $(this).attr('data-window-tab'); + dt_qa_open(target, null, window_id, window_tab); }); }; @@ -1053,7 +1059,9 @@ var register_qa_confirm = function(){ let confirm_message = $(this).attr('data-confirm'); let target = $(this).attr('data-target'); if (!confirm(confirm_message)) return; - dt_qa_open(target); + let window_id = $(this).attr('data-window'); + let window_tab = $(this).attr('data-window-tab'); + dt_qa_open(target, null, window_id, window_tab); }); }; @@ -1258,7 +1266,7 @@ var dt_generate_qa_url = function (table, url){ return url; }; -var dt_qa_open = function (url, modal_id){ +var dt_qa_open = function (url, modal_id, window_id, window_tab){ if (!modal_id) modal_id = "modal-dynamic-form"; if (!$('#' + modal_id).length){ let src = '<div class="modal" id="' + modal_id + '" tabindex="-1" role="dialog"'; @@ -1266,6 +1274,8 @@ var dt_qa_open = function (url, modal_id){ $("#message").after(src); } short_wait(); + let data = {}; + if (window_id) data["window_id"] = window_id; $.ajax({ url: url, cache: false, @@ -1282,7 +1292,16 @@ var dt_qa_open = function (url, modal_id){ $('#' + modal_id).modal("show"); let table_scroll_height = $(window).height() - 180; $(".table-scroll table").height(table_scroll_height + "px"); + if (window_id && window_tab){ + // reload the content and activate the tab + let current_window_id = $("div.card.sheet[id^=" + window_id + "]").attr('id').replaceAll('-', "_"); + let parameters = {}; + parameters["window-id"] = window_id; + parameters["window-tab"] = window_tab; + window["reload_window_" + current_window_id](parameters); + } }, + data: data, error: function() { close_wait(); } diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html index b30fc683b..282d0fc22 100644 --- a/ishtar_common/templates/ishtar/blocks/window_nav.html +++ b/ishtar_common/templates/ishtar/blocks/window_nav.html @@ -1,11 +1,18 @@ {% load l10n i18n ishtar_helpers %} <script type="text/javascript">{% localize off %} var current_url_{{window_id_underscore}}; - var reload_window_{{window_id_underscore}} = function() { + var reload_window_{{window_id_underscore}} = function(parameters) { /* reload put the sheet at the end of list - force other to be close in order to not loose the current sheet */ $(".sheet > .collapse").removeClass("show"); load_window(current_url_{{window_id_underscore}}, - '', function(){hide_window("{{window_id}}");}, + '', function(){ + hide_window("{{window_id}}"); + if (parameters && parameters["window-id"]){ + let window_id = parameters["window-id"]; + let window_tab = parameters["window-tab"]; + $("a[id^=" + window_id + "][id$=" + window_tab + "]").tab("show"); + } + }, true); }; {% endlocalize %}</script> @@ -69,7 +76,7 @@ {% endif %} {% for url, base_text, icon, extra_text, css_class, is_qa in extra_actions %} <a class="{% if is_qa %}btn-qa{% else %}wait-button{% endif %} btn btn-success{% if css_class %} {{css_class}}{% endif %}" - {% if is_qa %}href="#" data-target="{{url}}"{% else %}href='{{url}}'{% endif %} title="{{base_text}}"> + {% if is_qa %}href="#" data-target="{{url}}" data-window="{{window_id}}"{% else %}href='{{url}}'{% endif %} title="{{base_text}}"> <i class="{{icon}}"></i> {{extra_text}} </a> {% endfor %} diff --git a/ishtar_common/templates/ishtar/forms/modify_relations.html b/ishtar_common/templates/ishtar/forms/modify_relations.html index 419d94c9a..98daf68e4 100644 --- a/ishtar_common/templates/ishtar/forms/modify_relations.html +++ b/ishtar_common/templates/ishtar/forms/modify_relations.html @@ -57,7 +57,6 @@ $(document).on("click", '.check-all-relations', function(){ $('input[id$="-DELETE"]:checkbox').prop('checked', $(this).is(':checked')); });{% if window_id %} - console.log("{{window_id}}"); modal_on_close["modal-dynamic-form"] = reload_window_{{window_id}}; {% endif %} {% block js_ready %} |
