Skip to content

Commit

Permalink
Add callbacks to dashboard portlet rendering
Browse files Browse the repository at this point in the history
In some cases, we might want to change portlet attributes
before rendering it, skip it, or even update HasResults
attribute after the portlet has been rendered.
  • Loading branch information
richieri-bps committed Mar 4, 2024
1 parent cf34cad commit 3151ba1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions share/html/Dashboards/Elements/ShowPortlet/dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,18 @@ Abort("Possible recursive dashboard detected.") if $Depth > 8;

<%perl>
local $session{CurrentUser} = $session{ContextUser};

$m->callback(CallbackName => 'BeforePanes', Dashboard => $current_dashboard,
HasResults => $HasResults, Portlet => $Portlet, ARGSRef => \%ARGS);

for my $portlet (@panes) {

my $skip_processing = 0;
$m->callback(CallbackName => 'BeforeComponent', Dashboard => $current_dashboard,
HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS,
SkipProcessing => \$skip_processing);
last if $skip_processing;

$m->comp($portlet->{portlet_type},
Portlet => $portlet,
Rows => $Rows,
Expand All @@ -86,6 +97,10 @@ for my $portlet (@panes) {
Depth => $Depth + 1,
HasResults => $HasResults
);

$m->callback(CallbackName => 'AfterComponent', Dashboard => $current_dashboard,
HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS);

}
</%perl>

0 comments on commit 3151ba1

Please sign in to comment.