Skip to content

Commit

Permalink
#301 filter for account modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Mar 22, 2024
1 parent 37e31e4 commit 0c2c43e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions lam/HISTORY
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
June 2024 8.8
- PHP 8.1 or higher required
- Samba 3: dropped support for LM password hashes (307)
- Configuration: added filter for available account modules


16.03.2024 8.7
Expand Down
17 changes: 15 additions & 2 deletions lam/templates/config/confmodules.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace LAM\CONFIG;
use htmlInputField;
use htmlJavaScript;
use \htmlTable;
use \htmlOutputText;
Expand All @@ -16,7 +17,7 @@
use \htmlGroup;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2023 Roland Gruber
Copyright (C) 2004 - 2024 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -255,10 +256,22 @@ function config_showAccountModules($type, &$container): void {
$addButton->alignment = htmlElement::ALIGN_RIGHT;
$availTable->addElement($addButton, true);
}
$availRow = new htmlResponsiveRow();
$availDiv = new htmlDiv(null, $availTable);
$availDiv->alignment = htmlElement::ALIGN_TOP;
$availDiv->setCSSClasses(['confModList']);
$container->add($availDiv, 12, 6);
$availRow->add($availDiv);
if (sizeof($availOptions) >= 10) {
$availRow->addVerticalSpacer('1rem');
$filterGroup = new htmlGroup();
$filterGroup->addElement(new htmlOutputText(_('Filter')));
$filterInput = new htmlInputField('filter_' . $type->getId());
$filterInput->setOnInput('window.lam.config.updateModuleFilter(this); return false;');
$filterInput->setTransient(true);
$filterGroup->addElement($filterInput);
$availRow->add($filterGroup);
}
$container->add($availRow, 12, 6);
}
$positions = [];
for ($i = 0; $i < sizeof($selOptions); $i++) {
Expand Down
25 changes: 25 additions & 0 deletions lam/templates/lib/500_lam.js
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,31 @@ window.lam.smtp.test = function(event, tokenName, tokenValue, okText) {
});
}

window.lam.config = window.lam.config || {};

window.lam.config.updateModuleFilter = function(inputField) {
const filterValue = inputField.value.toLowerCase();
const table = inputField.parentElement.parentElement.querySelector('table');
table.querySelectorAll('tr').forEach(row => {
let matches = false;
for (let i = 0; i < row.children.length; i++) {
const cell = row.children[i];
if (cell.children.length > 0) {
continue;
}
if (cell.innerText.toLowerCase().includes(filterValue)) {
matches = true;
}
};
if (matches) {
row.classList.remove('hidden');
}
else {
row.classList.add('hidden');
}
});
}

window.lam.richEdit = window.lam.richEdit || {};

/**
Expand Down

0 comments on commit 0c2c43e

Please sign in to comment.