X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/69f51bf0aaf0fcfa23a732f7524168f52e67bd5c..ae278b58747710a8c843a6bee9375186eafa17f7:/SL/ClientJS.pm diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 91c9e1abe..91ff14b18 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 _error) ], + 'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _error) ], ); my %supported_methods = ( @@ -115,6 +115,8 @@ my %supported_methods = ( redirect_to => 1, # window.location.href = 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(, ) @@ -180,6 +182,10 @@ sub init__flash { return {}; } +sub init__flash_detail { + return {}; +} + sub init__error { return ''; } @@ -236,6 +242,21 @@ sub flash { return $self; } +sub flash_detail { + my ($self, $type, @messages) = @_; + + my $message = join '
', grep { $_ } @messages; + + if (!$self->_flash_detail->{$type}) { + $self->_flash_detail->{$type} = [ 'flash_detail', $type, $message ]; + push @{ $self->_actions }, $self->_flash_detail->{$type}; + } else { + $self->_flash_detail->{$type}->[-1] .= ' ' . $message; + } + + return $self; +} + sub error { my ($self, @messages) = @_;