Skip to content

Commit

Permalink
add support for new display action
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Feb 14, 2023
1 parent 4d8a108 commit 56ad133
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
19 changes: 19 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
0.43.0 2023-02-14 16:54:59 +0100 Tobias Oetiker <[email protected]>

- add display action which displays a report in a new window instead of providing a download

{
label => trm('Report'),
action => 'display',
key => 'report',
actionHandler => sub {
my $self = shift;
my $args = shift;
return {
asset => $self->getReportHtml(),
type => 'text/html',
filename => 'xyz.html',
}
}
},

0.42.5 2023-01-30 18:59:37 +0100 Tobias Oetiker <[email protected]>

- revert 0.42.2 do NOT catch instanciation errors as this will
Expand Down
2 changes: 1 addition & 1 deletion lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use CallBackery::Database;
use CallBackery::User;


our $VERSION = '0.42.5';
our $VERSION = '0.43.0';


=head2 config
Expand Down
4 changes: 3 additions & 1 deletion lib/CallBackery/Controller/RpcService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ async sub handleDownload {
}

$self->res->headers->content_type($map->{type}.';name=' .$map->{filename});
$self->res->headers->content_disposition('attachment;filename='.$map->{filename});
if (not $self->param('display')) {
$self->res->headers->content_disposition('attachment;filename='.$map->{filename});
}
$self->res->content->asset($map->{asset});
$self->rendered(200);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/CallBackery/GuiPlugin/AbstractAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ has actionCfgMap => sub {
my $self = shift;
my %map;
for my $row (@{$self->actionCfg}){
next unless $row->{action} =~ /^(submit|upload|download|autoSubmit|save)/;
next unless $row->{action} =~ /^(submit|upload|download|display|autoSubmit|save)/;
next unless $row->{key};
my $key = $row->{key};
die mkerror(4646, "Duplicate action key $key") if exists $map{$key};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ qx.Class.define("callbackery.ui.plugin.Action", {
case 'logout':
case 'cancel':
case 'download':
case 'display':
if (btCfg.addToMenu != null) {
button = new qx.ui.menu.Button(label);
}
Expand Down Expand Up @@ -321,6 +322,7 @@ qx.Class.define("callbackery.ui.plugin.Action", {
}
break;
case 'download':
case 'display':
var formData = getFormData();
if (formData === false){
callbackery.ui.MsgBox.getInstance().error(
Expand All @@ -331,6 +333,15 @@ qx.Class.define("callbackery.ui.plugin.Action", {
}
var key = btCfg.key;
callbackery.data.Server.getInstance().callAsyncSmart(function(cookie){
let url = 'download'
+'?name='+cfg.name
+'&key='+key
+'&xsc='+encodeURIComponent(cookie)
+'&formData='+encodeURIComponent(qx.lang.Json.stringify(formData));
if (btCfg.action == 'display') {
window.open(url + '&display=1','_blank');
return;
}
var iframe = new qx.ui.embed.Iframe().set({
width: 100,
height: 100
Expand Down Expand Up @@ -367,13 +378,7 @@ qx.Class.define("callbackery.ui.plugin.Action", {
}
that.getApplicationRoot().remove(iframe);
});
iframe.setSource(
'download'
+'?key='+key
+'&xsc='+encodeURIComponent(cookie)
+'&name='+cfg.name
+'&formData='+encodeURIComponent(qx.lang.Json.stringify(formData))
);
iframe.setSource(url);
that.getApplicationRoot().add(iframe,{top: -1000,left: -1000});
},'getSessionCookie');
break;
Expand Down

0 comments on commit 56ad133

Please sign in to comment.