[rt-devel] Feature Requests: Queuespecific Keyword Layout
Warnke Andreas
Andreas.Warnke at 3SOFT.de
Thu Jan 9 07:54:22 EST 2003
> D) Queuespecific but globally defined KeywordSelects
>
> The following requirement was quite troubling to me:
> When moving Tickets from one queue to another, they should keep their
> Keywords (-> So I use global Keywords) - but on the other hand there
are
> some queues (like the FAQ queue) that need only a subset of the global
> keywords. (-> So I don't display all global keywords in some queues)
- So: Here is a little HowTo for a queuespecific keyword-layout.
(Based on version 2.0.15)
First, add the desired Layout of the keyword-selects to your
config-script:
########################################## FILE: etc/config.pm
# ----------------------------------------
# added by Andreas.Warnke @3SOFT.de
# ----------------------------------------
# Layout of the Keyword Selections for the Create, Search and Modify
Forms
# Key-Syntax: *:* or QueueName:* or *:FormName or QueueName:FormName
# List-Syntax: pairs of 'HTML',HTMLCode or
'KeywordSelect',KeywordSelectName or
# 'IgnoreKeySelect',KeywordSelectName
%KeywordLayout = (
'*:*' => [
'HTML', '<TABLE BORDER="0"><TR><TD
ALIGN="right">Type</TD><TD>',
'KeywordSelect', 'Type',
'HTML', '</TD><TD ALIGN="right">Motion</TD><TD
COLSPAN="3">',
'KeywordSelect', 'Motion',
'HTML', '</TD></TR><TR><TD ALIGN="right"
VALIGN=TOP>Signals</TD><TD VALIGN=TOP>',
'KeywordSelect', 'Signals',
'HTML', '</TD><TD ALIGN="right" VALIGN=TOP>Position</TD><TD
VALIGN=TOP COLSPAN="3">',
'KeywordSelect','Position',
'HTML', '</TD></TR><TR><TD ALIGN="right">Verified</TD><TD
COLSPAN="5">',
'KeywordSelect','Verified',
'HTML', '</TD></TR></TABLE>'
],
'*:Create' => [
'HTML', '<TABLE BORDER="0"><TR><TD
ALIGN="right">Type</TD><TD>',
'KeywordSelect', 'Type',
'HTML', '</TD><TD ALIGN="right">Motion</TD><TD
COLSPAN="3">',
'KeywordSelect', 'Motion',
'HTML', '</TD></TR><TR><TD ALIGN="right"
VALIGN=TOP>Signals</TD><TD VALIGN=TOP>',
'KeywordSelect', 'Signals',
'HTML', '</TD><TD ALIGN="right" VALIGN=TOP>Position</TD><TD
VALIGN=TOP COLSPAN="3">',
'KeywordSelect','Position',
'HTML', '</TD></TR></TD></TR></TABLE>',
'IgnoreKeySelect','Verified',
],
'FAQ:*' => [
'IgnoreKeySelect','Type',
'IgnoreKeySelect','Signals',
'IgnoreKeySelect','Motion',
'IgnoreKeySelect','Position',
'IgnoreKeySelect','Verified',
],
);
# ----------------------------------------
########################################## /FILE: etc/config.pm
Then change the files that display the keyword-selections:
########################################## FILE:
webrt/Ticket/Create.html
...
%# Run the config layout script:
% my $actiontype;
% while ($actiontype = shift @LayoutScript ) {
% if ( $actiontype eq 'HTML' ) {
% print (shift @LayoutScript);
% }
% elsif ( $actiontype eq 'IgnoreKeySelect' ) {
% delete $AllSelects{shift @LayoutScript};
% }
% elsif ( $actiontype eq 'KeywordSelect' ) {
% my $KSName = shift @LayoutScript;
% if ( defined $AllSelects{$KSName}) {
% my ($KSID,$KSSingle,$Descendents) = @{delete
$AllSelects{$KSName}};
<INPUT TYPE="hidden" NAME="KeywordSelectMagic<% $KSID %>"
VALUE="1">
% # Popup Menus if single selects, checkboxes if multiple:
% if ($KSSingle) {
<SELECT NAME="KeywordSelect-<% $KSID %>" SIZE=1">
% foreach my $kid ( keys %{$Descendents} ) {
<OPTION VALUE="<% $kid %>"><% $Descendents->{$kid}
%></OPTION>
% }
<OPTION VALUE="" SELECTED>(empty)</OPTION>
</SELECT>
% }
% else {
<DIV>
% foreach my $kid ( keys %{$Descendents} ) {
<DIV>
<INPUT TYPE="checkbox" NAME="KeywordSelect-<% $KSID %>"
VALUE="<% $kid %>" /><% $Descendents->{$kid} %>
</DIV>
% }
</DIV>
% }
% }
% }
% else {shift @LayoutScript;}
% }
%# Display the keywords that are not yet handled:
<TABLE BORDER=0>
% foreach my $KSName (keys %AllSelects) {
% my ($KSID,$KSSingle,$Descendents) = @{$AllSelects{$KSName}};
<TR><TD ALIGN=RIGHT>
<% $KSName %></TD><TD>
<INPUT TYPE="hidden" NAME="KeywordSelectMagic<% $KSID %>"
VALUE="1">
%# Popup Menus if single selects, checkboxes if multiple:
% if ($KSSingle) {
<SELECT NAME="KeywordSelect-<% $KSID %>" SIZE=1">
% foreach my $kid ( keys %{$Descendents} ) {
<OPTION VALUE="<% $kid %>"><% $Descendents->{$kid}
%></OPTION>
% }
<OPTION VALUE="" SELECTED>(empty)</OPTION>
</SELECT>
% }
% else {
<DIV>
% foreach my $kid ( keys %{$Descendents} ) {
<DIV>
<INPUT TYPE="checkbox" NAME="KeywordSelect-<% $KSID %>"
VALUE="<% $kid %>" /><% $Descendents->{$kid} %>
</DIV>
% }
</DIV>
% }
</TD></TR>
% }
</TABLE>
<& /Elements/TitleBoxEnd &>
<BR>
<& /Elements/Submit, Label => "Create"&>
</FORM>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<%INIT>
my $QueueObj = new RT::Queue($session{'CurrentUser'});
$QueueObj->Load($Queue) || Abort("Queue could not be loaded.");
my $KeywordSelects = $QueueObj->KeywordSelects;
# Get all Keyword selects from the Database:
my %AllSelects = ();
while ( my $KeywordSelect = $KeywordSelects->Next ) {
my $KSDescendentsRef = $KeywordSelect->KeywordObj->Descendents;
my $KSName = $KeywordSelect->Name;
my $KSID = $KeywordSelect->id;
my $KSSingle = $KeywordSelect->Single;
$AllSelects{$KSName}=[($KSID,$KSSingle,$KSDescendentsRef)];
}
# Find the appropriate config.pm Layout script:
my @LayoutScript = ();
if (exists $RT::KeywordLayout{$QueueObj->Name.':Create'}) {
@LayoutScript=@{$RT::KeywordLayout{$QueueObj->Name.':Create'}};}
elsif (exists $RT::KeywordLayout{$QueueObj->Name.':*'}) {
@LayoutScript=@{$RT::KeywordLayout{$QueueObj->Name.':*'}};}
elsif (exists $RT::KeywordLayout{'*:Create'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:Create'}};}
elsif (exists $RT::KeywordLayout{'*:*'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:*'}};}
# ----------------------------------------
</%INIT>
...
########################################## FILE:
webrt/Ticket/Elements/EditKeywordSelects
%# ----------------------------------------
%# modified by andreas warnke @3SOFT.de
%# ----------------------------------------
%# Run the config layout script:
% my $actiontype;
% while ($actiontype = shift @LayoutScript ) {
% if ( $actiontype eq 'HTML' ) {
% print (shift @LayoutScript);
% }
% elsif ( $actiontype eq 'IgnoreKeySelect' ) {
% delete $AllSelects{shift @LayoutScript};
% }
% elsif ( $actiontype eq 'KeywordSelect' ) {
% my $KSName = shift @LayoutScript;
% if ( defined $AllSelects{$KSName}) {
% my ($KSID,$KSSingle,$Descendents) = @{delete
$AllSelects{$KSName}};
% my $selected_keywords = 0;
% my $CurrentKeywords = $TicketObj->KeywordsObj($KSID);
<INPUT TYPE="hidden" NAME="KeywordSelectMagic<% $KSID %>"
VALUE="1">
% # Popup Menus if single selects, checkboxes if multiple:
% if ($KSSingle) {
<SELECT NAME="KeywordSelect<% $KSID %>" SIZE=1">
% foreach my $kid ( keys %{$Descendents} ) {
% my $selected = 0;
% if ($CurrentKeywords->HasEntry($kid)) {
$selected_keywords++; $selected=1;}
<OPTION VALUE="<% $kid %>" <% $selected && 'SELECTED'%>
><% $Descendents->{$kid} %></OPTION>
% }
<OPTION VALUE="" <% ($selected_keywords == 0) && 'SELECTED'
%> >(empty)</OPTION>
</SELECT>
% }
% else {
<DIV>
% foreach my $kid ( keys %{$Descendents} ) {
% my $selected = 0;
% if ($CurrentKeywords->HasEntry($kid)) { $selected=1;}
<DIV>
<INPUT TYPE="checkbox" NAME="KeywordSelect<% $KSID %>"
VALUE="<% $kid %>" <% $selected && 'CHECKED'%> /><% $Descendents->{$kid}
%>
</DIV>
% }
</DIV>
% }
% }
% }
% else {shift @LayoutScript;}
% }
%# Display the keywords that are not yet handled:
<TABLE BORDER=0>
% foreach my $KSName (keys %AllSelects) {
% my ($KSID,$KSSingle,$Descendents) = @{$AllSelects{$KSName}};
% my $CurrentKeywords = $TicketObj->KeywordsObj($KSID);
% my $selected_keywords = 0;
<TR><TD ALIGN=RIGHT>
<% $KSName %></TD><TD>
<INPUT TYPE="hidden" NAME="KeywordSelectMagic<% $KSID %>"
VALUE="1">
% # Popup Menus if single selects, checkboxes if multiple:
% if ($KSSingle) {
<SELECT NAME="KeywordSelect<% $KSID %>" SIZE=1">
% foreach my $kid ( keys %{$Descendents} ) {
% my $selected = 0;
% if ($CurrentKeywords->HasEntry($kid)) {
$selected_keywords++; $selected=1;}
<OPTION VALUE="<% $kid %>"
<% $selected && 'SELECTED'%>>
<% $Descendents->{$kid} %>
</OPTION>
% }
<OPTION VALUE="" <% ($selected_keywords == 0) && 'SELECTED' %>
>(empty)</OPTION>
</SELECT>
% }
% else {
<DIV>
% foreach my $kid ( keys %{$Descendents} ) {
% my $selected = 0;
% if ($CurrentKeywords->HasEntry($kid)) { $selected=1;}
<DIV>
<INPUT TYPE="checkbox" NAME="KeywordSelect<% $KSID %>"
VALUE="<% $kid %>" <% $selected && 'CHECKED'%> /><% $Descendents->{$kid}
%>
</DIV>
% }
</DIV>
% }
</TD></TR>
% }
</TABLE>
<%INIT>
my $KeywordSelects = $TicketObj->QueueObj->KeywordSelects;
# Get all Keyword selects from the Database:
my %AllSelects = ();
while ( my $KeywordSelect = $KeywordSelects->Next ) {
my $KSDescendentsRef = $KeywordSelect->KeywordObj->Descendents;
my $KSName = $KeywordSelect->Name;
my $KSID = $KeywordSelect->id;
my $KSSingle = $KeywordSelect->Single;
$AllSelects{$KSName}=[($KSID,$KSSingle,$KSDescendentsRef)];
}
# Find the appropriate config.pm Layout script:
my @LayoutScript = ();
if (exists $RT::KeywordLayout{$TicketObj->QueueObj->Name.':Modify'}) {
@LayoutScript=@{$RT::KeywordLayout{$TicketObj->QueueObj->Name.':Modify'}
};}
elsif (exists $RT::KeywordLayout{$TicketObj->QueueObj->Name.':*'}) {
@LayoutScript=@{$RT::KeywordLayout{$TicketObj->QueueObj->Name.':*'}};}
elsif (exists $RT::KeywordLayout{'*:Modify'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:Modify'}};}
elsif (exists $RT::KeywordLayout{'*:*'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:*'}};}
# ----------------------------------------
</%INIT>
<%ARGS>
$TicketObj => undef
</%ARGS>
########################################## FILE:
webrt/Ticket/Elements/ShowKeywordSelects
%# ----------------------------------------
%# modified by andreas warnke @3SOFT.de
%# ----------------------------------------
%# Run the config layout script:
% my $actiontype;
% while ($actiontype = shift @LayoutScript ) {
% if ( $actiontype eq 'HTML' ) {
% print (shift @LayoutScript);
% }
% elsif ( $actiontype eq 'IgnoreKeySelect' ) {
% delete $AllSelects{shift @LayoutScript};
% }
% elsif ( $actiontype eq 'KeywordSelect' ) {
% my $KSName = shift @LayoutScript;
% if ( defined $AllSelects{$KSName}) {
% my ($KSID,$KSSingle,$Descendents) = @{delete
$AllSelects{$KSName}};
% my $CurrentKeywords = $Ticket->KeywordsObj($KSID);
<ul>
% foreach my $kid ( keys %{$Descendents} ) {
% if ($CurrentKeywords->HasEntry($kid)) {
<li><% $Descendents->{$kid} %></li>
% }
% }
</ul>
% }
% }
% else {shift @LayoutScript;}
% }
%# Display the keywords that are not yet handled:
<TABLE BORDER=0>
% foreach my $KSName (keys %AllSelects) {
% my ($KSID,$KSSingle,$Descendents) = @{$AllSelects{$KSName}};
% my $CurrentKeywords = $Ticket->KeywordsObj($KSID);
% my $selected_keywords = 0;
<TR><TD ALIGN=RIGHT>
<% $KSName %></TD><TD>
<ul>
% foreach my $kid ( keys %{$Descendents} ) {
% if ($CurrentKeywords->HasEntry($kid)) {
<li><% $Descendents->{$kid} %></li>
% }
% }
</ul>
</TD></TR>
% }
</TABLE>
<%INIT>
my $KeywordSelects = $Ticket->QueueObj->KeywordSelects;
# Get all Keyword selects from the Database:
my %AllSelects = ();
while ( my $KeywordSelect = $KeywordSelects->Next ) {
my $KSDescendentsRef = $KeywordSelect->KeywordObj->Descendents;
my $KSName = $KeywordSelect->Name;
my $KSID = $KeywordSelect->id;
my $KSSingle = $KeywordSelect->Single;
$AllSelects{$KSName}=[($KSID,$KSSingle,$KSDescendentsRef)];
}
# Find the appropriate config.pm Layout script:
my @LayoutScript = ();
if (exists $RT::KeywordLayout{$Ticket->QueueObj->Name.':Display'}) {
@LayoutScript=@{$RT::KeywordLayout{$Ticket->QueueObj->Name.':Display'}};
}
elsif (exists $RT::KeywordLayout{$Ticket->QueueObj->Name.':*'}) {
@LayoutScript=@{$RT::KeywordLayout{$Ticket->QueueObj->Name.':*'}};}
elsif (exists $RT::KeywordLayout{'*:Display'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:Display'}};}
elsif (exists $RT::KeywordLayout{'*:*'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:*'}};}
# ----------------------------------------
</%INIT>
<%ARGS>
$Ticket => undef
</%ARGS>
########################################## FILE:
webrt/Search/PickRestriction
%# $Header: /pro/CVS/rt/rt-2-0-15/webrt-rtee/Search/PickRestriction,v
1.3 2002/12/11 15:49:58 anwa2219 Exp $
<FORM ACTION="Listing.html" METHOD="GET">
<INPUT TYPE=HIDDEN NAME="Bookmark" VALUE="<%
$session{'tickets'}->FreezeLimits()|u %>">
<& /Elements/TitleBoxStart, title => 'Refine Search'&>
<INPUT TYPE=HIDDEN NAME="CompileRestriction" VALUE=1>
%# ----------------------------------------
%# modified by andreas.warnke @3SOFT.de
%# ----------------------------------------
<B> <-- Add these criteria to the current search.</B>
<TABLE BORDER="0"><TR>
<TD>Owner </TD><TD> <& /Elements/SelectBoolean, Name => "OwnerOp",
TrueVal=> '=',
FalseVal => '!='
&> </TD><TD>
<& /Elements/SelectOwner, Name => "ValueOfOwner" &>
</TD></TR><TR><TD>
Requestor email address
</TD><TD><& /Elements/SelectMatch, Name => "RequestorOp" &>
</TD><TD><INPUT Name="ValueOfRequestor" SIZE=20>
</TD></TR><TR><TD>
Subject </TD><TD><& /Elements/SelectMatch, Name => "SubjectOp" &>
</TD><TD><INPUT Name="ValueOfSubject" SIZE=20>
</TD></TR><TR><TD>Queue </TD><TD> <& /Elements/SelectBoolean, Name =>
"QueueOp" ,
True => "is",
False => "isn't",
TrueVal=> '=',
FalseVal => '!=' &>
</TD><TD><& /Elements/SelectQueue, Name => "ValueOfQueue" &>
</TD></TR><TR><TD>Priority </TD><TD> <&
/Elements/SelectEqualityOperator, Name => "PriorityOp" &>
</TD><TD>
<INPUT Name="ValueOfPriority" SIZE=5>
</TD></TR><TR><TD>
<& /Elements/SelectDateType, Name => 'DateType' &>
</TD><TD><& /Elements/SelectDateRelation, Name=>"DateOp" &>
</TD><TD><& /Elements/SelectDate, Name => "ValueOfDate", ShowTime => 0,
Default => '' &>
</TD></TR><TR><TD>Ticket content
</TD><TD><& /Elements/SelectBoolean, Name => "ContentOp",
True => "matches",
False => "does not match",
TrueVal => 'LIKE',
FalseVal => 'NOT LIKE'
&>
</TD><TD><Input Name="ValueOfContent" Size=20>
</TD></TR><TR><TD>Status
</TD><TD><& /Elements/SelectBoolean, Name => "StatusOp",
True => "is",
False => "isn't",
TrueVal=> '=',
FalseVal => '!='
&>
</TD><TD><& /Elements/SelectStatus, Name => "ValueOfStatus" &>
</TD></TR></TABLE>
%# Run the config layout script:
% my $actiontype;
% while ($actiontype = shift @LayoutScript ) {
% if ( $actiontype eq 'HTML' ) {
% print (shift @LayoutScript);
% }
% elsif ( $actiontype eq 'IgnoreKeySelect' ) {
% delete $AllSelects{shift @LayoutScript};
% }
% elsif ( $actiontype eq 'KeywordSelect' ) {
% my $KSName = shift @LayoutScript;
% if ( defined $AllSelects{$KSName}) {
% my ($KSID,$KSSingle,$Descendents) = @{delete
$AllSelects{$KSName}};
<& /Elements/SelectBoolean, Name => "KeywordSelectOp". $KSID,
True => "is", False => "isn't",
TrueVal=> '=', FalseVal => '!=' &>
<SELECT NAME="KeywordSelect<%$KSID%>" SIZE="1">
<OPTION VALUE="">-</OPTION>
<OPTION VALUE="NULL">(empty)</OPTION>
% foreach my $kid ( keys %{$Descendents} ) {
<OPTION VALUE="<%$kid%>"><% $Descendents->{$kid} %></OPTION>
% }
</SELECT>
% }
% }
% else {shift @LayoutScript;}
% }
%# Display the keywords that are not yet handled:
<TABLE BORDER=0><TR><TD ALIGN="RIGHT">
% foreach my $KSName (keys %AllSelects) {
% my ($KSID,$KSSingle,$Descendents) = @{$AllSelects{$KSName}};
<TR><TD ALIGN=RIGHT>
<% $KSName %></TD><TD>
<& /Elements/SelectBoolean, Name => "KeywordSelectOp". $KSID,
True => "is", False => "isn't",
TrueVal=> '=', FalseVal => '!=' &>
</TD><TD>
<SELECT NAME="KeywordSelect<%$KSID%>" SIZE="1">
<OPTION VALUE="">-</OPTION>
<OPTION VALUE="NULL">(empty)</OPTION>
% foreach my $kid ( keys %{$Descendents} ) {
<OPTION VALUE="<%$kid%>"><% $Descendents->{$kid} %></OPTION>
% }
</SELECT>
</TD></TR>
% }
</TD></TR></TABLE>
<& /Elements/TitleBoxEnd &>
<& /Elements/TitleBoxStart, title => 'Ordering and sorting'&>
<TABLE BORDER="0"><TR><TD>
Results per page </TD><TD><& /Elements/SelectResultsPerPage, Name =>
"RowsPerPage",
Default =>
$session{'tickets_rows_per_page'} || '50'
&>
</TD></TR><TR><TD>Sort results by </TD><TD><&
/Elements/SelectTicketSortBy, Name => "TicketsSortBy",
Default =>
$session{'tickets_sort_by'}
&>
<& /Elements/SelectSortOrder, Name => 'TicketsSortOrder', Default =>
$session{'tickets_sort_order'} &>
</TD></TR><TR><TD COLSPAN="2"> <& /Elements/Refresh, Name =>
'RefreshSearchInterval' , Default =>
$session{'tickets_refresh_interval'} &>
</TD></TR></TABLE>
</DIV>
%# ----------------------------------------
<& /Elements/TitleBoxEnd &>
%# ----------------------------------------
%# modified by andreas.warnke @3SOFT.de
%# ----------------------------------------
%#<& /Elements/Submit, Label => 'Show Results', AlternateLabel =>
'Refine', Name => 'Action'&>
<& /Elements/Submit, Label => 'Show Results', Name => 'Action'&>
%# ----------------------------------------
</FORM>
<%INIT>
my $KeywordSelects = new RT::KeywordSelects $session{'CurrentUser'};
foreach ( $session{'tickets'}->RestrictionValues('Queue') ) {
$KeywordSelects->LimitToQueue($_);
}
$KeywordSelects->IncludeGlobals;
# Get all Keyword selects from the Database:
my %AllSelects = ();
while ( my $KeywordSelect = $KeywordSelects->Next ) {
my $KSDescendentsRef = $KeywordSelect->KeywordObj->Descendents;
my $KSName = $KeywordSelect->Name;
my $KSID = $KeywordSelect->id;
my $KSSingle = $KeywordSelect->Single;
$AllSelects{$KSName}=[($KSID,$KSSingle,$KSDescendentsRef)];
}
# get the queue-name:
my ($QueueName,$QueueCount) = (undef,0);
my %descrList = $session{'tickets'}->DescribeRestrictions();
foreach my $descr ( values %descrList ) {
if ( $descr =~ /^Queue = / ) {
$QueueName = substr $descr, 8;
$QueueCount ++;
}
}
# Find the appropriate config.pm Layout script:
my @LayoutScript = ();
if (exists $RT::KeywordLayout{'*:Search'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:Search'}};}
elsif (exists $RT::KeywordLayout{'*:*'}) {
@LayoutScript=@{$RT::KeywordLayout{'*:*'}};}
if ( $QueueCount == 1 ) {
if (exists $RT::KeywordLayout{$QueueName.':Search'}) {
@LayoutScript=@{$RT::KeywordLayout{$QueueName.':Search'}};}
elsif (exists $RT::KeywordLayout{$QueueName.':*'}) {
@LayoutScript=@{$RT::KeywordLayout{$QueueName.':*'}};}
}
</%INIT>
########################################## /FILE
Regards
Andi
--
Andreas Warnke
3SOFT GmbH, Frauenweiherst. 14, 91058 Erlangen
Tel.: +49-9131-7701-274 mailto:Andreas.Warnke at 3SOFT.de
Fax: +49-9131-7701-333 http://www.3SOFT.de
More information about the Rt-devel
mailing list