@@ -686,6 +686,66 @@ push @ACL, (
686686 },
687687);
688688
689+ # Predefined searches
690+
691+ @SavedSearches = (
692+ { Name => 'New unlinked Incident Reports',
693+ Description => 'New unlinked Incident Reports', # loc
694+ ExtraQueryParams => 'RTIR',
695+ Format => q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#',}.
696+ q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject',}.
697+ q{Requestors,OwnerName,DueRelative,QueueName,Take},
698+ Order => 'ASC|ASC|ASC|ASC',
699+ OrderBy => 'Due',
700+ Query => 'Lifecycle = \'incident_reports\' AND Status = \'new\'',
701+ RTIR => '1',
702+ RTIRSearchEnabled => 'Yes',
703+ RowsPerPage => '10'
704+ },
705+ { Name => 'My most due incidents',
706+ Description => 'Most due incidents owned by [_1]', # loc
707+ ExtraQueryParams => 'RTIR',
708+ Format => q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#\',}.
709+ q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject\',}.
710+ q{DueRelative, OwnerName, __Priority__,}.
711+ q{'UnreadMessages/TITLE:Updates\''},
712+ Order => 'ASC|DESC|ASC|ASC',
713+ OrderBy => 'Due|Priority',
714+ Query => 'Lifecycle = \'incidents\' AND Status = \'__Active__\' AND Owner = \'__CurrentUser__\'',
715+ RTIR => '1',
716+ RTIRSearchEnabled => 'Yes',
717+ RowsPerPage => '10'
718+ },
719+ { Name => 'Most due unowned incidents',
720+ Description => 'Most due unowned incidents', # loc
721+ ExtraQueryParams => 'RTIR',
722+ Format => q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#\',}
723+ . q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject\',}
724+ . q{DueRelative, OwnerName, __Priority__,}
725+ . q{'UnreadMessages/TITLE:Updates\''},
726+ Order => 'ASC|DESC|ASC|ASC',
727+ OrderBy => 'Due|Priority',
728+ Query => 'Lifecycle = \'incidents\' AND Status = \'__Active__\' AND Owner = \'Nobody\'',
729+ RTIR => '1',
730+ RTIRSearchEnabled => 'Yes',
731+ RowsPerPage => '10'
732+ },
733+ { Name => 'Most due incidents',
734+ Description => 'Most due incidents', # loc
735+ ExtraQueryParams => 'RTIR',
736+ Format => q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#\',}.
737+ q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject\',}.
738+ q{DueRelative, OwnerName, __Priority__,}.
739+ q{'UnreadMessages/TITLE:Updates\''},
740+ Order => 'ASC|DESC|ASC|ASC',
741+ OrderBy => 'Due|Priority',
742+ Query => 'Lifecycle = \'incidents\' AND Status = \'__Active__\'',
743+ RTIR => '1',
744+ RTIRSearchEnabled => 'Yes',
745+ RowsPerPage => '10'
746+ },
747+ );
748+
689749for my $cf (@CustomFields) {
690750 push @ACL,
691751 (
@@ -786,63 +846,6 @@ for my $cf (@CustomFields) {
786846 }
787847);
788848
789- @Dashboards = (
790- {
791- Name => 'RTIR Homepage',
792- Description => 'RTIR Homepage',
793- Content => {
794- Elements => [
795- {
796- Layout => 'col-md-8,col-md-4',
797- Elements => [
798- [
799- {
800- portlet_type => 'component',
801- component => '/RTIR/Elements/NewReports',
802- description => '/RTIR/Elements/NewReports',
803- path => '/RTIR/Elements/NewReports',
804- },
805- {
806- portlet_type => 'component',
807- component => '/RTIR/Elements/UserDueIncidents',
808- description => '/RTIR/Elements/UserDueIncidents',
809- path => '/RTIR/Elements/UserDueIncidents',
810- },
811- {
812- portlet_type => 'component',
813- component => '/RTIR/Elements/NobodyDueIncidents',
814- description => '/RTIR/Elements/NobodyDueIncidents',
815- path => '/RTIR/Elements/NobodyDueIncidents',
816- },
817- {
818- portlet_type => 'component',
819- component => '/RTIR/Elements/DueIncidents',
820- description => '/RTIR/Elements/DueIncidents',
821- path => '/RTIR/Elements/DueIncidents',
822- },
823- ],
824- [
825- {
826- portlet_type => 'component',
827- component => '/RTIR/Elements/WorkWithConstituency',
828- description => '/RTIR/Elements/WorkWithConstituency',
829- path => '/RTIR/Elements/WorkWithConstituency',
830- },
831- {
832- portlet_type => 'component',
833- component => '/RTIR/Elements/QueueSummary',
834- description => '/RTIR/Elements/QueueSummary',
835- path => '/RTIR/Elements/QueueSummary',
836- },
837- ]
838- ],
839- }
840- ],
841- },
842- }
843- );
844-
845-
846849@Final = (
847850 sub {
848851 $| = 1;
@@ -901,8 +904,80 @@ for my $cf (@CustomFields) {
901904
902905 },
903906 sub {
907+ # The last 4 saved searches should be the ones added above.
908+ # Don't load by name since there could be other existing searches with
909+ # these names.
910+ my ($new_reports, $user_incidents, $nobody_incidents, $due_incidents);
911+ my $saved_searches = RT::SavedSearches->new(RT->SystemUser);
912+ $saved_searches->UnLimit;
913+ $due_incidents = $saved_searches->Last;
914+
915+ my $new_reports = RT::SavedSearch->new(RT->SystemUser);
916+ $new_reports->Load( $due_incidents->Id - 3 );
917+
918+ my $user_incidents = RT::SavedSearch->new(RT->SystemUser);
919+ $user_incidents->Load( $due_incidents->Id - 2 );
920+
921+ my $nobody_incidents = RT::SavedSearch->new(RT->SystemUser);
922+ $nobody_incidents->Load( $due_incidents->Id - 1 );
923+
924+ my $rtir_dashboard = {
925+ Elements => [
926+ {
927+ Layout => 'col-md-8,col-md-4',
928+ Elements => [
929+ [
930+ {
931+ portlet_type => 'search',
932+ id => $new_reports->Id,
933+ description => 'Ticket: ' . $new_reports->Description,
934+ },
935+ {
936+ portlet_type => 'search',
937+ id => $user_incidents->Id,
938+ description => 'Ticket: ' . $user_incidents->Description,
939+ },
940+ {
941+ portlet_type => 'search',
942+ id => $nobody_incidents->Id,
943+ description => 'Ticket: ' . $nobody_incidents->Description,
944+ },
945+ {
946+ portlet_type => 'search',
947+ id => $due_incidents->Id,
948+ description => 'Ticket: ' . $due_incidents->Description,
949+ },
950+ ],
951+ [
952+ {
953+ portlet_type => 'component',
954+ component => '/RTIR/Elements/WorkWithConstituency',
955+ description => '/RTIR/Elements/WorkWithConstituency',
956+ path => '/RTIR/Elements/WorkWithConstituency',
957+ },
958+ {
959+ portlet_type => 'component',
960+ component => '/RTIR/Elements/QueueSummary',
961+ description => '/RTIR/Elements/QueueSummary',
962+ path => '/RTIR/Elements/QueueSummary',
963+ },
964+ ]
965+ ],
966+ }
967+ ],
968+ };
969+
904970 my $dashboard = RT::Dashboard->new( RT->SystemUser );
905- my ( $ret, $msg ) = $dashboard->LoadByCols( Name => 'RTIR Homepage' );
971+ my ( $ret, $msg ) = $dashboard->Create(
972+ Name => 'RTIRDefaultDashboard',
973+ Description => 'RTIR Default Dashboard',
974+ PrincipalId => RT->SystemUser->PrincipalId,
975+ Content => $rtir_dashboard,
976+ );
977+
978+ if ( !$ret ) {
979+ RT->Logger->error("Couldn't create RTIRDefaultDashboard: $msg");
980+ }
906981
907982 if ( $ret ) {
908983 ( $ret, $msg ) = RT->System->SetAttribute(
@@ -914,9 +989,6 @@ for my $cf (@CustomFields) {
914989 RT->Logger->error("Couldn't set RTIRDefaultDashboard: $msg");
915990 }
916991 }
917- else {
918- RT->Logger->error("Couldn't load dashboard RTIR Homepage: $msg");
919- }
920992 },
921993 sub {
922994 my $class = RT::Class->new( RT->SystemUser );
0 commit comments