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 = (
redirect_to => 1, # window.location.href = <TARGET>
flash => 2, # kivi.display_flash(<TARGET>, <ARGS>)
+ flash_detail => 2, # kivi.display_flash_detail(<TARGET>, <ARGS>)
reinit_widgets => 0, # kivi.reinit_widgets()
run => -1, # kivi.run(<TARGET>, <ARGS>)
run_once_for => 3, # kivi.run_once_for(<TARGET>, <ARGS>)
return {};
}
+sub init__flash_detail {
+ return {};
+}
+
sub init__error {
return '';
}
return $self;
}
+sub flash_detail {
+ my ($self, $type, @messages) = @_;
+
+ my $message = join '<br>', 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) = @_;
ns.display_flash = function(type, message) {
$('#flash_' + type + '_content').text(message);
$('#flash_' + type).show();
+ $('#frame-header')[0].scrollIntoView();
+};
+
+ns.display_flash_detail = function(type, message) {
+ $('#flash_' + type + '_detail').html(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) {
$(['info', 'warning', 'error']).each(function(idx, category) {
$('#flash_' + category).hide();
+ $('#flash_detail_' + category).hide();
+ $('#flash_' + category + '_disp').hide();
$('#flash_' + category + '_content').empty();
+ $('#flash_' + category + '_detail').empty();
});
if ((data.js || '') != '')
// ## other stuff ##
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] == '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]);
ns.display_flash = function(type, message) {
$('#flash_' + type + '_content').text(message);
$('#flash_' + type).show();
+ $('#frame-header')[0].scrollIntoView();
+};
+
+ns.display_flash_detail = function(type, message) {
+ $('#flash_' + type + '_detail').html(message);
+ $('#flash_' + type + '_disp').show();
};
ns.eval_json_result = function(data) {
$(['info', 'warning', 'error']).each(function(idx, category) {
$('#flash_' + category).hide();
+ $('#flash_detail_' + category).hide();
+ $('#flash_' + category + '_disp').hide();
$('#flash_' + category + '_content').empty();
+ $('#flash_' + category + '_detail').empty();
});
if ((data.js || '') != '')
[%- USE HTML -%][%- USE LxERP %][%- USE T8 %]
[%- BLOCK output %]
<div id="flash_[% type %]" class="flash_message_[% type %]"[% IF !messages || !messages.size %] style="display: none"[% END %]>
- <a href='#' style='float:right' onclick='$(this).closest("div").find(".flash_content").empty(); $(this).closest("div").hide()'><img src='image/close.png' border='0' alt='[% 'Close Flash' | $T8 %]'></a>
+ <a href='#' style='float:right'
+ onclick='$("#flash_[% type %]_content").empty();$("#flash_[% type %]_detail").empty();$("#flash_[% type %]").hide()'>
+ <img src='image/close.png' border='0' alt='[% 'Close Flash' | $T8 %]'></a>
<span class="flash_title">[%- title %]:</span>
- <span id="flash_[% type %]_content" class="flash_content">
+ <span id="flash_[% type %]_content">
[% FOREACH message = messages %]
[%- HTML.escape(message) %]
[%- UNLESS loop.last %]<br>[% END %]
[%- END %]
</span>
+ <span id="flash_[% type %]_disp" style="display: none">
+ <a href='#' style='float:left' onclick='$("#flash_detail_[% type %]").toggle();'>
+ [[% 'Details' | $T8 %]]</a> </span>
+ <div id="flash_detail_[% type %]" style="display: none">
+ <br>
+ <span id="flash_[% type %]_detail"></span><br>
+ <a href='#' style='float:left'
+ onclick='$("#flash_detail_[% type %]").hide()'>
+ <img src='image/close.png' border='0' alt='[% 'Close Details' | $T8 %]'></a><br>
+ </div>
</div>
[%- END %]
[%- PROCESS output title=LxERP.t8('Error') type='error' messages = FLASH.error %]