From: Martin Helmling Date: Thu, 28 May 2015 15:51:42 +0000 (+0200) Subject: Flashanzeige erweitert: Löschen und Springen abschalten X-Git-Tag: release-3.5.4~2026 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4b1bcc4753f0a4870b4abb8053a63c548896c5e3;p=kivitendo-erp.git Flashanzeige erweitert: Löschen und Springen abschalten 1. Funktion zum Text löschen nach Timeout Bei neuen Controllern, die per AJAX laufen, ist es empfehlenswert bestimmte Texte nach einer gewissen Zeit implizit zu löschen, damit eine weitere identische Anzeige erkennbar ist. Änderung in clientjs: 2. nach Ausgabe einer Flash Anzeige (Info/Warning/Error) wird nach oben gesprungen ( derzeit zum frame-header). Damit wird die Anzeige auf jeden Fall sichtbar. Bei direkter Nutzung innerhalb Javascript kann per drittem Parameter 'true' das Scrollen verhindert werden. Dies ist derzeit nicht Controllerseitig durchführbar, da die flash() Funktion eine Liste von Strings erwartet. Hierzu müsste die Schnittstelle adaptiert werden oder ggf, eine neue Funktion flash_noscroll() eingebaut werden. --- diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 4cdb2037e..91ff14b18 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -116,6 +116,7 @@ my %supported_methods = ( flash => 2, # kivi.display_flash(, ) flash_detail => 2, # kivi.display_flash_detail(, ) + clear_flash => 2, # kivi.display_flash_detail(, ) reinit_widgets => 0, # kivi.reinit_widgets() run => -1, # kivi.run(, ) run_once_for => 3, # kivi.run_once_for(, ) diff --git a/js/client_js.js b/js/client_js.js index 6b3784a5a..c592e4c8e 100644 --- a/js/client_js.js +++ b/js/client_js.js @@ -5,10 +5,12 @@ // SL/ClientJS.pm for instructions. namespace("kivi", function(ns) { -ns.display_flash = function(type, message) { +ns.display_flash = function(type, message, noscroll) { $('#flash_' + type + '_content').text(message); $('#flash_' + type).show(); - $('#frame-header')[0].scrollIntoView(); + if (!noscroll) { + $('#frame-header')[0].scrollIntoView(); + } }; ns.display_flash_detail = function(type, message) { @@ -148,6 +150,7 @@ ns.eval_json_result = function(data) { else if (action[0] == 'redirect_to') window.location.href = action[1]; else if (action[0] == 'flash') kivi.display_flash(action[1], action[2]); else if (action[0] == 'flash_detail') kivi.display_flash_detail(action[1], action[2]); + else if (action[0] == 'clear_flash') kivi.clear_flash(action[1], action[2]); else if (action[0] == 'reinit_widgets') kivi.reinit_widgets(); else if (action[0] == 'run') kivi.run(action[1], action.slice(2, action.length)); else if (action[0] == 'run_once_for') kivi.run_once_for(action[1], action[2], action[3]); diff --git a/scripts/generate_client_js_actions.tpl b/scripts/generate_client_js_actions.tpl index 50a427c45..a29b32587 100644 --- a/scripts/generate_client_js_actions.tpl +++ b/scripts/generate_client_js_actions.tpl @@ -5,10 +5,12 @@ // SL/ClientJS.pm for instructions. namespace("kivi", function(ns) { -ns.display_flash = function(type, message) { +ns.display_flash = function(type, message, noscroll) { $('#flash_' + type + '_content').text(message); $('#flash_' + type).show(); - $('#frame-header')[0].scrollIntoView(); + if (!noscroll) { + $('#frame-header')[0].scrollIntoView(); + } }; ns.display_flash_detail = function(type, message) { @@ -16,6 +18,16 @@ ns.display_flash_detail = function(type, message) { $('#flash_' + type + '_disp').show(); }; +ns.clear_flash = function(category , timeout) { + window.setTimeout(function(){ + $('#flash_' + category).hide(); + $('#flash_detail_' + category).hide(); + $('#flash_' + category + '_disp').hide(); + $('#flash_' + category + '_content').empty(); + $('#flash_' + category + '_detail').empty(); + }, timeout); +}; + ns.eval_json_result = function(data) { if (!data) return;