1
|
|
|
function pre_process_data(data) { |
2
|
|
|
var component_cache = {}; |
3
|
|
|
var tags_cache = {}; |
4
|
|
|
|
5
|
|
|
data.forEach(function(element) { |
6
|
|
|
addResourceToData(element, 'component', 'Component.filter', component_cache); |
7
|
|
|
addResourceToData(element, 'tag', 'Tag.filter', tags_cache); |
8
|
|
|
}); |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
$(document).ready(function() { |
13
|
|
|
var table = $("#resultsTable").DataTable({ |
14
|
|
|
ajax: function(data, callback, settings) { |
|
|
|
|
15
|
|
|
var params = {}; |
16
|
|
|
|
17
|
|
|
if ($('#id_summary').val()) { |
18
|
|
|
params['summary__icontains'] = $('#id_summary').val(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
if ($('#id_before').val()) { |
22
|
|
|
params['create_date__lte'] = $('#id_before').data('DateTimePicker').date().format('YYYY-MM-DD 23:59:59'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
if ($('#id_after').val()) { |
26
|
|
|
params['create_date__gte'] = $('#id_after').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if ($('#id_product').val()) { |
30
|
|
|
params['category__product'] = $('#id_product').val(); |
31
|
|
|
}; |
32
|
|
|
|
33
|
|
|
if ($('#id_category').val()) { |
34
|
|
|
params['category'] = $('#id_category').val(); |
35
|
|
|
}; |
36
|
|
|
|
37
|
|
|
if ($('#id_component').val()) { |
38
|
|
|
params['component'] = $('#id_component').val(); |
39
|
|
|
}; |
40
|
|
|
|
41
|
|
|
if ($('#id_priority').val().length > 0) { |
42
|
|
|
params['priority__in'] = $('#id_priority').val(); |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
if ($('#id_status').val().length > 0) { |
46
|
|
|
params['case_status__in'] = $('#id_status').val(); |
47
|
|
|
}; |
48
|
|
|
|
49
|
|
|
if ($('#id_author').val()) { |
50
|
|
|
params['author__username__startswith'] = $('#id_author').val(); |
51
|
|
|
}; |
52
|
|
|
|
53
|
|
|
if ($('input[name=is_automated]:checked').val() === 'true') { |
54
|
|
|
params['is_automated'] = true; |
55
|
|
|
}; |
56
|
|
|
|
57
|
|
|
if ($('input[name=is_automated]:checked').val() === 'false') { |
58
|
|
|
params['is_automated'] = false; |
59
|
|
|
}; |
60
|
|
|
|
61
|
|
|
updateParamsToSearchTags('#id_tag', params); |
62
|
|
|
|
63
|
|
|
var bug_list = splitByComma($('#id_bugs').val()); |
64
|
|
|
if (bug_list.length > 0) { |
65
|
|
|
params['case_bug__bug_id__in'] = bug_list; |
66
|
|
|
}; |
67
|
|
|
|
68
|
|
|
dataTableJsonRPC('TestCase.filter', params, callback, pre_process_data); |
69
|
|
|
}, |
70
|
|
|
columns: [ |
71
|
|
|
{ data: "case_id" }, |
72
|
|
|
{ |
73
|
|
|
data: null, |
74
|
|
|
render: function (data, type, full, meta) { |
|
|
|
|
75
|
|
|
return '<a href="/case/'+ data.case_id + '/" target="_parent">' + escapeHTML(data.summary) + '</a>'; |
76
|
|
|
} |
77
|
|
|
}, |
78
|
|
|
{ data: "create_date"}, |
79
|
|
|
{ data: "category"}, |
80
|
|
|
{ |
81
|
|
|
data: "component", |
82
|
|
|
render: renderFromCache, |
|
|
|
|
83
|
|
|
}, |
84
|
|
|
{ data: "priority" }, |
85
|
|
|
{ data: "case_status"}, |
86
|
|
|
{ data: "is_automated" }, |
87
|
|
|
{ data: "author" }, |
88
|
|
|
{ |
89
|
|
|
data: "tag", |
90
|
|
|
render: renderFromCache, |
91
|
|
|
}, |
92
|
|
|
], |
93
|
|
|
dom: "t", |
94
|
|
|
language: { |
95
|
|
|
loadingRecords: '<div class="spinner spinner-lg"></div>', |
96
|
|
|
processing: '<div class="spinner spinner-lg"></div>', |
97
|
|
|
zeroRecords: "No records found" |
98
|
|
|
}, |
99
|
|
|
order: [[ 0, 'asc' ]], |
100
|
|
|
}); |
101
|
|
|
|
102
|
|
|
hookIntoPagination('#resultsTable', table); |
103
|
|
|
|
104
|
|
|
$('#btn_search').click(function() { |
105
|
|
|
table.ajax.reload(); |
106
|
|
|
return false; // so we don't actually send the form |
107
|
|
|
}); |
108
|
|
|
|
109
|
|
|
$('#id_product').change(function() { |
110
|
|
|
var updateCategory = function(data) { |
111
|
|
|
updateSelect(data, '#id_category', 'id', 'name'); |
112
|
|
|
} |
113
|
|
|
var updateComponent = function(data) { |
114
|
|
|
updateSelect(data, '#id_component', 'id', 'name'); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
var product_id = $(this).val(); |
118
|
|
|
if (product_id) { |
119
|
|
|
jsonRPC('Category.filter', {product: product_id}, updateCategory); |
120
|
|
|
jsonRPC('Component.filter', {product: product_id}, updateComponent); |
121
|
|
|
} else { |
122
|
|
|
updateCategory([]); |
123
|
|
|
updateComponent([]); |
124
|
|
|
} |
125
|
|
|
}); |
126
|
|
|
|
127
|
|
|
$('.selectpicker').selectpicker(); |
128
|
|
|
}); |
129
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.