diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templates/basetable_top.html')
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/basetable_top.html | 172 |
1 files changed, 159 insertions, 13 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_top.html b/bitbake/lib/toaster/toastergui/templates/basetable_top.html index 22c389799a..1231e1f924 100644 --- a/bitbake/lib/toaster/toastergui/templates/basetable_top.html +++ b/bitbake/lib/toaster/toastergui/templates/basetable_top.html | |||
@@ -1,17 +1,42 @@ | |||
1 | {% load projecttags %} | 1 | {% load projecttags %} |
2 | <!-- component to display a generic table --> | 2 | <!-- component to display a generic table --> |
3 | <script> | 3 | <script> |
4 | function showhideTableColumn(clname, sh) { | ||
5 | if (sh) $('.' + clname).show(100); | ||
6 | else $('.' + clname).hide(100); | ||
7 | 4 | ||
8 | // save cookie for all checkboxes | 5 | // |
9 | save = ''; | 6 | // most of the following javascript is for managing the 'Edit Columns' |
10 | $('.chbxtoggle').each(function() { if ($(this).attr('id') != undefined) { save += ';' + $(this).attr('id') +':'+ $(this).is(':checked')} }) | 7 | // pop-up dialog and actions. the idea is that there are 2 types |
11 | $.cookie('_displaycols_{{objectname}}', save); | 8 | // of actions: immediate - performed while the dialog is still |
12 | save = ''; | 9 | // visible - hide/show columns, and delayed - performed when the |
13 | } | 10 | // dialog becomes invisible - any resorting if necessary. |
11 | // | ||
12 | // When the dialog is open, an interval timer is set up to | ||
13 | // determine if the dialog is still visible. when the dialog | ||
14 | // closes - goes invisible, the delayed actions are performed. | ||
15 | // | ||
16 | // the interval timer and interrupt handler is a way of simulating | ||
17 | // an onclose event. there is probably a simpler way to do this | ||
18 | // however the pop-up window id was elusive. | ||
19 | // | ||
20 | |||
21 | var editColTimer; | ||
22 | var editColAction; | ||
14 | 23 | ||
24 | // | ||
25 | // this is the target function of the interval timeout. | ||
26 | // check to see if the dialog is visible. if the dialog | ||
27 | // has gone invisible since the last check, take any delayed | ||
28 | // actions indicated in the action list and clear the timer. | ||
29 | // | ||
30 | |||
31 | function checkVisible( ) { | ||
32 | editcol = document.getElementById( 'editcol' ); | ||
33 | if ( editcol.offsetWidth <= 0 ) { | ||
34 | clearInterval( editColTimer ); | ||
35 | editColTimer = false; | ||
36 | hideshowColumns( ); | ||
37 | editColAction = [ ]; | ||
38 | } | ||
39 | } | ||
15 | 40 | ||
16 | function filterTableRows(test) { | 41 | function filterTableRows(test) { |
17 | if (test.length > 0) { | 42 | if (test.length > 0) { |
@@ -24,6 +49,113 @@ | |||
24 | $('tr.data').show(); | 49 | $('tr.data').show(); |
25 | } | 50 | } |
26 | } | 51 | } |
52 | |||
53 | // | ||
54 | // determine the value of the indicated url arg. | ||
55 | // this is needed to determine whether a resort | ||
56 | // is necessary. it looks like a lot of gorp stuff | ||
57 | // but its actually pretty simple. | ||
58 | // | ||
59 | |||
60 | function getURLParameter( name ) { | ||
61 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + | ||
62 | '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, | ||
63 | '%20'))||null | ||
64 | } | ||
65 | |||
66 | // | ||
67 | // when the dialog box goes invisible | ||
68 | // this function is called to interpret | ||
69 | // the action list and take any delayed actions necessary. | ||
70 | // the editColAction list is a hash table with | ||
71 | // the column name as the hash key, the hash value | ||
72 | // is a 2 element list. the first element is a flag | ||
73 | // indicating whether the column is on or off. the | ||
74 | // 2nd element is the sort order indicator for the column. | ||
75 | // | ||
76 | |||
77 | function hideshowColumns( ) { | ||
78 | for( var k in editColAction ) { | ||
79 | showhideDelayedTableAction( k, editColAction[ k ][ 0 ], editColAction[ k ][ 1 ]); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | // | ||
84 | // this function actually performs the delayed table actions | ||
85 | // namely any resorting if necessary | ||
86 | // | ||
87 | |||
88 | function showhideDelayedTableAction( clname, sh, orderkey ) { | ||
89 | if ( !sh ) { | ||
90 | p = getURLParameter( "orderby" ).split( ":" )[ 0 ]; | ||
91 | if ( p == orderkey ) { | ||
92 | reload_params({ 'orderby' : '{{default_orderby}}'}); | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | |||
97 | // | ||
98 | // this function actually performs the immediate table actions | ||
99 | // namely any colums that need to be hidden/shown | ||
100 | // | ||
101 | |||
102 | function showhideImmediateTableAction( clname, sh, orderkey ) { | ||
103 | if ( sh ) { | ||
104 | $( '.' + clname ).show( 100 ); | ||
105 | } | ||
106 | else { | ||
107 | $( '.' + clname ).hide( 100 ); | ||
108 | } | ||
109 | |||
110 | // save cookie for all checkboxes | ||
111 | save = ''; | ||
112 | $( '.chbxtoggle' ).each(function( ) { | ||
113 | if ( $( this ).attr( 'id' ) != undefined ) { | ||
114 | save += ';' + $( this ).attr( 'id' ) +':'+ $( this ).is( ':checked' ) | ||
115 | } | ||
116 | }); | ||
117 | $.cookie( '_displaycols_{{objectname}}', save ); | ||
118 | save = ''; | ||
119 | } | ||
120 | |||
121 | // | ||
122 | // this is the onclick handler for all of the check box | ||
123 | // items in edit columns dialog | ||
124 | // | ||
125 | |||
126 | function showhideTableColumn( clname, sh, orderkey ) { | ||
127 | editcol = document.getElementById( 'editcol' ); | ||
128 | if ( editcol.offsetWidth <= 0 ) { | ||
129 | |||
130 | // | ||
131 | // this path is taken when the page is first | ||
132 | // getting initialized - no dialog visible, | ||
133 | // perform both the immediate and delayed actions | ||
134 | // | ||
135 | |||
136 | showhideImmediateTableAction( clname, sh, orderkey ); | ||
137 | showhideDelayedTableAction( clname, sh, orderkey ); | ||
138 | return; | ||
139 | } | ||
140 | if ( !editColTimer ) { | ||
141 | |||
142 | // | ||
143 | // we don't have a timer active so set one up | ||
144 | // and clear the action list | ||
145 | // | ||
146 | |||
147 | editColTimer = setInterval( checkVisible, 250 ); | ||
148 | editColAction = [ ]; | ||
149 | } | ||
150 | |||
151 | // | ||
152 | // save the action to be taken when the dialog closes | ||
153 | // | ||
154 | |||
155 | editColAction[ clname ] = [ sh, orderkey ]; | ||
156 | showhideImmediateTableAction( clname, sh, orderkey ); | ||
157 | } | ||
158 | |||
27 | </script> | 159 | </script> |
28 | 160 | ||
29 | <!-- control header --> | 161 | <!-- control header --> |
@@ -33,7 +165,6 @@ | |||
33 | <input class="input-xxlarge" id="search" name="search" type="text" placeholder="Search {%if object_search_display %}{{object_search_display}}{%else%}{{objectname}}{%endif%}" value="{{request.GET.search}}"/>{% if request.GET.search %}<a href="javascript:$('#search').val('');searchform.submit()" class="add-on btn" tabindex="-1"><i class="icon-remove"></i></a>{%endif%} | 165 | <input class="input-xxlarge" id="search" name="search" type="text" placeholder="Search {%if object_search_display %}{{object_search_display}}{%else%}{{objectname}}{%endif%}" value="{{request.GET.search}}"/>{% if request.GET.search %}<a href="javascript:$('#search').val('');searchform.submit()" class="add-on btn" tabindex="-1"><i class="icon-remove"></i></a>{%endif%} |
34 | <input type="hidden" name="orderby" value="{{request.GET.orderby}}"> | 166 | <input type="hidden" name="orderby" value="{{request.GET.orderby}}"> |
35 | <input type="hidden" name="page" value="1"> | 167 | <input type="hidden" name="page" value="1"> |
36 | <input type="hidden" name="count" value="{{request.GET.count}}"> | ||
37 | <button class="btn" type="submit" value="Search">Search</button> | 168 | <button class="btn" type="submit" value="Search">Search</button> |
38 | </form> | 169 | </form> |
39 | <div class="pull-right"> | 170 | <div class="pull-right"> |
@@ -45,12 +176,27 @@ | |||
45 | <!-- | 176 | <!-- |
46 | {{tablecols|sortcols}} | 177 | {{tablecols|sortcols}} |
47 | --> | 178 | --> |
48 | <ul class="dropdown-menu">{% for i in tablecols|sortcols %} | 179 | <ul id='editcol' class="dropdown-menu"> |
180 | {% for i in tablecols|sortcols %} | ||
49 | <li> | 181 | <li> |
50 | <label {% if not i.clclass %} class="checkbox muted" {%else%} class="checkbox" {%endif%}> | 182 | <label {% if not i.clclass %} class="checkbox muted" {%else%} class="checkbox" {%endif%}> |
51 | <input type="checkbox" class="chbxtoggle" {% if i.clclass %}id="{{i.clclass}}" value="ct{{i.name}}" {% if not i.hidden %}checked="checked"{%endif%} onchange="showhideTableColumn($(this).attr('id'), $(this).is(':checked'))" {%else%} checked disabled {% endif %}/> {{i.name}} | 183 | <input type="checkbox" class="chbxtoggle" |
184 | {% if i.clclass %} | ||
185 | id="{{i.clclass}}" | ||
186 | value="ct{{i.name}}" | ||
187 | {% if not i.hidden %} | ||
188 | checked="checked" | ||
189 | {%endif%} | ||
190 | onclick="showhideTableColumn( | ||
191 | $(this).attr('id'), | ||
192 | $(this).is(':checked'), | ||
193 | '{{i.orderkey}}' )" | ||
194 | {%else%} | ||
195 | checked disabled | ||
196 | {% endif %}/> {{i.name}} | ||
52 | </label> | 197 | </label> |
53 | </li>{% endfor %} | 198 | </li> |
199 | {% endfor %} | ||
54 | </ul> | 200 | </ul> |
55 | </div> | 201 | </div> |
56 | {% endif %} | 202 | {% endif %} |