Use localStorage to save/restore signoffs filters

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2014-03-09 11:40:58 -05:00
parent 81a2051e34
commit 2e06e74d3a
2 changed files with 19 additions and 0 deletions

View File

@ -444,6 +444,7 @@ function filter_signoffs() {
$('#filter-count').text(rows.length);
/* make sure we update the odd/even styling from sorting */
$('.results').trigger('applyWidgets', [false]);
filter_signoffs_save();
}
function filter_signoffs_reset() {
$('#signoffs_filter .arch_filter').attr('checked', 'checked');
@ -451,6 +452,23 @@ function filter_signoffs_reset() {
$('#id_pending').removeAttr('checked');
filter_signoffs();
}
function filter_signoffs_save() {
var state = $('#signoffs_filter').serializeArray();
localStorage['filter_signoffs'] = JSON.stringify(state);
}
function filter_signoffs_load() {
var state = localStorage['filter_signoffs'];
if (!state)
return;
state = JSON.parse(state);
$('#signoffs_filter .arch_filter').removeAttr('checked');
$('#signoffs_filter .repo_filter').removeAttr('checked');
$('#id_pending').removeAttr('checked');
$.each(state, function (i, v) {
// this assumes our only filters are checkboxes
$('#signoffs_filter input[name="' + v['name'] + '"]').attr('checked', 'checked');
});
}
function collapseNotes(elements) {
// Remove any trailing <br/> tags from the note contents

View File

@ -93,6 +93,7 @@ <h3>Filter Displayed Signoffs</h3>
$('#signoffs_filter input').change(filter_signoffs);
$('#criteria_reset').click(filter_signoffs_reset);
// fire function on page load to ensure the current form selections take effect
filter_signoffs_load();
filter_signoffs();
});
$(document).ready(function() {