Merge lp:~christopher-bradshaw-b/tiqit/submit into lp:tiqit
- submit
- Merge into trunk
Proposed by
Christopher Bradshaw
Status: | Merged |
---|---|
Approved by: | Sam Stoll |
Approved revision: | 6 |
Merged at revision: | 9 |
Proposed branch: | lp:~christopher-bradshaw-b/tiqit/submit |
Merge into: | lp:tiqit |
Diff against target: |
650 lines (+155/-135) 6 files modified
scripts/actions/addfile.py (+0/-20) scripts/actions/edit.py (+49/-0) scripts/actions/editfile.py (+0/-15) scripts/actions/editnote.py (+0/-34) scripts/pages/view.py (+21/-21) static/scripts/view.js (+85/-45) |
To merge this branch: | bzr merge lp:~christopher-bradshaw-b/tiqit/submit |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Stoll | Approve | ||
Review via email: mp+281224@code.launchpad.net |
Commit message
Putting the logic for editing enclosures and fields in the same file, and making the whole view page a single form. This allows multiple sections to be edited and submitted together.
Description of the change
Putting the logic for editing enclosures and fields in the same file, and making the whole view page a single form. This allows multiple sections to be edited and submitted together.
To post a comment you must log in.
Revision history for this message
Sam Stoll (samstoll1) : | # |
Revision history for this message
Sam Stoll (samstoll1) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'scripts/actions/addfile.py' |
2 | --- scripts/actions/addfile.py 2014-06-05 14:38:53 +0000 |
3 | +++ scripts/actions/addfile.py 1970-01-01 00:00:00 +0000 |
4 | @@ -1,20 +0,0 @@ |
5 | -#! /usr/bin/python |
6 | - |
7 | -import os |
8 | -from tiqit import * |
9 | -from backend import * |
10 | - |
11 | -args = Arguments() |
12 | - |
13 | -# Get a temporary file to put the attachment into |
14 | -filename = args.writeToTempFile('theFile') |
15 | - |
16 | -try: |
17 | - addAttachment(args['bugid'], args['fileTitle'], filename) |
18 | - |
19 | - redirect("%s" % args['bugid']) |
20 | -finally: |
21 | - # |
22 | - # In any case, delete the file! |
23 | - # |
24 | - os.unlink(filename) |
25 | |
26 | === modified file 'scripts/actions/edit.py' |
27 | --- scripts/actions/edit.py 2014-06-05 14:38:53 +0000 |
28 | +++ scripts/actions/edit.py 2015-12-22 15:27:33 +0000 |
29 | @@ -1,6 +1,7 @@ |
30 | #! /usr/bin/python |
31 | |
32 | import time |
33 | +import os |
34 | from backend import * |
35 | from tiqit import * |
36 | from frontend import * |
37 | @@ -21,6 +22,54 @@ |
38 | if realupdate > lastupdate: |
39 | raise TiqitWarning("The bug has been edited since you loaded the page. Saving would have overwritten any changes made in between time. Go back to the bug and reload the page to see what fields have been modified (pressing 'Back' and then 'F5' should result in no loss of your own changes - the other modifications will simply appear in blue, alongside your own changes. You may then confirm or revert the changes, as desired).") |
40 | |
41 | + |
42 | +# |
43 | +# Edit note |
44 | +# |
45 | +if args.has_key('tiqitAttachmentAddNote'): |
46 | + if not args.has_key('tiqitAttachmentDeleteTitle'): |
47 | + if len(args['tiqitAttachmentNoteContent']) > 16 * 1024 and args.has_key('tiqitAttachmentIsUpdate'): |
48 | + raise TiqitError("Note too large. Must be less than 16kb. Use Attachements instead. Your note is %d bytes long" % len(args['tiqitAttachmentNoteContent'])) |
49 | + |
50 | + noteType = args['tiqitAttachmentNoteType'] |
51 | + noteTitle = args['tiqitAttachmentNoteTitle'].strip() |
52 | + newTitle = args['tiqitAttachmentNewNoteTitle'].strip() |
53 | + deleteTitle = args['tiqitAttachmentDeleteTitle'].strip() |
54 | + |
55 | + # If this is a delete, then delete it |
56 | + if args.has_key('tiqitAttachmentDeleteTitle'): |
57 | + deleteNote(bugid, args['tiqitAttachmentDeleteTitle'].strip()) |
58 | + else: |
59 | + |
60 | + # Try to rename the note if required first |
61 | + if newTitle and newTitle != noteTitle: |
62 | + renameNote(bugid, noteType, noteTitle, newTitle) |
63 | + |
64 | + # Save the new name for the next step |
65 | + noteTitle = newTitle |
66 | + |
67 | + # Now update/create the note |
68 | + if len(args['tiqitAttachmentNoteContent']) > 0: |
69 | + addNote(bugid, noteType, noteTitle, args['tiqitAttachmentNoteContent'], args.has_key('tiqitAttachmentIsUpdate')) |
70 | + |
71 | +# |
72 | +# Addfile |
73 | +# |
74 | +if args.has_key('tiqitAttachmentAddFile'): |
75 | + if args.has_key('tiqitAttachmentDeleteTitle'): |
76 | + deleteAttachment(bugid, args['tiqitAttachmentDeleteTitle']) |
77 | + elif args.has_key('tiqitAttachmentRenameTitle'): |
78 | + renameAttachment(bugid, args['tiqitAttachmentRenameTitle'], args['tiqitAttachmentNewTitle']) |
79 | + else: |
80 | + filename = args.writeToTempFile('theFile') |
81 | + try: |
82 | + addAttachment(bugid, args['tiqitAttachmentFileTitle'], filename) |
83 | + finally: |
84 | + # |
85 | + # In any case, delete the file! |
86 | + # |
87 | + os.unlink(filename) |
88 | + |
89 | # |
90 | # What type of bug is this |
91 | # |
92 | |
93 | === removed file 'scripts/actions/editfile.py' |
94 | --- scripts/actions/editfile.py 2014-06-05 14:38:53 +0000 |
95 | +++ scripts/actions/editfile.py 1970-01-01 00:00:00 +0000 |
96 | @@ -1,15 +0,0 @@ |
97 | -#!/usr/bin/python |
98 | - |
99 | -from tiqit import * |
100 | -from backend import * |
101 | - |
102 | -args = Arguments() |
103 | - |
104 | -bugid = args['bugid'] |
105 | - |
106 | -if args.has_key('deleteTitle'): |
107 | - deleteAttachment(bugid, args['deleteTitle']) |
108 | -else: |
109 | - renameAttachment(bugid, args['renameTitle'], args['newTitle']) |
110 | - |
111 | -redirect('%s' % bugid) |
112 | |
113 | === removed file 'scripts/actions/editnote.py' |
114 | --- scripts/actions/editnote.py 2014-06-05 14:38:53 +0000 |
115 | +++ scripts/actions/editnote.py 1970-01-01 00:00:00 +0000 |
116 | @@ -1,34 +0,0 @@ |
117 | -#! /usr/bin/python |
118 | - |
119 | -import cgi, traceback, commands, tempfile, os, stat, urllib, sys |
120 | -from tiqit import * |
121 | -from backend import * |
122 | - |
123 | -args = Arguments() |
124 | - |
125 | -if not args.has_key('deleteTitle'): |
126 | - if len(args['noteContent']) > 16 * 1024 and args.has_key('isUpdate'): |
127 | - raise TiqitError("Note too large. Must be less than 16kb. Use Attachements instead. Your note is %d bytes long" % len(args['noteContent'])) |
128 | - |
129 | -noteType = args['noteType'] |
130 | -noteTitle = args['noteTitle'].strip() |
131 | -bugid = args['bugid'] |
132 | -newTitle = args['newNoteTitle'].strip() |
133 | -deleteTitle = args['deleteTitle'].strip() |
134 | - |
135 | -# If this is a delete, then delete it |
136 | -if args.has_key('deleteTitle'): |
137 | - deleteNote(bugid, args['deleteTitle'].strip()) |
138 | -else: |
139 | - |
140 | - # Try to rename the note if required first |
141 | - if newTitle and newTitle != noteTitle: |
142 | - renameNote(bugid, noteType, noteTitle, newTitle) |
143 | - |
144 | - # Save the new name for the next step |
145 | - noteTitle = newTitle |
146 | - |
147 | - # Now update/create the note |
148 | - addNote(bugid, noteType, noteTitle, args['noteContent'], args.has_key('isUpdate')) |
149 | - |
150 | -redirect('%s' % bugid) |
151 | |
152 | === modified file 'scripts/pages/view.py' |
153 | --- scripts/pages/view.py 2014-06-05 14:38:53 +0000 |
154 | +++ scripts/pages/view.py 2015-12-22 15:27:33 +0000 |
155 | @@ -110,7 +110,7 @@ |
156 | <td><a onclick='showUserDropDown(event);'>%(Updater)s</a></td> |
157 | <td>%(Date)s</td><td>%(Size)s</td> |
158 | <td> |
159 | - <input type='button' onclick='renameAttachment(this);' value='Rename'><input style='display: none;' type='button' onclick='saveAttachmentRename(this);' value='Save'><input style='display: none;' type='button' onclick='cancelAttachmentRename(this);' value='Cancel'><input type='button' onclick='deleteAttachment(this);' value='Delete'><a href='%(Url)s'>Link</a> |
160 | + <input type='button' onclick='renameAttachment(this);' value='Rename'><input style='display: none;' type='button' onclick='if (prepareForm()) document.getElementById("tiqitBugEdit").submit();' value='Save'><input style='display: none;' type='button' onclick='cancelAttachmentRename(this);' value='Cancel'><input type='button' onclick='deleteAttachment(this);' value='Delete'><a href='%(Url)s'>Link</a> |
161 | </td> |
162 | </tr> |
163 | <tr class='file' style='display: none;'> |
164 | @@ -189,6 +189,8 @@ |
165 | |
166 | printMessages() |
167 | |
168 | + # Make the whole page a single form |
169 | + print "<form id='tiqitBugEdit' action='edit.py' method='post' onSubmit='return prepareForm();' enctype='multipart/form-data'>" |
170 | # Other links section |
171 | print """ <div id='tiqitOtherLinks'>""" |
172 | |
173 | @@ -215,6 +217,8 @@ |
174 | for pos, (name, func) in sections: |
175 | func(getattr(prefs, 'display%s' % name) == 'remove') |
176 | |
177 | + print "</form>" |
178 | + print "<div id='extraCopies'></div>" |
179 | printPageFooter() |
180 | |
181 | view_sections = bugView.getViewBugSections(theDom) |
182 | @@ -223,32 +227,33 @@ |
183 | primarytitle, primarytitleDetail, primaryformat = view_sections[0] |
184 | printSectionHeader(primarytitle, primarytitleDetail, hide); |
185 | |
186 | - print "<form id='tiqitBugEdit' action='edit.py' method='post' onSubmit='return prepareForm();'>" |
187 | print cls.getFormat(primaryformat) % args |
188 | |
189 | print """ |
190 | -<div id='extraCopies'></div> |
191 | <p> |
192 | <input type='submit' value='Save Changes'> |
193 | <input type='button' value='Reset Form' onclick='this.form.reset(); checkChildren(); checkFormValidity();'> |
194 | - <input type='button' onclick='if (!amEditing || confirm("You've made changes to this bug. Cloning it will throw them away. Are you sure you want to continue?")) document.location = "newbug.py?bugid=%(Identifier)s";' value='Clone Bug'> |
195 | -</p> |
196 | -</form>""" % args |
197 | + <input type='button' onclick='if ((!amEditing && !amEditingNote && !amEditingFile) || confirm("You've made changes to this bug. Cloning it will throw them away. Are you sure you want to continue?")) document.location = "newbug.py?bugid=%(Identifier)s";' value='Clone Bug'> |
198 | +</p>""" % args |
199 | |
200 | printSectionFooter() |
201 | |
202 | def displayExtra(hide=False): |
203 | - print "<form onsubmit='return false;' id='tiqitExtraFormData'>" |
204 | + print "<div id='tiqitExtraFormData'>" |
205 | for title, titleDetail, format in view_sections[1:]: |
206 | printSectionHeader(title, titleDetail, hide) |
207 | print cls.getFormat(format) % args |
208 | print """ |
209 | |
210 | -<p><input type='button' value='Save Changes' onClick='if (prepareForm()) document.getElementById("tiqitBugEdit").submit();'></p> |
211 | +<p> |
212 | +<input type='button' value='Save Changes' onClick='if (prepareForm()) document.getElementById("tiqitBugEdit").submit();'> |
213 | +<input type='button' value='Reset Form' onclick='this.form.reset(); checkChildren(); checkFormValidity();'> |
214 | +</p> |
215 | + |
216 | """ |
217 | |
218 | printSectionFooter() |
219 | - print "</form>" |
220 | + print "</div>" |
221 | # |
222 | # Text Notes and File Attachments are printed in the same section. |
223 | # |
224 | @@ -270,9 +275,8 @@ |
225 | print "<p>No Enclosures or Attachments.</p>" |
226 | else: |
227 | print """ |
228 | - <form action='editnote.py' method='post'> |
229 | <input type='hidden' name='bugid' value='%s'> |
230 | - <input type='hidden' name='isUpdate' value='true'> |
231 | + <input type='hidden' name='tiqitAttachmentIsUpdate' value='true'> |
232 | <div id='encTableContainer'> |
233 | <table id='encTable' class='tiqitTable' style='width: 90%%'> |
234 | <tr> |
235 | @@ -298,33 +302,30 @@ |
236 | </p> |
237 | <div id='newnote' class='note' style='display: none;'> |
238 | <p>Add new Enclosure:</p> |
239 | - <form action='editnote.py' method='post'> |
240 | <input type='hidden' name='bugid' value='%s'> |
241 | <table> |
242 | <tr> |
243 | <td>Type: </td> |
244 | - <td><select id='newnotetype' name='noteType' onchange='newNoteTitle(this);'>%s</select></td> |
245 | + <td><select id='newnotetype' name='tiqitAttachmentNoteType' onchange='newNoteTitle(this);'>%s</select></td> |
246 | <td>Title: </td> |
247 | - <td><input name='noteTitle' id='newnotetitle' type='text' size='50' value='%s'></td> |
248 | + <td><input name='tiqitAttachmentNoteTitle' id='newnotetitle' type='text' size='50' value='%s'></td> |
249 | </tr> |
250 | <tr> |
251 | <td colspan='4'> |
252 | - <textarea id='newnotecontent' name='noteContent' style='width: 100%%' rows='18'></textarea> |
253 | + <textarea id='newnotecontent' name='tiqitAttachmentNoteContent' style='width: 100%%' rows='18'></textarea> |
254 | </td> |
255 | </tr> |
256 | </table> |
257 | <p> |
258 | - <input type='submit' value='Save'> |
259 | + <input type='button' onclick='if (prepareForm()) document.getElementById("tiqitBugEdit").submit();' value='Save'> |
260 | <input type='button' onclick='hideNewNote();' value='Cancel'> |
261 | </p> |
262 | - </form> |
263 | </div> |
264 | <div id='newfile' class='note' style='display: none;'> |
265 | <p>Attach new File:</p> |
266 | - <form action='addfile.py' method='post' enctype='multipart/form-data'> |
267 | <input type='hidden' name='bugid' value='%s'> |
268 | <p> |
269 | - Title: <input name='fileTitle' type='text' size='50'> |
270 | + Title: <input name='tiqitAttachmentFileTitle' type='text' size='50'> |
271 | <!-- |
272 | Type: <select name='fileType'> |
273 | <option value='Auto'>Auto</option> |
274 | @@ -334,10 +335,9 @@ |
275 | <input type='file' name='theFile' size='30'> |
276 | </p> |
277 | <p> |
278 | - <input type='submit' value='Save'> |
279 | + <input type='button' onclick='if (prepareForm()) document.getElementById("tiqitBugEdit").submit();' value='Save'> |
280 | <input type='button' onclick='hideNewFile();' value='Cancel'> |
281 | </p> |
282 | - </form> |
283 | </div> |
284 | """ % (bugid, "".join(["<option value='%s'>%s</option>" % (x, x) for x in noteTypes]), noteTypes[0], bugid) |
285 | |
286 | |
287 | === modified file 'static/scripts/view.js' |
288 | --- static/scripts/view.js 2014-06-05 14:38:53 +0000 |
289 | +++ static/scripts/view.js 2015-12-22 15:27:33 +0000 |
290 | @@ -79,6 +79,8 @@ |
291 | |
292 | // The object currently being edited. |
293 | var amEditing = null; |
294 | +var amEditingNote = null; |
295 | +var amEditingFile = null; |
296 | |
297 | var editMsg = "You have already changed another section of this bug.\nYou may only edit one section at a time.\n\nPlease save those changes, or undo them, then try again." |
298 | |
299 | @@ -86,7 +88,7 @@ |
300 | function makeNoteTypeSelect() { |
301 | var opt; |
302 | var newS = document.createElement('select'); |
303 | - newS.setAttribute('name', 'noteType') |
304 | + newS.setAttribute('name', 'tiqitAttachmentNoteType') |
305 | |
306 | for (i in noteTypes) { |
307 | opt = document.createElement('option'); |
308 | @@ -120,13 +122,13 @@ |
309 | img.alt = '[+]'; |
310 | img.title = 'Show Enclosure'; |
311 | |
312 | - if (amEditing == row) { |
313 | + if (amEditingNote == row) { |
314 | cancelEnclosureEdit(row.cells[6].getElementsByTagName('input')[0]); |
315 | } |
316 | } |
317 | |
318 | function editEnclosure(button) { |
319 | - if (amEditing) { |
320 | + if (amEditingNote) { |
321 | alert(editMsg); |
322 | return; |
323 | } |
324 | @@ -138,7 +140,7 @@ |
325 | |
326 | // Text box |
327 | var textBox = document.createElement('textarea'); |
328 | - textBox.setAttribute('name', 'noteContent'); |
329 | + textBox.setAttribute('name', 'tiqitAttachmentNoteContent'); |
330 | textBox.setAttribute('rows', 20); |
331 | |
332 | var pre = table.rows[row.rowIndex + 1].cells[0].firstChild; |
333 | @@ -150,7 +152,7 @@ |
334 | |
335 | // Type select |
336 | var types = makeNoteTypeSelect(); |
337 | - types.setAttribute('name', 'noteType'); |
338 | + types.setAttribute('name', 'tiqitAttachmentNoteType'); |
339 | types.value = row.cells[1].textContent.substring(1, row.cells[1].textContent.lastIndexOf("'")); |
340 | types.defaultValue = types.value; |
341 | |
342 | @@ -159,13 +161,13 @@ |
343 | // Note title |
344 | // First save old one |
345 | var oldTitle = document.createElement('input'); |
346 | - oldTitle.setAttribute('name', 'noteTitle'); |
347 | + oldTitle.setAttribute('name', 'tiqitAttachmentNoteTitle'); |
348 | oldTitle.setAttribute('type', 'hidden'); |
349 | oldTitle.setAttribute('value', row.cells[0].lastChild.textContent); |
350 | row.cells[2].appendChild(oldTitle); |
351 | |
352 | var title = document.createElement('input'); |
353 | - title.setAttribute('name', 'newNoteTitle'); |
354 | + title.setAttribute('name', 'tiqitAttachmentNewNoteTitle'); |
355 | title.setAttribute('type', 'text'); |
356 | title.setAttribute('value', row.cells[0].lastChild.textContent.trim()); |
357 | title.setAttribute('size', 40); |
358 | @@ -177,7 +179,7 @@ |
359 | button.nextSibling.nextSibling.nextSibling.style.display = 'none'; |
360 | button.style.display = 'none'; |
361 | |
362 | - amEditing = row; |
363 | + amEditingNote = row; |
364 | } |
365 | |
366 | function cancelEnclosureEdit(button) { |
367 | @@ -185,7 +187,7 @@ |
368 | var row = button.parentNode.parentNode; |
369 | var table = row.parentNode.parentNode; |
370 | |
371 | - if (amEditing != row) { |
372 | + if (amEditingNote != row) { |
373 | alert("How did you manage to cancel an edit you weren't performing?"); |
374 | return; |
375 | } |
376 | @@ -212,11 +214,11 @@ |
377 | button.nextSibling.nextSibling.nextSibling.style.display = 'inline'; |
378 | button.style.display = 'inline'; |
379 | |
380 | - amEditing = null; |
381 | + amEditingNote = null; |
382 | } |
383 | |
384 | function deleteEnclosure(button) { |
385 | - if (amEditing) { |
386 | + if (amEditingNote) { |
387 | alert(editMsg); |
388 | return; |
389 | } |
390 | @@ -226,18 +228,18 @@ |
391 | |
392 | // Note title |
393 | var oldTitle = document.createElement('input'); |
394 | - oldTitle.setAttribute('name', 'deleteTitle'); |
395 | + oldTitle.setAttribute('name', 'tiqitAttachmentDeleteTitle'); |
396 | oldTitle.setAttribute('type', 'hidden'); |
397 | oldTitle.setAttribute('value', row.cells[0].lastChild.textContent); |
398 | row.cells[2].appendChild(oldTitle); |
399 | |
400 | - amEditing = row; |
401 | + amEditingNote = row; |
402 | |
403 | button.form.submit(); |
404 | } |
405 | |
406 | function renameAttachment(button) { |
407 | - if (amEditing) { |
408 | + if (amEditingFile) { |
409 | alert(editMsg); |
410 | return; |
411 | } |
412 | @@ -248,20 +250,20 @@ |
413 | // Title |
414 | // First save old one |
415 | var oldTitle = document.createElement('input'); |
416 | - oldTitle.setAttribute('name', 'fileTitle'); |
417 | + oldTitle.setAttribute('name', 'tiqitAttachmentFileTitle'); |
418 | oldTitle.setAttribute('type', 'hidden'); |
419 | oldTitle.setAttribute('value', row.cells[0].lastChild.textContent.trim()); |
420 | row.cells[2].appendChild(oldTitle); |
421 | |
422 | var title = document.createElement('input'); |
423 | - title.setAttribute('name', 'newTitle'); |
424 | + title.setAttribute('name', 'tiqitAttachmentNewTitle'); |
425 | title.setAttribute('type', 'text'); |
426 | title.setAttribute('value', row.cells[0].lastChild.textContent.trim()); |
427 | title.setAttribute('size', 40); |
428 | title.addEventListener('click', function(event) { event.stopPropagation(); }, true); |
429 | row.cells[0].replaceChild(title, row.cells[0].lastChild); |
430 | |
431 | - amEditing = row; |
432 | + amEditingFile = row; |
433 | |
434 | button.style.display = 'none'; |
435 | button.nextSibling.style.display = 'inline'; |
436 | @@ -270,13 +272,14 @@ |
437 | } |
438 | |
439 | function saveAttachmentRename(button) { |
440 | - var row = button.parentNode.parentNode; |
441 | - |
442 | - var fileTitle = row.cells[2].lastChild.value; |
443 | - var newTitle = row.cells[0].lastChild.value; |
444 | - var bugid = document.getElementById('Identifier').value; |
445 | - |
446 | - document.location.assign('editfile.py?bugid=' + bugid + '&renameTitle=' + fileTitle + '&newTitle=' + newTitle); |
447 | + var row = amEditingFile; |
448 | + |
449 | + // Note title |
450 | + var oldTitle = document.createElement('input'); |
451 | + oldTitle.setAttribute('name', 'tiqitAttachmentRenameTitle'); |
452 | + oldTitle.setAttribute('type', 'hidden'); |
453 | + oldTitle.setAttribute('value', row.cells[2].lastChild.value); |
454 | + row.cells[2].appendChild(oldTitle); |
455 | } |
456 | |
457 | function cancelAttachmentRename(button) { |
458 | @@ -293,11 +296,11 @@ |
459 | button.style.display = 'none'; |
460 | button.nextSibling.style.display = 'inline'; |
461 | |
462 | - amEditing = null; |
463 | + amEditingFile = null; |
464 | } |
465 | |
466 | function deleteAttachment(button) { |
467 | - if (amEditing) { |
468 | + if (amEditingFile) { |
469 | alert(editMsg); |
470 | return; |
471 | } |
472 | @@ -306,7 +309,7 @@ |
473 | var bugid = document.getElementById('Identifier').value; |
474 | var fileTitle = row.cells[0].textContent.trim(); |
475 | |
476 | - document.location.assign('editfile.py?bugid=' + bugid + '&deleteTitle=' + escape(fileTitle)); |
477 | + document.location.assign('editfile.py?bugid=' + bugid + '&tiqitAttachmentDeleteTitle=' + escape(fileTitle)); |
478 | } |
479 | |
480 | function showAllEnclosures() { |
481 | @@ -392,8 +395,28 @@ |
482 | |
483 | // New Note/File functions |
484 | |
485 | +function addFile() { |
486 | + var newFile = document.getElementById('newfile'); |
487 | + |
488 | + var addAttachment = document.createElement('input'); |
489 | + addAttachment.setAttribute('name', 'tiqitAttachmentAddFile'); |
490 | + addAttachment.setAttribute('type', 'hidden'); |
491 | + addAttachment.setAttribute('value', true); |
492 | + newFile.appendChild(addAttachment); |
493 | +} |
494 | + |
495 | +function addNote() { |
496 | + var newNote = document.getElementById('newnote'); |
497 | + |
498 | + var addAttachment = document.createElement('input'); |
499 | + addAttachment.setAttribute('name', 'tiqitAttachmentAddNote'); |
500 | + addAttachment.setAttribute('type', 'hidden'); |
501 | + addAttachment.setAttribute('value', true); |
502 | + newNote.appendChild(addAttachment); |
503 | +} |
504 | + |
505 | function showNewNote() { |
506 | - if (amEditing) { |
507 | + if (amEditingNote) { |
508 | alert(editMsg); |
509 | return false; |
510 | } |
511 | @@ -404,14 +427,14 @@ |
512 | newNote.style.display = "block"; |
513 | theButton.style.display = "none"; |
514 | |
515 | - amEditing = theButton; |
516 | + amEditingNote = theButton; |
517 | } |
518 | |
519 | function hideNewNote() { |
520 | var newNote = document.getElementById("newnote"); |
521 | var theButton = document.getElementById("newencbuttons"); |
522 | |
523 | - if (theButton != amEditing) { |
524 | + if (theButton != amEditingNote) { |
525 | alert("You're not editing a new Note!"); |
526 | return false; |
527 | } |
528 | @@ -419,11 +442,11 @@ |
529 | newNote.style.display = "none"; |
530 | theButton.style.display = "inline"; |
531 | |
532 | - amEditing = null; |
533 | + amEditingNote = null; |
534 | } |
535 | |
536 | function showNewFile() { |
537 | - if (amEditing) { |
538 | + if (amEditingFile) { |
539 | alert(editMsg); |
540 | return false; |
541 | } |
542 | @@ -434,14 +457,14 @@ |
543 | newNote.style.display = "block"; |
544 | theButton.style.display = "none"; |
545 | |
546 | - amEditing = theButton; |
547 | + amEditingFile = theButton; |
548 | } |
549 | |
550 | function hideNewFile() { |
551 | var newNote = document.getElementById("newfile"); |
552 | var theButton = document.getElementById("newencbuttons"); |
553 | |
554 | - if (theButton != amEditing) { |
555 | + if (theButton != amEditingFile) { |
556 | alert("You're not editing a new File!"); |
557 | return false; |
558 | } |
559 | @@ -449,7 +472,7 @@ |
560 | newNote.style.display = "none"; |
561 | theButton.style.display = "inline"; |
562 | |
563 | - amEditing = null; |
564 | + amEditingFile = null; |
565 | } |
566 | |
567 | function initNoteTitleChange() { |
568 | @@ -781,18 +804,35 @@ |
569 | // |
570 | |
571 | function prepareForm() { |
572 | + if (amEditing && (amEditingFile || amEditingNote)) { |
573 | + if (!confirm("You've made changes to another section of this bug. Do you wish to continue and also save these changes?")) { |
574 | + return false; |
575 | + } |
576 | + } |
577 | + if (amEditingFile) { |
578 | + if (amEditingFile.tagName == 'P') { |
579 | + addFile(); |
580 | + } else if (amEditingFile.tagName == 'TR') { |
581 | + saveAttachmentRename(); |
582 | + } |
583 | + } |
584 | + if (amEditingNote) { |
585 | + addNote(); |
586 | + } |
587 | + |
588 | + |
589 | var form = document.getElementById('tiqitBugEdit'); |
590 | var extra = document.getElementById('tiqitExtraFormData'); |
591 | - |
592 | + |
593 | var inputs = extra.getElementsByTagName('input'); |
594 | var selects = extra.getElementsByTagName('select'); |
595 | - |
596 | + |
597 | var extraDiv = document.getElementById('extraCopies'); |
598 | - |
599 | + |
600 | while (extraDiv.childNodes.length) { |
601 | extraDiv.removeChild(extraDiv.childNodes[0]); |
602 | } |
603 | - |
604 | + |
605 | for (var i = 0; i < inputs.length; i++) { |
606 | if (inputs[i].name && ((inputs[i].type != 'checkbox' && inputs[i].value) || inputs[i].checked) && !inputs[i].disabled) { |
607 | var hidden = document.createElement('input'); |
608 | @@ -802,7 +842,7 @@ |
609 | extraDiv.appendChild(hidden); |
610 | } |
611 | } |
612 | - |
613 | + |
614 | for (var i = 0; i < selects.length; i++) { |
615 | if (selects[i].name && selects[i].value && !selects[i].disabled) { |
616 | var hidden = document.createElement('input'); |
617 | @@ -812,12 +852,12 @@ |
618 | extraDiv.appendChild(hidden); |
619 | } |
620 | } |
621 | - |
622 | + |
623 | var oldRelates = new Array(); |
624 | var newRelates = document.getElementById('tiqitNewRelates'); |
625 | - |
626 | + |
627 | var relatesTable = document.getElementById('tiqitRelatesTable'); |
628 | - |
629 | + |
630 | if (relatesTable) { |
631 | for (row = 0; row < relatesTable.rows.length; row++) { |
632 | // Related bugs with disabled check boxes are those that aren't tracked |
633 | @@ -828,7 +868,7 @@ |
634 | } |
635 | } |
636 | } |
637 | - |
638 | + |
639 | if (newRelates) { |
640 | var hidden = document.createElement('input'); |
641 | hidden.type = 'hidden'; |
642 | @@ -836,7 +876,7 @@ |
643 | hidden.value = oldRelates.join(',') + ',' + newRelates.value; |
644 | extraDiv.appendChild(hidden); |
645 | } |
646 | - |
647 | + |
648 | if (!checkFormValidity()) |
649 | return confirm("Missing info in form. Submit anyway?"); |
650 | else |