summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/system_groupmanager_addprivs.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/system_groupmanager_addprivs.php')
-rw-r--r--src/usr/local/www/system_groupmanager_addprivs.php121
1 files changed, 117 insertions, 4 deletions
diff --git a/src/usr/local/www/system_groupmanager_addprivs.php b/src/usr/local/www/system_groupmanager_addprivs.php
index 5882727..e1ae561 100644
--- a/src/usr/local/www/system_groupmanager_addprivs.php
+++ b/src/usr/local/www/system_groupmanager_addprivs.php
@@ -150,7 +150,7 @@ if ($_POST) {
/* if ajax is calling, give them an update message */
if (isAjax()) {
- print_info_box_np($savemsg);
+ print_info_box($savemsg, 'success');
}
function build_priv_list() {
@@ -176,7 +176,7 @@ if ($input_errors) {
}
if ($savemsg) {
- print_info_box($savemsg, success);
+ print_info_box($savemsg, 'success');
}
$tab_array = array();
@@ -207,8 +207,46 @@ $section->addInput(new Form_Select(
$a_group['priv'],
build_priv_list(),
true
-))->addClass('multiselect')->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.')->setAttribute('style', 'height:400px;');
+))->addClass('multiselect')
+ ->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.');
+$section->addInput(new Form_Select(
+ 'shadow',
+ 'Shadow',
+ null,
+ build_priv_list(),
+ true
+))->addClass('shadowselect')
+ ->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items');
+
+$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;
@@ -240,12 +278,87 @@ events.push(function() {
echo $jdescs;
}
?>
+ $('.shadowselect').parent().parent('div').addClass('hidden');
+
// Set the number of options to display
$('.multiselect').attr("size","20");
+ $('.shadowselect').attr("size","20");
// When the 'sysprivs" selector is clicked, we display a description
$('.multiselect').click(function() {
- $('#pdesc').html('<span style="color: green;">' + descs[$(this).children('option:selected').index()] + '</span>');
+ $('#pdesc').html('<span class="text-info">' + descs[$(this).children('option:selected').index()] + '</span>');
+
+ // and update the shadow list from the real list
+ $(".multiselect option").each(function() {
+ shadowoption = $('.shadowselect option').filter('[value=' + $(this).val() + ']');
+
+ if ($(this).is(':selected')) {
+ shadowoption.prop("selected", true);
+ } else {
+ shadowoption.prop("selected", false);
+ }
+ });
+ });
+
+ $('#btnfilter').prop('type', 'button');
+
+ $('#btnfilter').click(function() {
+ searchterm = $('#filtertxt').val().toLowerCase();
+ copyselect(true);
+
+ // Then filter
+ $(".multiselect > option").each(function() {
+ if (this.text.toLowerCase().indexOf(searchterm) == -1 ) {
+ $(this).remove();
+ }
+ });
+ });
+
+ $('#btnclear').prop('type', 'button');
+
+ $('#btnclear').click(function() {
+ // Copy all options from shadow to sysprivs
+ copyselect(true)
+
+ $('#filtertxt').val('');
+ });
+
+ $('#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();
+ });
+
+ $('.shadowselect').remove();
+ });
+
+ function copyselect(selected) {
+ // Copy all optionsfrom shadow to sysprivs
+ $('.multiselect').html($('.shadowselect').html());
+
+ if (selected) {
+ // Update the shadow list from the real list
+ $(".shadowselect option").each(function() {
+ multioption = $('.multiselect option').filter('[value=' + $(this).val() + ']');
+ if ($(this).is(':selected')) {
+ multioption.prop("selected", true);
+ } else {
+ multioption.prop("selected", false);
+ }
+ });
+ }
+ }
+
+ $('.multiselect').mouseup(function () {
+ $('.multiselect').trigger('click');
});
});
//]]>
OpenPOWER on IntegriCloud