diff options
author | David Reyna <David.Reyna@windriver.com> | 2015-03-21 18:01:38 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-25 12:39:53 +0000 |
commit | 6a934f488fd636829efbcb24058f92621e5a9fc6 (patch) | |
tree | cce4aaacc49ba4c179573de7f4ff2f2017044707 /bitbake/lib/toaster/toastergui/static/js | |
parent | e840b7a8fba16b857db4e74dd8331680a21e5eb1 (diff) | |
download | poky-6a934f488fd636829efbcb24058f92621e5a9fc6.tar.gz |
bitbake: toaster: build date range selections
Enable date range selections for build start and build complete in all
builds page for both managed and interactive mode. Disable the filter
counts.
[YOCTO #6040]
[YOCTO #7249]
[YOCTO #7461]
(Bitbake rev: 7c86ed5fb51c6237fa40fb454e58564ef027dd51)
Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/static/js/filtersnippet.js | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/filtersnippet.js b/bitbake/lib/toaster/toastergui/static/js/filtersnippet.js new file mode 100755 index 0000000000..27b057e64e --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/filtersnippet.js | |||
@@ -0,0 +1,95 @@ | |||
1 | "use strict" | ||
2 | |||
3 | // The disable removes the 'datepicker' attribute and | ||
4 | // settings, so you have to re-initialize it each time | ||
5 | // the date range is selected and enabled | ||
6 | // DOM is used instead of jQuery to find the elements | ||
7 | // in all contexts | ||
8 | function date_enable (key, action) { | ||
9 | |||
10 | var elemFrom=document.getElementById("date_from_"+key); | ||
11 | var elemTo=document.getElementById("date_to_"+key); | ||
12 | |||
13 | if ('enable' == action) { | ||
14 | elemFrom.removeAttribute("disabled"); | ||
15 | elemTo.removeAttribute("disabled"); | ||
16 | |||
17 | $(elemFrom).datepicker(); | ||
18 | $(elemTo).datepicker(); | ||
19 | |||
20 | $(elemFrom).datepicker( "option", "dateFormat", "dd/mm/yy" ); | ||
21 | $(elemTo).datepicker( "option", "dateFormat", "dd/mm/yy" ); | ||
22 | |||
23 | $(elemFrom).datepicker( "setDate", elemFrom.getAttribute( "data-setDate") ); | ||
24 | $(elemTo).datepicker( "setDate", elemTo.getAttribute( "data-setDate") ); | ||
25 | $(elemFrom).datepicker( "option", "minDate", elemFrom.getAttribute( "data-minDate")); | ||
26 | $(elemTo).datepicker( "option", "minDate", elemTo.getAttribute( "data-minDate")); | ||
27 | $(elemFrom).datepicker( "option", "maxDate", elemFrom.getAttribute( "data-maxDate")); | ||
28 | $(elemTo).datepicker( "option", "maxDate", elemTo.getAttribute( "data-maxDate")); | ||
29 | } else { | ||
30 | elemFrom.setAttribute("disabled","disabled"); | ||
31 | elemTo.setAttribute("disabled","disabled"); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | // Initialize the date picker elements with their default state variables, and | ||
36 | // register the radio button and form actions | ||
37 | function date_init (key, from_date, to_date, min_date, max_date, initial_enable) { | ||
38 | |||
39 | var elemFrom=document.getElementById("date_from_"+key); | ||
40 | var elemTo=document.getElementById("date_to_"+key); | ||
41 | |||
42 | // Were there any daterange filters instantiated? (e.g. no builds found) | ||
43 | if (null == elemFrom) { | ||
44 | return; | ||
45 | } | ||
46 | |||
47 | // init the datepicker context data | ||
48 | elemFrom.setAttribute( "data-setDate", from_date ); | ||
49 | elemTo.setAttribute( "data-setDate", to_date ); | ||
50 | elemFrom.setAttribute( "data-minDate", min_date); | ||
51 | elemTo.setAttribute( "data-minDate", min_date); | ||
52 | elemFrom.setAttribute( "data-maxDate", max_date); | ||
53 | elemTo.setAttribute( "data-maxDate", max_date); | ||
54 | |||
55 | // does the date set start enabled? | ||
56 | if (key == initial_enable) { | ||
57 | date_enable (key, "enable"); | ||
58 | } else { | ||
59 | date_enable (key, "disable"); | ||
60 | } | ||
61 | |||
62 | // catch the radio button selects for enable/disable | ||
63 | $('input:radio[name="filter"]').change(function(){ | ||
64 | if ($(this).val() == 'daterange') { | ||
65 | key=$(this).attr("data-key"); | ||
66 | date_enable (key, 'enable'); | ||
67 | } else { | ||
68 | key=$(this).attr("data-key"); | ||
69 | date_enable (key, 'disable'); | ||
70 | } | ||
71 | }); | ||
72 | |||
73 | // catch any new 'from' date as minDate for 'to' date | ||
74 | $("#date_from_"+key).change(function(){ | ||
75 | from_date = $("#date_from_"+key).val(); | ||
76 | $("#date_to_"+key).datepicker( "option", "minDate", from_date ); | ||
77 | }); | ||
78 | |||
79 | // catch the submit (just once) | ||
80 | $("form").unbind('submit'); | ||
81 | $("form").submit(function(e) { | ||
82 | // format a composite daterange filter value so that it can be parsed and post-processed in the view | ||
83 | var key=e.originalEvent.explicitOriginalTarget.getAttribute("data-key") | ||
84 | if (typeof key != "undefined") { | ||
85 | if ($("#date_from_"+key).length) { | ||
86 | var filter=key+"__gte!"+key+"__lt:"+$("#date_from_"+key).val()+"!"+$("#date_to_"+key).val()+"_daterange"; | ||
87 | $("#last_date_from_"+key).val($("#date_from_"+key).val()); | ||
88 | $("#last_date_to_"+key).val($("#date_to_"+key).val()); | ||
89 | $("#filter_value_"+key).val(filter); | ||
90 | } | ||
91 | } | ||
92 | return true; | ||
93 | }); | ||
94 | |||
95 | }; | ||