From d72aaef520f381fce2f247d752c01821c8596622 Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Tue, 2 Feb 2016 15:47:54 -0500 Subject: Added priv filter capability --- src/usr/local/www/system_groupmanager_addprivs.php | 66 +++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'src/usr/local/www/system_groupmanager_addprivs.php') diff --git a/src/usr/local/www/system_groupmanager_addprivs.php b/src/usr/local/www/system_groupmanager_addprivs.php index 6819e39..222501e 100644 --- a/src/usr/local/www/system_groupmanager_addprivs.php +++ b/src/usr/local/www/system_groupmanager_addprivs.php @@ -209,6 +209,34 @@ $section->addInput(new Form_Select( true ))->addClass('multiselect')->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.')->setAttribute('style', 'height:400px;'); +$section->addInput(new Form_Input( + 'filtertxt', + 'Filter', + 'text', + null +))->setHelp('Show only the choices containing this term'); + +$btnfilter = new Form_Button( + 'btnfilter', + 'Filter', + null, + 'fa-filter' +); + +$btnfilter->addClass('btn btn-info'); + +$form->addGlobal($btnfilter); + +$btnclear = new Form_Button( + 'btnclear', + 'Clear', + null, + 'fa-times' +); + +$btnclear->addClass('btn btn-warning'); + +$form->addGlobal($btnclear); $form->add($section); print $form; @@ -245,7 +273,43 @@ events.push(function() { // When the 'sysprivs" selector is clicked, we display a description $('.multiselect').click(function() { - $('#pdesc').html('' + descs[$(this).children('option:selected').index()] + ''); + $('#pdesc').html('' + descs[$(this).children('option:selected').index()] + ''); + }); + + $('#btnfilter').prop('type', 'button'); + + $('#btnfilter').click(function() { + searchterm = $('#filtertxt').val().toLowerCase(); + + $(".multiselect > option").each(function() { + if (this.text.toLowerCase().indexOf(searchterm) > -1 ) { + $(this).show(); + } else { + $(this).hide(); + } + }); + }); + + $('#btnclear').prop('type', 'button'); + + $('#btnclear').click(function() { + $(".multiselect > option").each(function() { + $(this).show(); + }); + }); + + $('#filtertxt').keypress(function(e) { + if(e.which == 13) { + e.preventDefault(); + $('#btnfilter').trigger('click'); + } + }); + + // On submit unhide all options (or else they will not submit) + $('form').submit(function() { + $(".multiselect > option").each(function() { + $(this).show(); + }); }); }); //]]> -- cgit v1.1