1 | function get_tasks_json(object, url) { |
||
2 | var wait_html = "<tr id='child_" + object.id +"'><td colspan ='3' style='text-align:center'><img class='loading' src='" + MIDCOM_STATIC_URL + "/stock-icons/32x32/ajax-loading.gif' alt='loading' /></td></tr>", |
||
3 | row = $(object).parent().parent(); |
||
4 | row.after(wait_html); |
||
5 | $.ajax({ |
||
6 | type: "GET", |
||
7 | url: url, |
||
8 | dataType: "json", |
||
9 | success: function(json) { |
||
10 | $("#child_" + object.id).remove(); |
||
11 | if (json.length > 0) { |
||
12 | var max_rows = json.length, |
||
13 | html = "", |
||
14 | tr_class = $(object).parent().parent().attr('class'), |
||
15 | indent_class = 'expand-icon'; |
||
16 | |||
17 | if ( (!$(object).parent().parent().next()) |
||
18 | || $(object).parent().parent().next().children('th')[0]) { |
||
19 | indent_class = 'hidden-icon'; |
||
20 | } |
||
21 | |||
22 | //iterate through tasks |
||
23 | json.forEach(function(task, index) { |
||
24 | // new row |
||
25 | if (tr_class == 'even') { |
||
26 | tr_class = 'odd'; |
||
27 | } else { |
||
28 | tr_class = 'even'; |
||
29 | } |
||
30 | html += "<tr class='" + tr_class + " child_" + object.id + "'>\n"; |
||
31 | //icons |
||
32 | html += "<td class='multivalue'>"; |
||
33 | html += "<img class='" + indent_class + "' src='" + MIDCOM_STATIC_URL + "/stock-icons/16x16/line.png' /> "; |
||
34 | if (index == (max_rows - 1)) { |
||
35 | html += "<img class='expand-icon' src='" + MIDCOM_STATIC_URL + "/stock-icons/16x16/branchbottom.png' /> "; |
||
36 | } else { |
||
37 | html += "<img class='expand-icon' src='" + MIDCOM_STATIC_URL + "/stock-icons/16x16/branch.png' /> "; |
||
38 | } |
||
39 | //title & link |
||
40 | html += task.title; |
||
41 | html += "</td>\n"; |
||
42 | //dates |
||
43 | html += "<td>"; |
||
44 | html += task.start; |
||
45 | html += "</td>\n"; |
||
46 | html += "<td>"; |
||
47 | html += task.end; |
||
48 | html += "</td>\n"; |
||
49 | //sub-tasks ? |
||
50 | html += "<td>"; |
||
51 | html += "</td>\n"; |
||
52 | html += "<td></td><td></td><td></td>"; |
||
53 | //workinghours |
||
54 | html += "<td class='numeric' >"; |
||
55 | html += "<span >" + task.reported_hours + "</span> "; |
||
56 | if (task.planned_hours > 0) { |
||
57 | html += "/ <span>" + task.planned_hours + "</span>"; |
||
58 | } |
||
59 | html += "</td>\n"; |
||
60 | }); |
||
61 | row.after(html); |
||
62 | } |
||
63 | } |
||
64 | }); |
||
65 | } |
||
66 | |||
67 | function show_tasks_for_project(object, url) { |
||
68 | var position = ''; |
||
69 | if ($(".child_" + object.id).length == 0) { |
||
0 ignored issues
–
show
Best Practice
introduced
by
![]() |
|||
70 | $(".child_" + object.id).remove(); |
||
71 | if ( (!$(object).parent().parent().next()) |
||
72 | || $(object).parent().parent().next().children('th')[0]) { |
||
73 | position = 'bottom'; |
||
74 | } |
||
75 | |||
76 | object.src = MIDCOM_STATIC_URL + "/stock-icons/16x16/minus" + position + ".png"; |
||
77 | get_tasks_json(object, url); |
||
78 | } else { |
||
79 | $(".child_" + object.id).remove(); |
||
80 | if ( !$(object).parent().parent().next() |
||
81 | || $(object).parent().parent().next().children('th')[0]) { |
||
82 | position = 'bottom'; |
||
83 | } |
||
84 | object.src = MIDCOM_STATIC_URL + "/stock-icons/16x16/plus" + position + ".png"; |
||
85 | } |
||
86 | } |
||
87 |