X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FClientJS.pm;h=4cdb2037e2770d66b2bfeb9d9f69a29f94378989;hb=7349649bae8d80eabfd253592d59f8455f9ef6b0;hp=335bf8163107cdfcf383cd7c7e19a9de039d36cd;hpb=4f14c25d5726275ba6805480d974190ee80c187e;p=kivitendo-erp.git diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 335bf8163..4cdb2037e 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -9,8 +9,8 @@ use SL::JSON (); use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(controller) ], - 'scalar --get_set_init' => [ qw(_actions _flash _error) ], + scalar => [ qw() ], + 'scalar --get_set_init' => [ qw(controller _actions _flash _flash_detail _error) ], ); my %supported_methods = ( @@ -115,6 +115,7 @@ my %supported_methods = ( redirect_to => 1, # window.location.href = flash => 2, # kivi.display_flash(, ) + flash_detail => 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 +181,10 @@ sub init__flash { return {}; } +sub init__flash_detail { + return {}; +} + sub init__error { return ''; } @@ -236,6 +241,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) = @_; @@ -244,6 +264,12 @@ sub error { return $self; } +sub init_controller { + # fallback + require SL::Controller::Base; + SL::Controller::Base->new; +} + 1; __END__