Add module filter by text -#2094
This commit is contained in:
parent
10b337f713
commit
988eb2e257
|
@ -388,6 +388,11 @@ $table->data['form_modules_4'][1] = html_print_select(
|
|||
true
|
||||
);
|
||||
|
||||
$table->rowstyle['form_modules_filter'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_filter'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_filter'][0] = __('Filter Modules');
|
||||
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
|
||||
|
||||
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
|
||||
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
|
||||
$table->data['form_modules_2'][0] = __('Modules');
|
||||
|
@ -1247,6 +1252,9 @@ $(document).ready (function () {
|
|||
});
|
||||
$("#module_loading").hide ();
|
||||
$("#module_name").removeAttr ("disabled");
|
||||
//Filter modules. Call the function when the select is fully loaded.
|
||||
var textNoData = "<?php echo __('None'); ?>";
|
||||
filterByText($('#module_name'), $("#text-filter_modules"), textNoData);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
|
|
@ -1223,3 +1223,42 @@ function get_explanation_recon_script(id, id_rt, url) {
|
|||
|
||||
taskManager.addTask(xhr);
|
||||
}
|
||||
|
||||
// Filter modules in a select (bulk operations)
|
||||
function filterByText(selectbox, textbox, textNoData) {
|
||||
return selectbox.each(function() {
|
||||
var select = selectbox;
|
||||
var options = [];
|
||||
$(select)
|
||||
.find("option")
|
||||
.each(function() {
|
||||
options.push({ value: $(this).val(), text: $(this).text() });
|
||||
});
|
||||
$(select).data("options", options);
|
||||
$(textbox).bind("change keyup", function() {
|
||||
var options = $(select)
|
||||
.empty()
|
||||
.scrollTop(0)
|
||||
.data("options");
|
||||
var search = $(this).val();
|
||||
var regex = new RegExp(search, "gi");
|
||||
$.each(options, function(i) {
|
||||
var option = options[i];
|
||||
if (option.text.match(regex) !== null) {
|
||||
$(select).append(
|
||||
$("<option>")
|
||||
.text(option.text)
|
||||
.val(option.value)
|
||||
);
|
||||
}
|
||||
});
|
||||
if ($(select)[0].length == 0) {
|
||||
$(select).append(
|
||||
$("<option>")
|
||||
.text(textNoData)
|
||||
.val(textNoData)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue