From abff4e19886c6e820d32fbfc4647ac11323a7626 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Feb 2018 12:16:30 +0100 Subject: Improve navigation between sheets (JS) --- ishtar_common/static/js/ishtar.js | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'ishtar_common') diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index c3e36d77b..2772b3ecf 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -324,8 +324,20 @@ function load_window(url, speed, on_success, no_jump){ if (current_sheet.length){ current_sheet.parent().remove(); } + var current_id = $(html).find(".card-header").parent().attr("id"); + var current_label = $(html).find(".card-label").html(); + var new_sheet_list = new Array(); + for (idx in sheet_list){ + if (sheet_list[idx]['register_id'] != register_id){ + new_sheet_list.push(sheet_list[idx]); + } + } + sheet_list = new_sheet_list; + sheet_list.push({'id': current_id, 'label': current_label, + 'register_id': register_id}); $("#window").append(html); $("#" + last_window).show(); + update_window_menu(); if (!no_jump){ // jump to this window var url = location.href; @@ -354,6 +366,24 @@ function load_current_window(url, model_name){ return load_window(url.join('/')); } +function hide_window(window_id){ + $("#" + window_id).remove(); + splitted = window_id.split('-'); + register_id = ""; + for (idx=0 ; idx < splitted.length - 1 ; idx++){ + if (idx > 0) register_id += "-"; + register_id += splitted[idx] + } + var new_sheet_list = new Array(); + for (idx in sheet_list){ + if (sheet_list[idx]['register_id'] != register_id){ + new_sheet_list.push(sheet_list[idx]); + } + } + sheet_list = new_sheet_list; + update_window_menu(); +} + function load_url(url){ $('.modal-progress').modal('show'); $.ajax({ @@ -500,6 +530,25 @@ function update_search_resume(){ } } +var sheet_list = new Array(); + +function update_window_menu(){ + if (!sheet_list.length){ + $("#window-fixed-menu").hide(); + return + } + var html = ""; + for (idx in sheet_list){ + var sheet = sheet_list[idx]; + html += ''; + } + $("#window-fixed-menu-list").html(html); + $("#window-fixed-menu").show(); +} + function register_advanced_search(){ $(".advanced-search-reset").click( -- cgit v1.2.3