From 268317dd331bcdbe1c2828583034c0274a19eea3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 9 Mar 2014 11:58:51 -0500 Subject: Use localStorage to save/restore developer report filters Signed-off-by: Dan McGee --- devel/views.py | 1 + sitestatic/archweb.js | 16 ++++++++++++++++ templates/devel/packages.html | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/devel/views.py b/devel/views.py index c53da66..972d0ab 100644 --- a/devel/views.py +++ b/devel/views.py @@ -201,6 +201,7 @@ def report(request, report_name, username=None): context = { 'all_maintainers': maints, 'title': report.description, + 'report': report, 'maintainer': user, 'packages': report.packages(packages, username), 'arches': sorted(arches), diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index 457e334..0a97949 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -386,6 +386,22 @@ function filter_todolist_load(list_id) { }); } +function filter_report_save(report_id) { + var state = $('#report_filter').serializeArray(); + localStorage['filter_report_' + report_id] = JSON.stringify(state); +} +function filter_report_load(report_id) { + var state = localStorage['filter_report_' + report_id]; + if (!state) + return; + state = JSON.parse(state); + $('#report_filter input[type="checkbox"]').removeAttr('checked') + $.each(state, function (i, v) { + // this assumes our only filters are checkboxes + $('#report_filter input[name="' + v['name'] + '"]').attr('checked', 'checked'); + }); +} + /* signoffs.html */ function signoff_package() { // TODO: fix usage of this diff --git a/templates/devel/packages.html b/templates/devel/packages.html index 74aebf2..c190ab0 100644 --- a/templates/devel/packages.html +++ b/templates/devel/packages.html @@ -84,10 +84,14 @@ $(document).ready(function() { $(".results").tablesorter({widgets: ['zebra']}); }); $(document).ready(function() { - var filter_func = function() { filter_pkgs_list('#report_filter', '#dev-report-results tbody'); }; + var filter_func = function() { + filter_pkgs_list('#report_filter', '#dev-report-results tbody'); + filter_report_save('{{ report.slug }}'); + }; $('#report_filter input').change(filter_func); $('#criteria_reset').click(function() { filter_pkgs_reset(filter_func); }); // run on page load to ensure current form selections take effect + filter_report_load('{{ report.slug }}'); filter_func(); }); -- cgit v1.2.3-24-g4f1b