[Rt-commit] [rtir] 02/02: A first pass at a constituency selector on the RTIR homepage

Jesse Vincent jesse at bestpractical.com
Mon Mar 9 06:16:29 EDT 2015


This is an automated email from the git hooks/post-receive script.

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit 17e660a20fe522a1473a9e1a7158f8462465d44b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sat Mar 7 17:45:09 2015 -0800

    A first pass at a constituency selector on the RTIR homepage
    
    This commit adds a constituency selector on the RTIR homepage
    as well, as code to handle URL rewriting to include the constituency
    for many basic parts of RTIR.
---
 html/RTIR/Elements/WorkWithConstituency | 23 +++++++++++++++++++++++
 html/RTIR/c/dhandler                    | 15 +++++++++++++++
 html/RTIR/index.html                    |  2 ++
 lib/RT/IR.pm                            | 12 ++++++++++--
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/html/RTIR/Elements/WorkWithConstituency b/html/RTIR/Elements/WorkWithConstituency
new file mode 100644
index 0000000..b718936
--- /dev/null
+++ b/html/RTIR/Elements/WorkWithConstituency
@@ -0,0 +1,23 @@
+<&| /Widgets/TitleBox, title => 'Work with constituency' &>
+<ul>
+% for my $constituency (keys %known_constituencies) {
+<li><a href="<% RT::IR->HREFTo('', Constituency => $constituency)%>"><%$constituency%></a></li>
+% }
+</ul>
+</&>
+<%init>
+my %known_constituencies;
+my $queues = RT::Queues->new($session{'CurrentUser'});
+for my $lifecycle (RT::IR->Lifecycles) {
+    $queues->Limit(FIELD => 'Lifecycle', VALUE => $lifecycle, ENTRYAGGREGATOR =>'OR');
+}
+
+# This list is already filtered by queues the user can see
+for my $queue (@{$queues->ItemsArrayRef}) {
+    my $c = $queue->FirstCustomFieldValue('RTIR Constituency');
+    next unless $c;
+   $known_constituencies{$c }++;  
+}
+# XXX TODO Caching
+# XXX TODO pull the current default
+</%init>
\ No newline at end of file
diff --git a/html/RTIR/c/dhandler b/html/RTIR/c/dhandler
new file mode 100644
index 0000000..bba5428
--- /dev/null
+++ b/html/RTIR/c/dhandler
@@ -0,0 +1,15 @@
+<%init>
+my @uri = split("/",$m->dhandler_arg);
+my $constituency= shift @uri;
+$m->{'RTIR_ConstituencyFilter'} = $constituency;
+my $path = join("/",'','RTIR', at uri);
+    $path =~ s!/$!!;
+    if (   !$m->interp->comp_exists( $path )
+         && $m->interp->comp_exists( $path . "/index.html" ) )
+    {
+        $path= $path . "/index.html";
+    }
+
+
+return $m->comp($path, %ARGS);
+</%init>
\ No newline at end of file
diff --git a/html/RTIR/index.html b/html/RTIR/index.html
index 2325bc3..e0d7ba9 100644
--- a/html/RTIR/index.html
+++ b/html/RTIR/index.html
@@ -49,6 +49,8 @@
 <& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@results &>
 <& /Elements/MyRT, Portlets => $portlets &>
+
+<& /RTIR/Elements/WorkWithConstituency &>
 <%INIT>
 
 # XXX: this should be automated!!!
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 2c45c6e..c867d0c 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -754,8 +754,16 @@ XXX TODO this wants a better name.
 sub HREFTo {
     my $self = shift;
     my $page = shift;
-
-    return RT->Config->Get('WebPath') .'/RTIR/'.$page;
+    my %args = ( Constituency => $HTML::Mason::Commands::m->{'RTIR_ConstituencyFilter'},
+                 @_); 
+    # XXX TODO - this code has a dependency on the implementation
+    # of the mason UI. It might want to be either in a web handler
+    # related namespace or to have a better abstraction
+    my $c = '';
+    if ($args{'Constituency'}) {  
+        $c = 'c/'.$args{'Constituency'}."/";
+    }
+    return RT->Config->Get('WebPath') .'/RTIR/'.$c.$page;
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list