From 56ad133c3a86dfe50d1b7475663a6ccefd14c9e0 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Tue, 14 Feb 2023 17:05:23 +0100 Subject: [PATCH] add support for new display action --- CHANGES | 19 +++++++++++++++++++ lib/CallBackery.pm | 2 +- lib/CallBackery/Controller/RpcService.pm | 4 +++- lib/CallBackery/GuiPlugin/AbstractAction.pm | 2 +- .../class/callbackery/ui/plugin/Action.js | 19 ++++++++++++------- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 9515058..1b4c268 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,22 @@ +0.43.0 2023-02-14 16:54:59 +0100 Tobias Oetiker + + - 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 - revert 0.42.2 do NOT catch instanciation errors as this will diff --git a/lib/CallBackery.pm b/lib/CallBackery.pm index 9ce81bb..e8c244c 100644 --- a/lib/CallBackery.pm +++ b/lib/CallBackery.pm @@ -38,7 +38,7 @@ use CallBackery::Database; use CallBackery::User; -our $VERSION = '0.42.5'; +our $VERSION = '0.43.0'; =head2 config diff --git a/lib/CallBackery/Controller/RpcService.pm b/lib/CallBackery/Controller/RpcService.pm index d9307d5..e6955ef 100644 --- a/lib/CallBackery/Controller/RpcService.pm +++ b/lib/CallBackery/Controller/RpcService.pm @@ -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); } diff --git a/lib/CallBackery/GuiPlugin/AbstractAction.pm b/lib/CallBackery/GuiPlugin/AbstractAction.pm index b11efb9..776eef9 100644 --- a/lib/CallBackery/GuiPlugin/AbstractAction.pm +++ b/lib/CallBackery/GuiPlugin/AbstractAction.pm @@ -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}; diff --git a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Action.js b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Action.js index fa6fb3e..f1f2c9e 100644 --- a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Action.js +++ b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/plugin/Action.js @@ -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); } @@ -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( @@ -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 @@ -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;