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