EditCustomField 5.25 KB
Newer Older
1
%# BEGIN BPS TAGGED BLOCK {{{
2
%# 
3
4
%# COPYRIGHT:
%#  
Ruslan Zakirov's avatar
Ruslan Zakirov committed
5
%# This software is Copyright (c) 1996-2008 Best Practical Solutions, LLC 
6
%#                                          <jesse@bestpractical.com>
7
%# 
8
9
10
11
%# (Except where explicitly superseded by other copyright notices)
%# 
%# 
%# LICENSE:
12
13
14
15
%# 
%# 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
16
%# from www.gnu.org.
17
18
19
20
21
22
%# 
%# 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.
%# 
23
24
%# You should have received a copy of the GNU General Public License
%# along with this program; if not, write to the Free Software
Jesse Vincent's avatar
Jesse Vincent committed
25
26
%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
%# 02110-1301 or visit their web page on the internet at
Ruslan Zakirov's avatar
Ruslan Zakirov committed
27
%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28
29
30
31
32
33
34
35
36
%# 
%# 
%# 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.)
Alex Vandiver's avatar
Alex Vandiver committed
37
%# 
38
39
40
41
42
43
44
45
%# 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.
46
%# 
47
%# END BPS TAGGED BLOCK }}}
48
49
50
<& /Elements/ListActions, actions => \@results &>


Ruslan Zakirov's avatar
Ruslan Zakirov committed
51
52
53
<form method="post" action="CustomField.html">
<input type="hidden" class="hidden" name="CustomField" value="<%$id %>" />
<input type="hidden" class="hidden" name="Queue" value="<%$Queue%>" />
54

Ruslan Zakirov's avatar
Ruslan Zakirov committed
55
56
<table width="100%" border="0">
<tr><td align="right">
57
<&|/l&>Name</&>:
Jesse Vincent's avatar
Jesse Vincent committed
58
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
59
<input name="Name" value="<%$CustomFieldObj->Name%>" size="20" />
Jesse Vincent's avatar
Jesse Vincent committed
60
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
61
<tr><td align="right">
62
<&|/l&>Description</&>:
Jesse Vincent's avatar
Jesse Vincent committed
63
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
64
<input name="Description" value="<%$CustomFieldObj->Description%>" size="80" />
Jesse Vincent's avatar
Jesse Vincent committed
65
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
66
<tr><td align="right">
67
<&|/l&>Type</&>:
Jesse Vincent's avatar
Jesse Vincent committed
68
</td><td>
69
<& /Admin/Elements/SelectCustomFieldType, Name => "Type", Default => $CustomFieldObj->Type &>
Jesse Vincent's avatar
Jesse Vincent committed
70
71
72
</td></tr>
<tr><td>
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
73
74
<input type="hidden" class="hidden" name="SetEnabled" value="1" />
<input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> /> <&|/l&>Enabled (Unchecking this box disables this custom field)</&>
Jesse Vincent's avatar
Jesse Vincent committed
75
76
</td></tr>
</table>
77

Jesse Vincent's avatar
Jesse Vincent committed
78
<p>
79
% if ($CustomFieldObj->Id and $CustomFieldObj->Type =~ /Select/) {
80
<h2><&|/l&>Values</&></h2>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
81
<font size="-1">
82
83
84
85
<& /Admin/Elements/EditCustomFieldValues, CustomField => $CustomFieldObj &>
<& /Admin/Elements/AddCustomFieldValue, CustomField => $CustomFieldObj &>
</font>
% }
Hubert Hwang's avatar
Hubert Hwang committed
86
<&/Elements/Submit, Label => loc('Create') &>
Jesse Vincent's avatar
Jesse Vincent committed
87
</form>
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107



<%INIT>

my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
my $EnabledChecked = "CHECKED";
my (@results);

if (! $CustomField ) { 
  $title = loc("Create a CustomField");
  $id = 'new';
} else {

    if ($CustomField eq 'new') {
      my ($val, $msg) =  $CustomFieldObj->Create(Queue => $Queue, 
                                                 Name => $Name, 
                                                 Type => $Type,
                                                 Description => $Description,
						 );
Hubert Hwang's avatar
Hubert Hwang committed
108
109
110
111
112
113
114
115
116
117
118
119
      
      # if there is an error, then abort.  But since at this point there's
      # stuff already printed, clear it out.
      # (This only works in conjunction with temporarily turning autoflush
      #  off in the files that use this component.)
      unless ($val) {
	  $m->clear_buffer;
	  Abort(loc("Could not create CustomField: [_1]", $msg));
      }
      push @results, $msg;
      $CustomFieldObj->SetSortOrder($CustomFieldObj->id);
      $title = loc('Created CustomField [_1]', $CustomFieldObj->Name()); 
120
    } else {
Hubert Hwang's avatar
Hubert Hwang committed
121
      $CustomFieldObj->Load($CustomField) || Abort(loc('No CustomField'));
122
123
124
125
126
      $title = loc('Editing CustomField [_1]', $CustomFieldObj->Name()); 

      my @aresults = ProcessCustomFieldUpdates ( 
                        CustomFieldObj => $CustomFieldObj,
                        ARGSRef => \%ARGS );
Hubert Hwang's avatar
Hubert Hwang committed
127
      push @results, @aresults;
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    }


$id = $CustomFieldObj->id;

  #we're asking about enabled on the web page but really care about disabled.
  my $Disabled = ($Enabled ? 0 : 1);

  if  ( ($SetEnabled) and ( $Disabled != $CustomFieldObj->Disabled) ) { 
      my  ($code, $msg) = $CustomFieldObj->SetDisabled($Disabled);
      push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
  }
  
  if ($CustomFieldObj->Disabled()) {
      $EnabledChecked ="";
  }

}


</%INIT>
<%ARGS>
$id => undef
$title => undef
$Queue => undef
$CustomField => undef
$Type => undef
$Description => undef
$Name => undef
$SetEnabled => undef
$Enabled => undef
</%ARGS>