Skip to content

Commit

Permalink
Fix reports order saving
Browse files Browse the repository at this point in the history
Using the 'Update this menu' option under the Reports menu or
'Modify Reports menu' from global or a user admin page previously failed
to preserve the order of reports.

This issue stemmed from an incorrect loop iterating over report
components rather than the selected reports.
  • Loading branch information
richieri-bps committed May 13, 2024
1 parent d095c61 commit 7839f1a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 9 additions & 4 deletions share/html/Admin/Global/DashboardsInMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@
else {
my $report_names = ref $ARGS{'report'} eq 'ARRAY' ? $ARGS{'report'} : [$ARGS{'report'}];
my @ret;
foreach my $report ( @report_components ) {
last unless $report_names->[0];

push @ret, $report if grep { $_ =~ /report-$report->{'name'}/ } @{$report_names};
if ( $report_names->[0] ) {
foreach my $report ( @$report_names ) {
foreach my $report_component ( @report_components ) {
if ( $report eq "report-".$report_component->{'name'} ) {
push @ret, $report_component;
last;
}
}
}
}
my ( $ok, $msg );
if ( $reports_attr ) {
Expand Down
13 changes: 9 additions & 4 deletions share/html/Admin/Users/DashboardsInMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,15 @@
else {
my $report_names = ref $ARGS{'report'} eq 'ARRAY' ? $ARGS{'report'} : [$ARGS{'report'}];
my @ret;
foreach my $report ( @report_components ) {
last unless $report_names->[0];

push @ret, $report if grep { $_ =~ /report-$report->{'name'}/ } @{$report_names};
if ( $report_names->[0] ) {
foreach my $report ( @$report_names ) {
foreach my $report_component ( @report_components ) {
if ( $report eq "report-".$report_component->{'name'} ) {
push @ret, $report_component;
last;
}
}
}
}

my ( $ok, $msg ) = $UserObj->SetPreferences( $ARGS{'dashboard_id'}, \@ret );
Expand Down
14 changes: 9 additions & 5 deletions share/html/Prefs/DashboardsInMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@
else {
my $report_names = ref $ARGS{'report'} eq 'ARRAY' ? $ARGS{'report'} : [$ARGS{'report'}];
my @ret;
foreach my $report ( @report_components ) {
last unless $report_names->[0];

push @ret, $report if grep { $_ =~ /report-$report->{'name'}/ } @{$report_names};
if ( $report_names->[0] ) {
foreach my $report (@$report_names) {
foreach my $report_component (@report_components) {
if ( $report eq "report-" . $report_component->{'name'} ) {
push @ret, $report_component;
last;
}
}
}
}

my ( $ok, $msg ) = $user->SetPreferences( $ARGS{'dashboard_id'}, \@ret );
push @results, $ok ? loc('Preferences saved for reports in menu.') : $msg;
delete $session{'reports_in_menu'};
Expand Down

0 comments on commit 7839f1a

Please sign in to comment.