summaryrefslogtreecommitdiff
path: root/rt/webrt/Admin/KeywordSelects/index.html
blob: ba3da9f0cf98ffbe9a1d4021b9c07e018494889e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<& /Admin/Elements/Header, Title => 'Admin KeywordSelects' &>
<& /Admin/Elements/Tabs, current_tab => 'Admin/KeywordSelects/' &>

A <B>KeywordSelect</B> is a link between a <B>Keyword</B> and a object
(currently just <B>Tickets</B>), titled by the <I>Name</I> field of the Keyword such that:
<ul>
<li>Object display will contain a field, titled with the <I>Name</I> field of
the <B>Keyword</B> and showing any descendent keywords.
<li>Object creation for this field will contain a field, titled with the
<I>Name</I> field of the <B>Keyword</B> and containing the descendents of
the <B>Keyword</B> as choices.
<li>Searches for this object type will contain a selection field titled with
the <I>Name</I> field of the <B>Keyword</B> and containing the descendents
of the <B>Keyword</B> as choices.
<TABLE WIDTH=100%>



  <TD VALIGN=TOP>
    <h2>Create KeywordSelect</h2>
  <FORM NAME="ModifyKeywordSelect" METHOD="POST" ACTION="<%$RT::WebPath%>/Admin/KeywordSelects/Modify.html">
    [<%$title |n %>]
    <BR>
      
      <INPUT TYPE="hidden" NAME="id" VALUE="<% $id %>">
	Keyword 
	<SELECT NAME="Parent">
	  
%while ( $parent = $parents->Next ) {
	  
	  <OPTION VALUE="<% $parent->id %>" <% defined($KeywordSelect->Parent) && $parent->id == $KeywordSelect->Parent ? ' SELECTED' : '' %>><% $parent->Name %></OPTION>
	  
% }
	  
	</SELECT>
	<BR>
	  Object 
	  <SELECT NAME="ObjectType">
	    <OPTION SELECTED>Ticket</OPTION>
	  </SELECT>
	  <BR>
	    
%foreach $queue ( keys %queues ) {
    addOption("<% $queues{$queue} %>", "<% $queue %>", false, <% $queue == $KeywordSelect->ObjectValue ? 'true' : 'false' %> )
%}
  }
}
</SCRIPT>
	    
	    Limit to <SELECT NAME="ObjectField" onChange="ChangeObjectValue(this)">
	      <OPTION VALUE="" <% $KeywordSelect->ObjectField ? '' : ' SELECTED' %>>(none)</OPTION>
	      <OPTION VALUE="Queue" <% $KeywordSelect->ObjectField eq 'Queue' ? ' SELECTED' : '' %>>Queue</OPTION>
	    </SELECT> 
	    <SELECT NAME="ObjectValue">
	      <OPTION VALUE="<% $KeywordSelect->ObjectValue %>">
		<% $KeywordSelect->ObjectField ? $queues{$KeywordSelect->ObjectValue} : "(n/a)" %></OPTION>
	    </SELECT><BR>
	      <INPUT TYPE="hidden" NAME="SingleMagic" VALUE="1">
		<INPUT TYPE="checkbox" NAME="Single" VALUE="1" <% $KeywordSelect->Single ? ' CHECKED' : '' %>>Allow single selection only<BR>
		    Limit to <INPUT TYPE="text" NAME="Generations" SIZE="2" VALUE="<% $KeywordSelect->Generations %>"> generations (0 = no limit)<BR>
			<& /Elements/Submit, Label => $submit &>

</FORM>

<%INIT>


my $KeywordSelect = new RT::KeywordSelect($session{CurrentUser});
  
my($title, $submit);
  
if ( $Create ) {
      $title = "Create a new KeywordSelect";
      $submit = "Create";
      $id = "new";
} else {
    if  ( $id eq 'new' ) {
	$id = $KeywordSelect->Create (
				      Parent      => $Parent,
				      ObjectType  => $ObjectType,
				      ObjectField => $ObjectField,
				      ObjectValue => $ObjectValue,
				      Single      => $Single,
				      Generations => $Generations,
				     ) or Abort "can't create KeywordSelect";
    } else {
	$KeywordSelect->Load($id) || Abort("Can't load keyword id $id");
	#false laziness
	$KeywordSelect->SetParent($Parent) if defined($Parent);
	$KeywordSelect->SetObjectType($ObjectType) if defined($ObjectType);
	$KeywordSelect->SetObjectField($ObjectField) if defined($ObjectField);
	$KeywordSelect->SetObjectValue($ObjectValue) if defined($ObjectValue);
	$KeywordSelect->SetSingle($Single) if defined($SingleMagic);
	$KeywordSelect->SetGenerations($Generations) if defined($Generations);
    }
    $title = "Modify the KeywordSelect <B>". $KeywordSelect->KeywordObj->Name. "</B>";
    $submit = "Modify";
    
}
  
  my $parents = new RT::Keywords($session{CurrentUser});
  $parents->UnLimit;
  my $parent;

my $queues = new RT::Queues($session{CurrentUser});
$queues->UnLimit;

my %queues;
my $queue;
$queues{$queue->id} = $queue->Name while $queue = $queues->Next;

</%INIT>

<%ARGS>
$id => undef
$Create => undef
$Parent => undef
$ObjectType => undef
$ObjectField => undef
$ObjectValue => undef
$Single => undef
$SingleMagic => undef
$Generations => undef
</%ARGS>


    <& /Admin/Elements/ModifyKeywordSelect, 'Create'=>'1' &>
  </TD>

  <TD VALIGN=TOP>
    <H2>Modify KeywordSelect</H2>

    <& /Admin/Elements/SelectModifyKeywordSelect &>
  </TD>
</TR>

</TABLE>