annotate bts_webui/amancay/static/amancay_interface.js @ 144:c93c594f1f98 draft

toolbox: convert the toolbox into a template tag This is a *huge* improvement to how the code is organized right now. Specifically this gives us complete control over how stuff is loaded from the sidebar and makes more evident which are the paths taken by the code to actually do stuff. A concrete example is how loading of links happen. amancay_interface.js has been disabled to implement/move its functionality to other places.
author diegoe-guest
date Mon, 10 Aug 2009 23:42:03 +0000
parents 3f5b51f6f99b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
1 function reload_current_view(evt) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
2 var view = document.getElementById("current_view").value;
144
c93c594f1f98 toolbox: convert the toolbox into a template tag
diegoe-guest
parents: 44
diff changeset
3 load_bugs(evt,"/" + view + "_table/");
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
4 }
c60a544ed178 Initial commit
marga
parents:
diff changeset
5
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
6 var items_changed = function(request) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
7 var item_type = document.getElementById("item").name;
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
8 var item_list = MochiKit.Async.evalJSONRequest(request)["item_list"];
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
9 if (item_list.length == 0) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
10 var dom_form = document.getElementById("item_selection");
9
71c2dd718293 Fixed the Homepage to turn it into XHTML 1.0
marga
parents: 3
diff changeset
11 new_span = DIV({'class': 'toolbox_message'}, "No items selected");
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
12 replaceChildNodes(dom_form, new_span);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
13 } else {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
14 var cells = new Array(item_list.length);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
15 for (var i=0; i < item_list.length; i++) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
16 cells[i] = [ TD({"class":"item_select"}, INPUT({"type":"checkbox",
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
17 "name":item_type+"_select", "id":"item_select", "value":
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
18 item_list[i]}, null)), TD({"class":"item_name"}, item_list[i]) ];
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
19 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
20 var rows = map(partial(TR, null), cells);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
21 var dom_item_table = document.getElementById("item_list");
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
22 if (! dom_item_table) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
23 dom_item_table = TABLE({"id":"item_list"})
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
24 dom_item_list = TBODY(null, null)
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
25 replaceChildNodes(dom_item_table, dom_item_list);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
26 var dom_form = document.getElementById("item_selection");
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
27 var dom_remove = DIV({"class":"toolbox_remove"},
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
28 INPUT({"type":"submit", "value": "Remove", "class": "toolbox_remove"}))
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
29 MochiKit.Signal.connect( dom_form, 'onsubmit', send_item_selected );
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
30 replaceChildNodes(dom_form, dom_item_table, dom_remove)
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
31 } else {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
32 dom_item_list = dom_item_table.getElementsByTagName("tbody")[0];
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
33 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
34 replaceChildNodes(dom_item_list, rows);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
35 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
36 reload_current_view();
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
37 }
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
38
c60a544ed178 Initial commit
marga
parents:
diff changeset
39
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
40 function loading_bugs() {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
41 new_span = SPAN({'class': 'loading'}, "Loading...");
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
42 replaceChildNodes(document.getElementById("loading"), new_span);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
43 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
44 function loading_finished() {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
45 new_span = SPAN();
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
46 replaceChildNodes(document.getElementById("loading"), new_span);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
47 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
48
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
49 var got_search_results = function(request) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
50 place = document.getElementById("search_results");
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
51 replace_content(request, place);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
52 pagerConnect();
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
53 }
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
54
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
55 var got_bugs = function(request) {
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
56 place = document.getElementById("main_content");
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
57 replace_content(request, place);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
58 }
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
59
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
60 function replace_content(request, place) {
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
61 if (strip(request.responseText) != "") {
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
62 place.innerHTML = request.responseText;
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
63 }
c60a544ed178 Initial commit
marga
parents:
diff changeset
64 else {
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
65 new_span = SPAN({'class': 'error'}, "No bugs found");
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
66 replaceChildNodes(place, new_span);
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
67 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
68 loading_finished();
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
69 }
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
70
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
71 var failed_bugs = function(request) {
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
72 new_span = SPAN({'class': 'error'}, "ERROR: bug list couldn't be loaded");
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
73 replaceChildNodes(document.getElementById("main_content"), new_span);
3
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
74 loading_finished();
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
75 }
026d1bcf0746 The migration to the new interface is almost done
marga
parents: 1
diff changeset
76
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
77 var failed_search_results = function(request) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
78 new_span = SPAN({'class': 'error'}, "ERROR: search results couldn't be loaded");
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
79 replaceChildNodes(document.getElementById("search_results"), new_span);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
80 loading_finished();
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
81 }
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
82
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
83 function load_bugs(evt, url) {
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
84 loading_bugs();
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
85 var d = doXHR(url);
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
86 d.addCallbacks(got_bugs, failed_bugs);
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
87 evt.preventDefault();
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
88 }
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
89
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
90 function load_search_results(evt, url) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
91 loading_bugs();
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
92 var d = doXHR(url);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
93 d.addCallbacks(got_search_results, failed_search_results);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
94 evt.preventDefault();
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
95 }
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
96
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
97 function send_page(evt) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
98 url = (evt.src() + "").replace(/search/, "search_table");
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
99 load_search_results(evt,url);
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
100 evt.preventDefault();
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
101 }
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
102
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
103 function pagerConnect() {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
104 var pager = document.getElementById("pager")
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
105 if (pager) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
106 var items = pager.getElementsByTagName("a")
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
107 for (var i = 0; i < items.length; i++) {
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
108 MochiKit.Signal.connect( items[i], 'onclick', send_page );
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
109 }
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
110 }
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
111 }
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
112
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
113 function myLoadFunction()
c60a544ed178 Initial commit
marga
parents:
diff changeset
114 {
36
5ebd6587f8c0 AJAX capabilities for searching and paging
marga
parents: 25
diff changeset
115 pagerConnect();
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
116
44
3f5b51f6f99b Divided the javascript files into buglog / everything else
marga
parents: 36
diff changeset
117 if (buglogConnect)
3f5b51f6f99b Divided the javascript files into buglog / everything else
marga
parents: 36
diff changeset
118 buglogConnect();
3f5b51f6f99b Divided the javascript files into buglog / everything else
marga
parents: 36
diff changeset
119
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
120 var link;
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
121 link = document.getElementById("submitted_bugs_link");
25
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
122 if (link)
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
123 MochiKit.Signal.connect( link, 'onclick', get_submitted_bugs );
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
124
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
125 link = document.getElementById("received_bugs_link");
25
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
126 if (link)
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
127 MochiKit.Signal.connect( link, 'onclick', get_received_bugs );
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
128
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
129 link = document.getElementById("package_bugs_link");
25
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
130 if (link)
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
131 MochiKit.Signal.connect( link, 'onclick', get_package_bugs );
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
132
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
133 link = document.getElementById("selected_bugs_link");
25
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
134 if (link)
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
135 MochiKit.Signal.connect( link, 'onclick', get_selected_bugs );
1
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
136
009ede2396ab Complete change in the look of the app.
marga
parents: 0
diff changeset
137 link = document.getElementById("tagged_bugs_link");
25
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
138 if (link)
82700cdc9687 Add support for sending comments
marga
parents: 22
diff changeset
139 MochiKit.Signal.connect( link, 'onclick', get_tagged_bugs );
0
c60a544ed178 Initial commit
marga
parents:
diff changeset
140 }
c60a544ed178 Initial commit
marga
parents:
diff changeset
141
c60a544ed178 Initial commit
marga
parents:
diff changeset
142 /*connect our event handlers right off*/
144
c93c594f1f98 toolbox: convert the toolbox into a template tag
diegoe-guest
parents: 44
diff changeset
143 MochiKit.DOM.addLoadEvent(myLoadFunction);