-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathedit-ticket.rsp
301 lines (294 loc) · 8.23 KB
/
edit-ticket.rsp
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<%
if any [
validate/full [id integer! *]
empty? ticket: get-raw-ticket request/content/id
][
response/redirect "view-tickets.rsp"
]
if ticket/2 <> session/content/project-id [ ;-- current project <> ticket's project
if all [
session/content/user-id
access-project? ticket/2 session/content/user-id
][
response/redirect request/web-app
]
session/content/project-id: ticket/2
]
params: request/content
if all [
session/content/user-role = 'reporter
session/content/user-id <> ticket/17 ; ticket's owner allowed to edit
ticket/10 <> 6 ; dismissed ticket can't be edited by owner (Reporter)
][
deny-access
]
sync-vars: [
summary 3
description 4
code 5
version 6
fixedin 7
category 8
severity 9
status 10
; resolution 11
priority 12
; reproduce 13
type 14
platform 15
]
invalid: validate/full [
status integer! *
severity integer! *
priority integer! *
version integer! -
fixedin integer! -
category integer! -
; reproduce integer! *
type integer! *
platform integer! *
; resolution integer! *
summary - *
description - *
code - -
project integer! -
cursor integer! -
action word! -
]
err?: no
if params/action = 'save [
either invalid [
err?: yes
][
;--- Clean up CR chars from IE
if params/description [remove-each c params/description [c = #"^M"]]
if params/code [remove-each c params/code [c = #"^M"]]
;--- Log changes
changed?: no
foreach [var id] sync-vars [
if not ticket/:id == value: params/:var [
changed?: yes
case [
id = 3 [
add-log/msg first ticket 'modified var reform [
ticket/:id "=>" value
]
]
any [id = 4 id = 5][
add-log first ticket 'modified var
]
id <= 8 [
list: either id = 8 [enum-categories][enum-versions]
add-log/msg first ticket 'modified var reform [
any [all [ticket/:id select list ticket/:id] ""]
"=>" select list value
]
]
id > 8 [
add-log/old/new first ticket 'modified var ticket/:id value
if all [id = 10 ticket/:id <> value][update-closed-date params value ]
]
]
]
]
;--- Save changes
if changed? [update-ticket params]
response/redirect rejoin [
"ticket.rsp?id=" params/id
either params/cursor [join "&cursor=" params/cursor][""]
]
]
]
if all [
params/action = 'delete
any [
find [admin developer] session/content/user-role
all [ ;-- fix for R3#1371
session/content/user-id = ticket/17
zero? touched-by-others? params/id
]
]
][
delete-ticket params/id
response/redirect "view-tickets.rsp"
]
if all [
params/action = 'move
any [
find [admin developer] session/content/user-role
session/content/user-id = ticket/17
]
][
move-ticket ticket params/project
response/redirect "view-tickets.rsp"
]
foreach [var id] sync-vars [
if value: params/:var [poke ticket id value]
]
title: rejoin [say "Ticket" " #" zeropad params/id 7]
include %head.rsp
edit?: yes
include %navigate-tickets.rsp
%>
<script type="text/javascript">
function MoveSubmit() {
var warn = "\n\nWatch out, following fields will be reset:\n - Category\n - Version\n - Fixed In";
var res = confirm("<%= join say "Do you really want to move ticket #" params/id%> ?" + warn);
if (res) document.forms.ticket.action.value = 'move';
return res;
}
</script>
<%if ins: select request/config/locals 'short [
id: params/id%>
<div style="position:absolute;top:130px;left:5%;padding-left:12px;text-align:right;">
#[Short URL]: <a href="http://issue.cc/<%=ins%>/<%=id%>">http://issue.cc/<%=ins%>/<%=id%></a>
</div>
<%]%>
<div style="position:absolute;top:132px;right:5%;padding-right:12px;text-align:right;">
<a href="feed.rsp?tid=<%=id%>"><img src="img/rss.gif" border="0" alt="rss"></a><br>
</div>
<div align="center" style="margin-top:10px;">
<form method="POST" name="ticket" action="<%=join request/parsed/url "#comments"%>">
<table class="tbl" width="90%">
<tr>
<th width="120">#[Type]</th>
<td>
<select name="type" class="sel"><%foreach [id label] enum-types [%>
<option value="<%=id%>"<% mark/selected id 'type ticket/14%>><%=say label%></option><%
]%></select>
</td>
<th>#[Status]</th>
<td>
<select name="status"><%foreach [id label] enum-statuses [
%><option value="<%=id%>"<% mark/selected id 'status ticket/10%>><%=say label%></option>
<%]%></select>
</td>
<th>#[Date]</th>
<td ><%=ticket/18/date%> <%=ticket/18/time%></td>
</tr><tr>
<th>#[Version]</th>
<td><%either empty? list-ver: enum-versions [%>
n/a
<input type="hidden" name="version" value="<%=ticket/6%>">
<%][%>
<select name="version"><%foreach [id label] list-ver [
%><option value="<%=id%>"<% mark/selected id 'version ticket/6%>><%=label%></option>
<%]%>
</select>
<%]%>
</td>
<th>#[Category]</th>
<td><%either empty? list: enum-categories [%>
n/a
<input type="hidden" name="category" value="<%=ticket/8%>">
<%][%>
<select name="category"><%foreach [id label] list [
%><option value="<%=id%>"<% mark/selected id 'category ticket/8%>><%=label%></option>
<%]%>
</select>
<%]%>
</td>
<th>#[Submitted by]</th>
<td><%=ticket/21%></td>
</tr><tr>
<th>#[Platform]</th>
<td>
<select name="platform"><%foreach [id label] enum-platforms [%>
<option value="<%=id%>"<% mark/selected id 'platform ticket/15%>><%=say label%></option><%
]%></select>
</td>
<th>#[Severity]</th>
<td>
<select name="severity"><%foreach [id label] enum-severities [%>
<option value="<%=id%>"<% mark/selected id 'severity ticket/9%>><%=say label%></option><%
]%></select>
</td>
<th>#[Priority]</th>
<td>
<select name="priority"><%foreach [id label] enum-priorities [
%><option value="<%=id%>"<% mark/selected id 'priority ticket/12%>><%=say label%></option>
<%]%>
</select>
</td>
</tr>
</table><br>
<table class="tbl" width="90%">
<tr>
<th align="left" width="120">#[Summary]</th>
<td colspan="3">
<input name="summary" type="text" size="94" value="<%=html-encode ticket/3%>" style="background-color:beige">
</td>
</tr><tr>
<th align="left">#[Description]</th>
<td colspan="3">
<textarea name="description" rows="10" style="width:99%"><%=ticket/4%></textarea>
</td>
</tr><tr>
<th align="left">#[Example Code]</th>
<td colspan="3">
<textarea name="code" rows="10" style="width:99%"><%=any [ticket/5 ""]%></textarea>
</td>
</tr>
</table>
<br>
<table class="tbl" width="90%">
<tr>
<th width="120">#[Assigned to]</th>
<td width="120">n/a</td>
<th>#[Fixed in]</th>
<td><%either empty? list-ver [%>
n/a
<input type="hidden" name="fixedin" value="<%=any [ticket/7 0]%>">
<%][%>
<select name="fixedin">
<option value="0"> </option>
<%foreach [id label] list-ver [
%><option value="<%=id%>"<% mark/selected id 'version ticket/7%>><%=label%></option>
<%]%>
</select>
<%]%>
</td>
<th>#[Last Update]</th>
<td><%=ticket/19/date%> <%=ticket/19/time%></td>
</tr>
</table>
<br>
<div align="center">
<input type="submit" value=" #[Update Ticket] ">
<%if any [
session/content/user-role = 'admin
session/content/user-id = ticket/17
][%>
<script type="text/javascript">
function DeleteSubmit() {
var res = confirm("<%= join say "Do you really want to delete ticket #" params/id%> ?");
if (res) document.forms.ticket.action.value = 'delete';
return res;
}
</script>
<input type="submit" value=" #[Delete Ticket] " onclick="return DeleteSubmit();">
<%
projects: copy skip projects 2
remove/part find projects ticket/2 2 ;-- removes current ticket's project entry
if not empty? projects [%>
<input type="submit" value=" #[Move Ticket To] " onclick="return MoveSubmit();">
<select name="project"><%
foreach [id prj] head sort/skip/compare projects 2 2 [%>
<option value="<%=id%>"><%=prj%></option>
<%]%></select>
<%]
]%>
</div>
<input type="hidden" name="action" value="save">
</form>
</div>
<%
allow-modify?: yes
width: none
include %attached.rsp
add-cmt: yes
include %comments.rsp
include %history.rsp
include-file %footer.inc
%>