%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2021 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /Elements/Header, Title => $title &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &> <& /Widgets/SearchSelection, pane_name => \%pane_name, sections => \@sections, selected => \%selected, filters => \@filters, &> <& /Elements/Submit, Name => "UpdateSearches", Label => loc('Save') &> <&|/Widgets/TitleBox, title => loc('Options'), bodyclass => "", class => "mx-auto max-width-lg" &>
<&|/l&>Rows per box:
<&|/Widgets/TitleBox, title => loc("Reset RT at a glance"), class => "mx-auto max-width-lg" &> <%INIT> my @results; my $title = loc("Customize").' '.loc("RT at a glance"); my $user = $session{'CurrentUser'}->UserObj; if ( $ARGS{'UpdateSummaryRows'} ) { unless ( $ARGS{SummaryRows} && int $ARGS{SummaryRows} > 0 ) { push @results, loc ("Illegal '[_1]' preference value.", loc('summary rows')); $ARGS{SummaryRows} = 0; } else { my ($ok, $msg) = $user->SetPreferences( 'SummaryRows', int $ARGS{SummaryRows} ); push @results, $ok ? loc('Preferences saved for [_1].', loc('summary rows')) : $msg; } } $ARGS{'SummaryRows'} ||= $user->Preferences('SummaryRows', RT->Config->Get('DefaultSummaryRows')); if ($ARGS{Reset}) { for my $pref_name ('HomepageSettings', 'SummaryRows') { next unless $user->Preferences($pref_name); my ($ok, $msg) = $user->DeletePreferences($pref_name); push @results, $msg unless $ok; } push @results, loc('Preferences saved.') unless @results; } my $portlets = $user->Preferences('HomepageSettings'); unless ($portlets) { my ($defaults) = RT::System->new($session{'CurrentUser'})->Attributes->Named('HomepageSettings'); $portlets = $defaults ? $defaults->Content : {}; } my @sections; my %item_for; my @components = map { type => "component", name => $_, label => loc($_) }, @{RT->Config->Get('HomepageComponents')}; $item_for{ $_->{type} }{ $_->{name} } = $_ for @components; push @sections, { id => 'components', label => loc("Components"), items => \@components, }; my $sys = RT::System->new($session{'CurrentUser'}); my @objs = ($sys); push @objs, RT::SavedSearch->new( $session{CurrentUser} )->ObjectsForLoading if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch', Object => $RT::System ); for my $object (@objs) { my @items; my $object_id = ref($object) . '-' . $object->Id; for ($m->comp("/Search/Elements/SearchesForObject", Object => $object)) { my ($desc, $loc_desc, $search) = @$_; my $SearchType = 'Ticket'; if ((ref($search->Content)||'') eq 'HASH') { $SearchType = $search->Content->{'SearchType'} if $search->Content->{'SearchType'}; } else { $RT::Logger->debug("Search ".$search->id." ($desc) appears to have no Content"); } my $item; if ($object eq $sys && $SearchType eq 'Ticket') { $item = { type => 'system', name => $desc, label => $loc_desc }; } else { my $oid = $object_id.'-SavedSearch-'.$search->Id; $item = { type => 'saved', name => $oid, search_type => $SearchType, label => $loc_desc }; } $item_for{ $item->{type} }{ $item->{name} } = $item; push @items, $item; } my $label = $object eq $sys ? loc('System') : $object->isa('RT::Group') ? $object->Label : $object->Name; push @sections, { id => $object_id, label => $label, items => [ sort { lc($a->{label}) cmp lc($b->{label}) } @items ], }; } my %selected; for my $pane (keys %$portlets) { my @items; for my $saved (@{ $portlets->{$pane} }) { my $item = $item_for{ $saved->{type} }{ $saved->{name} }; if ($item) { push @items, $item; } else { push @results, loc('Unable to find [_1] [_2]', $saved->{type}, $saved->{name}); } } $selected{$pane} = \@items; } my %pane_name = ( 'body' => loc('Body'), 'sidebar' => loc('Sidebar'), ); my @filters = ( [ 'component' => loc('Components') ], [ 'ticket' => loc('Tickets') ], [ 'chart' => loc('Charts') ], ); $m->callback( CallbackName => 'Default', pane_name => \%pane_name, sections => \@sections, selected => \%selected, filters => \@filters, ); if ($ARGS{UpdateSearches}) { my ($ok, $msg) = UpdateDashboard( \%ARGS, \%item_for ); push @results, $ok ? loc('Preferences saved.') : $msg; MaybeRedirectForResults( Actions => \@results, Path => "/Prefs/MyRT.html", ); }