Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aa8809a6

Von Martin Helmling martin.helmling@octosoft.eu vor mehr als 7 Jahren hinzugefügt

  • ID aa8809a6fe7015f001643b74a5599aebdf6a2123
  • Vorgänger 88d162cc
  • Nachfolger 93a1b332

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

Unterschiede anzeigen:

SL/ClientJS.pm
10 10
use Rose::Object::MakeMethods::Generic
11 11
(
12 12
  scalar                  => [ qw() ],
13
  'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _error) ],
13
  'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _no_flash_clear _error) ],
14 14
);
15 15

  
16 16
my %supported_methods = (
......
190 190
  return '';
191 191
}
192 192

  
193
sub init__no_flash_clear {
194
  return '';
195
}
196

  
193 197
sub to_json {
194 198
  my ($self) = @_;
195 199

  
196
  return SL::JSON::to_json({ error        => $self->_error   }) if $self->_error;
197
  return SL::JSON::to_json({ eval_actions => $self->_actions });
200
  return SL::JSON::to_json({ error          => $self->_error   }) if $self->_error;
201
  return SL::JSON::to_json({ no_flash_clear => $self->_no_flash_clear, eval_actions => $self->_actions });
198 202
}
199 203

  
200 204
sub to_array {
......
257 261
  return $self;
258 262
}
259 263

  
264
sub no_flash_clear{
265
  my ($self) = @_;
266
  $self->_no_flash_clear('1');
267
  return $self;
268
}
269

  
260 270
sub error {
261 271
  my ($self, @messages) = @_;
262 272

  
......
484 494

  
485 495
On the client side the flashes of all types will be cleared after each
486 496
successful ClientJS call that did not end with C<$js-E<gt>error(...)>.
497
This clearing can be switched of by the function C<no_flash_clear>
498

  
499
=item C<flash_detail $type, $message>
500

  
501
Display a detailed message C<$message> in the flash of type C<$type>. Multiple calls of
502
C<flash_detail> on the same C<$self> will be merged by type.
503
So the flash message can be hold short and the visibility of details can toggled by the user.
504

  
505
=item C<no_flash_clear>
506

  
507
No automatic clearing of flash after successful ClientJS call
487 508

  
488 509
=item C<error $message>
489 510

  
js/client_js.js
35 35
  if (data.error)
36 36
    return ns.display_flash('error', data.error);
37 37

  
38
  if (!data.no_flash_clear) {
38 39
  $(['info', 'warning', 'error']).each(function(idx, category) {
39 40
    $('#flash_' + category).hide();
40 41
    $('#flash_detail_' + category).hide();
......
42 43
    $('#flash_' + category + '_content').empty();
43 44
    $('#flash_' + category + '_detail').empty();
44 45
  });
45

  
46
  }
46 47
  if ((data.js || '') != '')
47 48
    eval(data.js);
48 49

  

Auch abrufbar als: Unified diff