support filter for NIS net groups
This commit is contained in:
parent
0807a1b741
commit
e0d291378e
|
@ -418,6 +418,8 @@ class htmlInputField extends htmlElement {
|
||||||
protected $fieldMaxLength = 255;
|
protected $fieldMaxLength = 255;
|
||||||
/** on keypress event */
|
/** on keypress event */
|
||||||
protected $onKeyPress = null;
|
protected $onKeyPress = null;
|
||||||
|
/** on keyupp event */
|
||||||
|
protected $onKeyUp = null;
|
||||||
/** password field */
|
/** password field */
|
||||||
protected $isPassword = false;
|
protected $isPassword = false;
|
||||||
/** check password strength */
|
/** check password strength */
|
||||||
|
@ -535,11 +537,15 @@ class htmlInputField extends htmlElement {
|
||||||
if ($this->onKeyPress != null) {
|
if ($this->onKeyPress != null) {
|
||||||
$onKeyPress = ' onkeypress="' . $this->onKeyPress . '"';
|
$onKeyPress = ' onkeypress="' . $this->onKeyPress . '"';
|
||||||
}
|
}
|
||||||
|
$onKeyUp = '';
|
||||||
|
if ($this->onKeyUp != null) {
|
||||||
|
$onKeyUp = ' onkeyup="' . $this->onKeyUp . '"';
|
||||||
|
}
|
||||||
$title = '';
|
$title = '';
|
||||||
if (!empty($this->title)) {
|
if (!empty($this->title)) {
|
||||||
$title = ' title="' . $this->title . '"';
|
$title = ' title="' . $this->title . '"';
|
||||||
}
|
}
|
||||||
echo '<input type="' . $inputType . '"' . $class . $name . $id . $value . $maxLength . $size . $fieldTabIndex . $onKeyPress . $title . $disabled . '>';
|
echo '<input type="' . $inputType . '"' . $class . $name . $id . $value . $maxLength . $size . $fieldTabIndex . $onKeyPress . $onKeyUp . $title . $disabled . '>';
|
||||||
// autocompletion
|
// autocompletion
|
||||||
if ($this->autocomplete) {
|
if ($this->autocomplete) {
|
||||||
echo "<script type=\"text/javascript\">\n";
|
echo "<script type=\"text/javascript\">\n";
|
||||||
|
@ -723,6 +729,15 @@ class htmlInputField extends htmlElement {
|
||||||
$this->onKeyPress = $onKeyPress;
|
$this->onKeyPress = $onKeyPress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the JavaScript for the onKeyUp event.
|
||||||
|
*
|
||||||
|
* @param String $onKeyUp JavaScript code
|
||||||
|
*/
|
||||||
|
public function setOnKeyUp($onKeyUp) {
|
||||||
|
$this->onKeyUp = $onKeyUp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a calendar when the field is selected.
|
* Shows a calendar when the field is selected.
|
||||||
*
|
*
|
||||||
|
|
|
@ -192,6 +192,15 @@ class nisNetGroupUser extends baseModule {
|
||||||
$addButton = new htmlButton('addGroup', 'add.png', true);
|
$addButton = new htmlButton('addGroup', 'add.png', true);
|
||||||
$addButton->setTitle(_('Add'));
|
$addButton->setTitle(_('Add'));
|
||||||
$return->addElement($addButton, true);
|
$return->addElement($addButton, true);
|
||||||
|
|
||||||
|
$filterGroup = new htmlGroup();
|
||||||
|
$filterGroup->alignment = htmlElement::ALIGN_RIGHT;
|
||||||
|
$filterGroup->addElement(new htmlOutputText(_('Filter') . ' '));
|
||||||
|
$filter = new htmlInputField('group_filter');
|
||||||
|
$filter->setFieldSize('5em');
|
||||||
|
$filter->setOnKeyUp('filterSelect(\'group_filter\', \'group_add\', event);');
|
||||||
|
$filterGroup->addElement($filter);
|
||||||
|
$return->addElement($filterGroup, true);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,3 +615,33 @@ function updateModulePositions(id, oldPos, newPos) {
|
||||||
}
|
}
|
||||||
jQuery('#' + id).val(positions.join(','));
|
jQuery('#' + id).val(positions.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters a select box by the value of the filter input field.
|
||||||
|
*
|
||||||
|
* @param filterInput ID of input field for filter
|
||||||
|
* @param select ID of select box to filter
|
||||||
|
* @param event key event
|
||||||
|
*/
|
||||||
|
function filterSelect(filterInput, select, event) {
|
||||||
|
// if values were not yet saved, save them
|
||||||
|
if (!jQuery('#' + select).data('options')) {
|
||||||
|
var options = [];
|
||||||
|
jQuery('#' + select).find('option').each(function() {
|
||||||
|
options.push({value: $(this).val(), text: $(this).text()});
|
||||||
|
});
|
||||||
|
jQuery('#' + select).data('options', options);
|
||||||
|
}
|
||||||
|
// get matching values
|
||||||
|
var list = jQuery('#' + select).empty().scrollTop(0).data('options');
|
||||||
|
var search = jQuery.trim(jQuery('#' + filterInput).val());
|
||||||
|
var regex = new RegExp(search,'gi');
|
||||||
|
jQuery.each(list, function(i) {
|
||||||
|
var option = list[i];
|
||||||
|
if(option.text.match(regex) !== null) {
|
||||||
|
jQuery('#' + select).append(
|
||||||
|
jQuery('<option>').text(option.text).val(option.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue