OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <title>{{ .Title }}</title> |
| 4 <link rel="stylesheet" type="text/css" href="style.css" /> |
| 5 <script type="text/javascript" src="third_party/jquery-2.1.1.min.js"></script> |
| 6 <script type="text/javascript" src="third_party/jquery.tablednd.js"></script> |
| 7 <script type="text/javascript"> |
| 8 "use strict"; |
| 9 |
| 10 var issues = {{ .BugsJson }}; |
| 11 var edited = {}; |
| 12 |
| 13 function edit_label(bug_id, old_value, new_value) { |
| 14 console.log("issue[" + bug_id + "]: " + old_value + " -> " + new_value); |
| 15 if (!edited[bug_id]) { |
| 16 edited[bug_id] = JSON.parse(JSON.stringify(issues[bug_id])); |
| 17 } |
| 18 var old_index = edited[bug_id]["labels"].indexOf(old_value); |
| 19 if (old_index > -1) { |
| 20 edited[bug_id]["labels"][old_index] = new_value; |
| 21 } else { |
| 22 edited[bug_id]["labels"].push(new_value) |
| 23 } |
| 24 if (JSON.stringify(issues[bug_id]) == JSON.stringify(edited[bug_id])) { |
| 25 console.log("Not changing " + bug_id); |
| 26 delete edited[bug_id] |
| 27 } |
| 28 document.getElementById("all_edits").value = JSON.stringify(edited); |
| 29 } |
| 30 |
| 31 </script> |
| 32 </head> |
| 33 <body> |
| 34 <h1>BugChomper</h1> |
| 35 |
| 36 <form method="post"> |
| 37 <input type="hidden" name="all_edits" id="all_edits" value="{}" /> |
| 38 <input type="submit" value="Submit changes to issue tracker" /> |
| 39 </form> |
| 40 <table id="buglist"> |
| 41 <thead> |
| 42 <tr id="table_header" class="nodrag tr_head"> |
| 43 <td colspan=3><h2>Open bugs for {{ .User }}</h2></td> |
| 44 </tr> |
| 45 <tr id="table_subheader" class="nodrag tr_head"> |
| 46 <td>ID</td> |
| 47 <td>Priority</td> |
| 48 <td>Title</td> |
| 49 </tr> |
| 50 </thead> |
| 51 <tbody> |
| 52 {{ with $all_data := . }} |
| 53 {{ range $index, $priority := index $all_data.Priorities }} |
| 54 <tr id="priority_{{ $priority }}" |
| 55 class="{{ if eq $index 0 }}nodrop{{ else }}{{ end }} nodrag priority
_row priority_{{ $priority }}" |
| 56 > |
| 57 <td colspan=3 class="priority_td">Priority {{ $priority }}</td> |
| 58 </tr> |
| 59 {{ range $index, $bug := index $all_data.BugsByPriority $priority}} |
| 60 <tr id="{{ $bug.Id }}" class="priority_{{ $priority }}"> |
| 61 <td id="id_{{ $bug.Id }}"> |
| 62 <a href="{{ $bug.URL }}" target="_blank">{{ $bug.Id }}</a> |
| 63 </td> |
| 64 <td id="priority_{{ $bug.Id }}">{{ $priority }}</td> |
| 65 <td id="title_{{ $bug.Id }}">{{ $bug.Title }}</td> |
| 66 </tr> |
| 67 {{ end }} |
| 68 {{ end }} |
| 69 {{ end }} |
| 70 </tbody> |
| 71 </table> |
| 72 |
| 73 <script type="text/javascript"> |
| 74 $(document).ready(function() { |
| 75 $("#buglist").tableDnD({ |
| 76 onDrop: function(table, dropped_row) { |
| 77 var id = dropped_row.id; |
| 78 var css_priority_prefix = "priority_" |
| 79 var new_priority = null; |
| 80 var dropped_index = null; |
| 81 var thead_rows = table.tHead.rows; |
| 82 var tbody_rows = table.tBodies[0].rows; |
| 83 var all_rows = []; |
| 84 for (var i = 0; i < thead_rows.length; i++) { |
| 85 all_rows.push(thead_rows[i]); |
| 86 } |
| 87 for (var i = 0; i < tbody_rows.length; i++) { |
| 88 all_rows.push(tbody_rows[i]); |
| 89 } |
| 90 for (var i = 0; i < all_rows.length; i++) { |
| 91 if (all_rows[i].id) { |
| 92 if (all_rows[i].id.indexOf(css_priority_prefix) == 0) { |
| 93 new_priority = all_rows[i].id.substring(css_priority_pre
fix.length); |
| 94 } |
| 95 if (all_rows[i].id == id) { |
| 96 break; |
| 97 } |
| 98 } else { |
| 99 console.warn("No id for:"); |
| 100 console.warn(all_rows[i]); |
| 101 } |
| 102 } |
| 103 if (new_priority) { |
| 104 priority_td = document.getElementById(css_priority_prefix + id); |
| 105 old_priority = priority_td.innerHTML; |
| 106 if (priority_td && new_priority != old_priority) { |
| 107 priority_td.innerHTML = new_priority; |
| 108 document.getElementById(id).className = css_priority_prefix
+ new_priority; |
| 109 edit_label(id, "{{ .PriorityPrefix }}" + old_priority, "{{ .
PriorityPrefix }}" + new_priority); |
| 110 } |
| 111 } |
| 112 } |
| 113 }); |
| 114 }); |
| 115 </script> |
| 116 </body> |
| 117 </html> |
OLD | NEW |