Patchwork [6/9] error-report: remember state of the menu

login
register
mail settings
Submitter Roxana
Date Aug. 22, 2014, 8:49 a.m.
Message ID <2dc12c2d3d7a743194eb4a73be664822d0d0cb70.1408696291.git.roxana.ciobanu@intel.com>
Download mbox | patch
Permalink /patch/78821/
State New
Headers show

Comments

Roxana - Aug. 22, 2014, 8:49 a.m.
Remember the state of the menu, so that people are
not forced to customise the columns every
time they search.

[YOCTO #6538]

Signed-off-by: Roxana Ciobanu <roxana.ciobanu@intel.com>
---
 templates/base.html           |  2 +-
 templates/search-details.html | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

Patch

diff --git a/templates/base.html b/templates/base.html
index 01453c7..a6f0cf0 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -60,7 +60,7 @@ 
 		<script type = "text/javascript" src = "{% static "js/bootstrap.min.js" %}"></script>
 		<script type = "text/javascript" src = "{% static "js/d3.v2.js" %}"></script>
 		<script type = "text/javascript" src = "{% static "js/nv.d3.js" %}"></script>
-		
+	    <script type = "text/javascript" src = "{% static "js/jquery.cookie.js" %}"></script>
 		{% block content %}{% endblock %}
 	</body>
 </html>
diff --git a/templates/search-details.html b/templates/search-details.html
index 269aa62..fb1f3c1 100644
--- a/templates/search-details.html
+++ b/templates/search-details.html
@@ -14,6 +14,15 @@ 
 			else {
 				$('.' + clname ).hide( 100 );
 			}
+			// save cookie for all checkboxes$
+			save = '';
+			$( '.chbxtoggle' ).each(function( ) {
+				if ( $( this ).attr( 'id' ) != undefined ) {
+					save += ';' + $( this ).attr( 'id' ) +':'+ $( this ).is( ':checked' )
+				}
+			});
+			$.cookie( '_displaycols_{{objectname}}', save );
+			save = '';
 		}
 		</script>
 
@@ -163,6 +172,25 @@ 
 				<script>
 				$(document).ready(function() {
 					$('.commit > div').popover({placement:'left'})
+
+					// we load cookies for the column display$
+					save = $.cookie('_displaycols_{{objectname}}');
+					if (save != undefined) {
+						setting = save.split(';');
+						for ( i = 0; i < setting.length; i++) {
+							if (setting[i].length > 0) {
+								splitlist = setting[i].split(':');
+								id = splitlist[0], v = splitlist[1];
+								if (v == 'true') {
+									$('.chbxtoggle#'+id).prop('checked', true);
+								}
+								else {
+									$('.chbxtoggle#'+id).prop('checked', false);
+								}
+							}
+						}
+					}
+					
 					$('.chbxtoggle').each(function () {
 						showhideTableColumn($(this).attr('id'), $(this).is(':checked'))
 					});