From: Martin Helmling martin.helmling@octosoft.eu Date: Mon, 7 Nov 2016 09:34:10 +0000 (+0100) Subject: Automatisches Löschen von Flashanzeige unterdrückbar X-Git-Tag: release-3.5.4~1932 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=aa8809a6fe7015f001643b74a5599aebdf6a2123;p=kivitendo-erp.git Automatisches Löschen von Flashanzeige unterdrückbar Bei jedem ClientJS call wird bisher vor Ausführung der Antwortdaten in Javascript die Info/Warnung/Fehleranzeige gelöscht. Bei periodischen ClientJS call kann das zu unerwünschten Effekten führen, z.B. eine Fehlermeldung wird so schnell gelöscht, dass sie nicht erkannt werden kann. Nun kann optional dies per $self->js->no_flash_clear abgeschaltet werden --- diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 91ff14b18..91a12576b 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -10,7 +10,7 @@ use SL::JSON (); use Rose::Object::MakeMethods::Generic ( scalar => [ qw() ], - 'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _error) ], + 'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _no_flash_clear _error) ], ); my %supported_methods = ( @@ -190,11 +190,15 @@ sub init__error { return ''; } +sub init__no_flash_clear { + return ''; +} + sub to_json { my ($self) = @_; - return SL::JSON::to_json({ error => $self->_error }) if $self->_error; - return SL::JSON::to_json({ eval_actions => $self->_actions }); + return SL::JSON::to_json({ error => $self->_error }) if $self->_error; + return SL::JSON::to_json({ no_flash_clear => $self->_no_flash_clear, eval_actions => $self->_actions }); } sub to_array { @@ -257,6 +261,12 @@ sub flash_detail { return $self; } +sub no_flash_clear{ + my ($self) = @_; + $self->_no_flash_clear('1'); + return $self; +} + sub error { my ($self, @messages) = @_; @@ -484,6 +494,17 @@ C on the same C<$self> will be merged by type. On the client side the flashes of all types will be cleared after each successful ClientJS call that did not end with C<$js-Eerror(...)>. +This clearing can be switched of by the function C + +=item C + +Display a detailed message C<$message> in the flash of type C<$type>. Multiple calls of +C on the same C<$self> will be merged by type. +So the flash message can be hold short and the visibility of details can toggled by the user. + +=item C + +No automatic clearing of flash after successful ClientJS call =item C diff --git a/js/client_js.js b/js/client_js.js index c592e4c8e..d29fca627 100644 --- a/js/client_js.js +++ b/js/client_js.js @@ -35,6 +35,7 @@ ns.eval_json_result = function(data) { if (data.error) return ns.display_flash('error', data.error); + if (!data.no_flash_clear) { $(['info', 'warning', 'error']).each(function(idx, category) { $('#flash_' + category).hide(); $('#flash_detail_' + category).hide(); @@ -42,7 +43,7 @@ ns.eval_json_result = function(data) { $('#flash_' + category + '_content').empty(); $('#flash_' + category + '_detail').empty(); }); - + } if ((data.js || '') != '') eval(data.js);