import rt 2.0.14
[freeside.git] / rt / webrt / Admin / KeywordSelects / index.html
1 <& /Admin/Elements/Header, Title => 'Admin KeywordSelects' &>
2 <& /Admin/Elements/Tabs, current_tab => 'Admin/KeywordSelects/' &>
3
4 A <B>KeywordSelect</B> is a link between a <B>Keyword</B> and a object
5 (currently just <B>Tickets</B>), titled by the <I>Name</I> field of the Keyword such that:
6 <ul>
7 <li>Object display will contain a field, titled with the <I>Name</I> field of
8 the <B>Keyword</B> and showing any descendent keywords.
9 <li>Object creation for this field will contain a field, titled with the
10 <I>Name</I> field of the <B>Keyword</B> and containing the descendents of
11 the <B>Keyword</B> as choices.
12 <li>Searches for this object type will contain a selection field titled with
13 the <I>Name</I> field of the <B>Keyword</B> and containing the descendents
14 of the <B>Keyword</B> as choices.
15 <TABLE WIDTH=100%>
16
17
18
19   <TD VALIGN=TOP>
20     <h2>Create KeywordSelect</h2>
21   <FORM NAME="ModifyKeywordSelect" METHOD="POST" ACTION="<%$RT::WebPath%>/Admin/KeywordSelects/Modify.html">
22     [<%$title |n %>]
23     <BR>
24       
25       <INPUT TYPE="hidden" NAME="id" VALUE="<% $id %>">
26         Keyword 
27         <SELECT NAME="Parent">
28           
29 %while ( $parent = $parents->Next ) {
30           
31           <OPTION VALUE="<% $parent->id %>" <% defined($KeywordSelect->Parent) && $parent->id == $KeywordSelect->Parent ? ' SELECTED' : '' %>><% $parent->Name %></OPTION>
32           
33 % }
34           
35         </SELECT>
36         <BR>
37           Object 
38           <SELECT NAME="ObjectType">
39             <OPTION SELECTED>Ticket</OPTION>
40           </SELECT>
41           <BR>
42             
43 %foreach $queue ( keys %queues ) {
44     addOption("<% $queues{$queue} %>", "<% $queue %>", false, <% $queue == $KeywordSelect->ObjectValue ? 'true' : 'false' %> )
45 %}
46   }
47 }
48 </SCRIPT>
49             
50             Limit to <SELECT NAME="ObjectField" onChange="ChangeObjectValue(this)">
51               <OPTION VALUE="" <% $KeywordSelect->ObjectField ? '' : ' SELECTED' %>>(none)</OPTION>
52               <OPTION VALUE="Queue" <% $KeywordSelect->ObjectField eq 'Queue' ? ' SELECTED' : '' %>>Queue</OPTION>
53             </SELECT> 
54             <SELECT NAME="ObjectValue">
55               <OPTION VALUE="<% $KeywordSelect->ObjectValue %>">
56                 <% $KeywordSelect->ObjectField ? $queues{$KeywordSelect->ObjectValue} : "(n/a)" %></OPTION>
57             </SELECT><BR>
58               <INPUT TYPE="hidden" NAME="SingleMagic" VALUE="1">
59                 <INPUT TYPE="checkbox" NAME="Single" VALUE="1" <% $KeywordSelect->Single ? ' CHECKED' : '' %>>Allow single selection only<BR>
60                     Limit to <INPUT TYPE="text" NAME="Generations" SIZE="2" VALUE="<% $KeywordSelect->Generations %>"> generations (0 = no limit)<BR>
61                         <& /Elements/Submit, Label => $submit &>
62
63 </FORM>
64
65 <%INIT>
66
67
68 my $KeywordSelect = new RT::KeywordSelect($session{CurrentUser});
69   
70 my($title, $submit);
71   
72 if ( $Create ) {
73       $title = "Create a new KeywordSelect";
74       $submit = "Create";
75       $id = "new";
76 } else {
77     if  ( $id eq 'new' ) {
78         $id = $KeywordSelect->Create (
79                                       Parent      => $Parent,
80                                       ObjectType  => $ObjectType,
81                                       ObjectField => $ObjectField,
82                                       ObjectValue => $ObjectValue,
83                                       Single      => $Single,
84                                       Generations => $Generations,
85                                      ) or Abort "can't create KeywordSelect";
86     } else {
87         $KeywordSelect->Load($id) || Abort("Can't load keyword id $id");
88         #false laziness
89         $KeywordSelect->SetParent($Parent) if defined($Parent);
90         $KeywordSelect->SetObjectType($ObjectType) if defined($ObjectType);
91         $KeywordSelect->SetObjectField($ObjectField) if defined($ObjectField);
92         $KeywordSelect->SetObjectValue($ObjectValue) if defined($ObjectValue);
93         $KeywordSelect->SetSingle($Single) if defined($SingleMagic);
94         $KeywordSelect->SetGenerations($Generations) if defined($Generations);
95     }
96     $title = "Modify the KeywordSelect <B>". $KeywordSelect->KeywordObj->Name. "</B>";
97     $submit = "Modify";
98     
99 }
100   
101   my $parents = new RT::Keywords($session{CurrentUser});
102   $parents->UnLimit;
103   my $parent;
104
105 my $queues = new RT::Queues($session{CurrentUser});
106 $queues->UnLimit;
107
108 my %queues;
109 my $queue;
110 $queues{$queue->id} = $queue->Name while $queue = $queues->Next;
111
112 </%INIT>
113
114 <%ARGS>
115 $id => undef
116 $Create => undef
117 $Parent => undef
118 $ObjectType => undef
119 $ObjectField => undef
120 $ObjectValue => undef
121 $Single => undef
122 $SingleMagic => undef
123 $Generations => undef
124 </%ARGS>
125
126
127     <& /Admin/Elements/ModifyKeywordSelect, 'Create'=>'1' &>
128   </TD>
129
130   <TD VALIGN=TOP>
131     <H2>Modify KeywordSelect</H2>
132
133     <& /Admin/Elements/SelectModifyKeywordSelect &>
134   </TD>
135 </TR>
136
137 </TABLE>