[Rt-commit] r7954 - in rtir/branches/2.3-EXPERIMENTAL: . html/RTIR/Elements

jesse at bestpractical.com jesse at bestpractical.com
Tue May 29 15:34:33 EDT 2007


Author: jesse
Date: Tue May 29 15:34:32 2007
New Revision: 7954

Added:
   rtir/branches/2.3-EXPERIMENTAL/html/Callbacks/RTIR/Elements/EditCustomField/
   rtir/branches/2.3-EXPERIMENTAL/html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/EditConstituency
Modified:
   rtir/branches/2.3-EXPERIMENTAL/   (props changed)

Log:
 r57751 at pinglin:  jesse | 2007-05-29 15:18:26 -0400
 * Switch to rendering the constituency with a custom field that skips constituencies you can't see


Added: rtir/branches/2.3-EXPERIMENTAL/html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName	Tue May 29 15:34:32 2007
@@ -0,0 +1,10 @@
+<%init>
+return unless ($CustomField->Name eq '_RTIR_Constituency');
+$$Name = '/RTIR/Elements/EditConstituency';
+
+</%init>
+<%args>
+$Name
+$CustomField
+$Object
+</%args>

Added: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/EditConstituency
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/EditConstituency	Tue May 29 15:34:32 2007
@@ -0,0 +1,136 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%#  
+%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
+%#                                          <jesse at bestpractical.com>
+%# 
+%# (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/copyleft/gpl.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 }}}
+%# Build up the set of cascading select boxes as "guides"
+%# each one limits the options of the final one a bit
+%# (perhaps by tweaking the .display style?)
+%       my $selected = 0;
+%       my @category;
+%       my $id = $NamePrefix . $CustomField->Id;
+%       my $out = $m->scomp('SELF:options', %ARGS, SelectedRef => \$selected, CategoryRef => \@category, Object => $Object);
+%       if (@category) {
+<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/cascaded.js"></script>
+%#      XXX - Hide this select from w3m?
+      <select onchange="filter_cascade('<% $id %>-Values', this.value)" name="<% $id %>-Category">
+        <option value="" <% !$selected && 'selected' %>><&|/l&>-</&></option>
+%           foreach my $cat (@category) {
+%               my ($depth, $name) = @$cat;
+        <option value="<% $name %>"><% '&nbsp;' x $depth |n %><% $name %></option>
+%           }
+      </select><br />
+%       }
+      <select name="<%$id%>-Values" id="<%$id%>-Values"
+%       if ( $Rows && ( $Multiple || !@category ) ) {
+        size="<% $Rows %>"
+%       }
+        <% $Multiple && 'multiple' %> >
+%       $m->out($out);
+      </select>
+<%ARGS>
+$Object => undef
+$CustomField => undef
+$NamePrefix => undef
+$Default => undef
+$Values => undef
+$Multiple => 0
+$Rows => undef
+</%ARGS>
+
+<%METHOD options>
+% my $selected;
+% my $CFVs = $CustomField->Values;
+% my @levels;
+% my $main_queue = RT::Queue->new($session{'CurrentUser'});
+% $main_queue->LoadByCols(Name => 'Incidents');
+% my $show_all = 0;
+% if ($main_queue->CurrentUserHasRight('OwnTicket')) {
+% $show_all = 1;
+% }
+
+% while ( my $value = $CFVs->Next ) {
+%       my $name = $value->Name;
+% my $subqueue = RT::Queue->new($session{'CurrentUser'});
+%  next unless ($show_all || ($subqueue->LoadByCols(Name => $main_queue->Name . " - ".$name) && $subqueue->id && $subqueue->CurrentUserHasRight('OwnTicket')));
+%       my $category = $value->Category || '';
+%       my $level = (split /:/, $category, 2)[0] || '';
+%       while (@levels) {
+%           if ($levels[-1] eq $level) {
+%               $level = '';
+%               last;
+%           } elsif (index($level, $levels[-1]) != 0) {
+%               $m->out('</optgroup>');
+%               pop @levels;
+%           } else {
+%               last;
+%           }
+%       }
+%       if ( length $level ) {
+%           push @$CategoryRef, [0+ at levels, $level];
+            <optgroup style="padding-left: <% @levels/2 %>em" label="<% $category %>">
+%           push @levels, $level;
+%       }
+        <option value="<% $name %>"
+%       if ( grep( ( $_ || '') eq ( $name || '') , @Default )
+%            || ( $Values && $Values->HasEntry( $name ) ) )
+%       {
+%           $$SelectedRef = 1;
+            selected
+%       }
+        ><% $name %></option>
+% }
+% for (@levels) {
+            </optgroup>
+% }
+<%ARGS>
+$CustomField => undef
+ at Default => ()
+$Values => undef
+$SelectedRef => undef
+$CategoryRef => undef
+$Object => undef
+</%ARGS>
+</%METHOD>


More information about the Rt-commit mailing list