[Rt-commit] r4211 - in rtir/branches/1.9-EXPERIMENTAL: . etc
html/RTIR html/RTIR/Elements html/RTIR/Prefs
ruz at bestpractical.com
ruz at bestpractical.com
Thu Dec 1 15:21:49 EST 2005
Author: ruz
Date: Thu Dec 1 15:21:49 2005
New Revision: 4211
Added:
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Prefs/
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Prefs/Home.html
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm
rtir/branches/1.9-EXPERIMENTAL/etc/initialdata
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/DueIncidents
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Tabs
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/index.html
Log:
r384 at cubic-pc: cubic | 2005-12-01 23:23:18 +0300
r380 at cubic-pc: cubic | 2005-12-01 22:54:58 +0300
Customzable RTIR homepage
* new config option $RTIR_HomepageComponents
* the default initial data for homepage layout
* remove debug statements
* new tab 'Preferences' without subtabs yet
* home page is based on the portlets feature
Modified: rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/etc/RTIR_Config.pm Thu Dec 1 15:21:49 2005
@@ -237,4 +237,12 @@
# on the edit screen.
Set($DisplayAfterEdit, 1);
+# Components that available to add on the first page of the RTIR
+Set($RTIR_HomepageComponents, [qw(
+ /RTIR/Elements/NewReports
+ /RTIR/Elements/UserDueIncidents
+ /RTIR/Elements/DueIncidents
+ RefreshHomepage
+)]);
+
1;
Modified: rtir/branches/1.9-EXPERIMENTAL/etc/initialdata
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/etc/initialdata (original)
+++ rtir/branches/1.9-EXPERIMENTAL/etc/initialdata Thu Dec 1 15:21:49 2005
@@ -832,3 +832,18 @@
Queue => 'Blocks',
Right => 'ReplyToTicket', },
);
+
+ at Attributes = ( {
+ Name => 'RTIR_HomepageSettings',
+ Description => 'RTIR homepage settings',
+ Content => {
+ body => [
+ { type => 'component', name => '/RTIR/Elements/NewReports' },
+ { type => 'component', name => '/RTIR/Elements/UserDueIncidents' },
+ { type => 'component', name => '/RTIR/Elements/DueIncidents' },
+ ],
+ summary => [
+ { type => 'component', name => 'RefreshHomepage' },
+ ]
+ },
+} );
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/DueIncidents
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/DueIncidents (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/DueIncidents Thu Dec 1 15:21:49 2005
@@ -39,7 +39,7 @@
$Query .= " AND ". $m->comp( '/RTIR/Elements/NewQuery', Queue => 'Incidents' );
$Query .= " AND $ARGS{Query}" if $ARGS{'Query'};
-use Data::Dumper;
-$RT::Logger->crit( Dumper(\%ARGS) );
-$RT::Logger->crit( $Query );
</%INIT>
+<%ATTR>
+Description => loc('Due Incidents')
+</%ATTR>
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Tabs
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Tabs (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Tabs Thu Dec 1 15:21:49 2005
@@ -50,6 +50,8 @@
path => 'RTIR/Search/Results.html?Queue=Blocks' },
G => { title => loc('Tools'),
path => 'RTIR/Tools/Lookup.html' },
+ H => { title => loc('Preferences'),
+ path => 'RTIR/Prefs/Home.html' },
};
my $topactions = {
Added: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Prefs/Home.html
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Prefs/Home.html Thu Dec 1 15:21:49 2005
@@ -0,0 +1,89 @@
+<& /Elements/Header, Title => $title &>
+<& /RTIR/Elements/Tabs, current_toptab => 'RTIR/Prefs/Home.html', Title => $title &>
+<& /Elements/ListActions, actions => \@results &>
+
+<& /Widgets/SelectionBox:header, nojs => 1 &>
+% foreach my $box( @boxes ) {
+<&|/Widgets/TitleBox,
+ title => loc('RT at a glance') .': '. loc( $box->{Name} ),
+ bodyclass => ""
+&>
+<& /Widgets/SelectionBox:show, self => $box, nojs => 1 &>
+</&>
+% }
+
+<%INIT>
+# XXX: copy&past of the similar RT's page
+
+my @results;
+my $title = loc("Customize '[_1]'", loc("RTIR home page") );
+my $user = $session{'CurrentUser'}->UserObj;
+
+unless (exists $session{'my_rtir_portlets'}) {
+ my ($d_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('RTIR_HomepageSettings');
+ $session{'my_rtir_portlets'} = $user->Preferences('RTIR_HomepageSettings', $d_portlets->Content);
+}
+my $portlets = $session{'my_rtir_portlets'};
+
+my %seen;
+
+my @items;
+foreach my $comp ( grep !$seen{$_}++, @$RT::RTIR_HomepageComponents ) {
+ use Data::Dumper;
+ #$RT::Logger->error( Dumper($comp, $m->fetch_comp($comp)) );
+ my $desc;
+ my $obj = $m->fetch_comp($comp);
+ $desc = $obj->attr_if_exists('Description') if $obj;
+ unless( $desc ) {
+ $desc = $comp;
+ $desc =~ s/^.*\///;
+ }
+ push @items, ["component-$comp", $desc];
+}
+
+my @sys_searches;
+my @searches = $m->comp( "/Search/Elements/UserSearches" );
+foreach my $s( @searches ) {
+ #XXX: get rid of this exception
+ if ( $s->{'Type'} eq 'system' ) {
+ push @items, ["system-".$s->{'Description'}, $s->{'Description'} ];
+ push @sys_searches, [ $s->{'Description'}, $s->{'Search'} ];
+ }
+ else {
+ my $oid = join '-', ref $s->{'Object'},
+ $s->{'Object'}->Id,
+ 'SavedSearch',
+ $s->{'Search'};
+ push @items, [ "saved-$oid", loc("Saved Search: [_1]", $s->{'Description'}) ];
+ }
+}
+
+use Data::Dumper;
+$RT::Logger->error( Dumper( \@items ) );
+
+my @boxes;
+foreach my $pane ( sort keys %$portlets ) {
+ push @boxes,
+ $m->comp(
+ '/Widgets/SelectionBox:new',
+ Action => 'Home.html',
+ Name => $pane,
+ Available => \@items,
+ AutoSave => 1,
+ OnSubmit => sub {
+ my $self = shift;
+ $portlets->{$pane} = [
+ map { m/(\w+)-(.*)$}/; { type => $1, name => $2, }}
+ @{$self->{Current}}
+ ];
+ $user->SetPreferences('RTIR_HomepageSettings', $portlets);
+ push @results, loc ('Preferences saved for [_1].', $pane);
+ delete $session{'my_rtir_portlets'};
+ },
+ Selected => [ map { join '-', @{$_}{qw/type name/} } @{ $portlets->{$pane} } ]
+ );
+}
+
+$m->comp ('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1) for @boxes;
+
+</%INIT>
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/index.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/index.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/index.html Thu Dec 1 15:21:49 2005
@@ -28,17 +28,17 @@
current_toptab => 'RTIR/index.html' &>
<& /Elements/ListActions, actions => \@results &>
-<& /Elements/MyRT, Portlets => {
- body => [
- { type => 'component', name => '/RTIR/Elements/NewReports' },
- { type => 'component', name => '/RTIR/Elements/UserDueIncidents' },
- { type => 'component', name => '/RTIR/Elements/DueIncidents' },
- ],
- summary => [
- { type => 'component', name => '/Elements/RefreshHomepage' },
- ],
-} &>
+<& /Elements/MyRT, Portlets => $portlets &>
<%INIT>
+
+# XXX: this should be automated!!!
+unless (exists $session{'my_rtir_portlets'}) {
+ my ($d_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('RTIR_HomepageSettings');
+ $session{'my_rtir_portlets'} = $session{'CurrentUser'}->UserObj->Preferences('RTIR_HomepageSettings', $d_portlets->Content);
+}
+my $portlets = $session{'my_rtir_portlets'};
+
+
if ( $ARGS{'q'} ) {
my $query = $ARGS{'q'};
More information about the Rt-commit
mailing list