Added custom fields combo larger params
This commit is contained in:
parent
247343c0b6
commit
4b9f8ce202
|
@ -0,0 +1,6 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tagent_custom_fields` MODIFY COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
|
||||
COMMIT;
|
|
@ -2519,7 +2519,7 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di
|
|||
-- ----------------------------------------------------------------------
|
||||
-- Add column in table `tagent_custom_fields`
|
||||
-- ----------------------------------------------------------------------
|
||||
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT '';
|
||||
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Add column in table `tnetflow_filter`
|
||||
|
|
|
@ -931,24 +931,19 @@ foreach ($fields as $field) {
|
|||
}
|
||||
|
||||
if ($field['combo_values'] !== '') {
|
||||
$data_field[1] = html_print_select(
|
||||
$combo_values,
|
||||
'customvalue_'.$field['id_field'],
|
||||
$custom_value,
|
||||
'',
|
||||
__('None'),
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
$data_field[1] = html_print_input(
|
||||
[
|
||||
'type' => 'select_search',
|
||||
'fields' => $combo_values,
|
||||
'name' => 'customvalue_'.$field['id_field'],
|
||||
'selected' => $custom_value,
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => '',
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
'size' => '400px',
|
||||
'dropdownAutoWidth' => true,
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ if ($id_field) {
|
|||
$name = $field['name'];
|
||||
$display_on_front = $field['display_on_front'];
|
||||
$is_password_type = $field['is_password_type'];
|
||||
$combo_values = $field['combo_values'];
|
||||
$combo_values = $field['combo_values'] ? $field['combo_values'] : '';
|
||||
$is_combo_enable = $config['is_combo_enable'];
|
||||
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||
} else {
|
||||
|
@ -116,12 +116,12 @@ $table->data[4][0] = __('Combo values').ui_print_help_tip(
|
|||
__('Set values separated by comma'),
|
||||
true
|
||||
);
|
||||
$table->data[4][1] = html_print_input_text(
|
||||
$table->data[4][1] = html_print_textarea(
|
||||
'combo_values',
|
||||
3,
|
||||
65,
|
||||
io_safe_output($combo_values),
|
||||
'',
|
||||
35,
|
||||
200,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -144,7 +144,7 @@ echo '</form>';
|
|||
|
||||
<script>
|
||||
$(document).ready (function () {
|
||||
if($('input[type=hidden][name=update_field]').val() == 1 && $('input[type=text][name=combo_values]').val() != ''){
|
||||
if($('input[type=hidden][name=update_field]').val() == 1 && $('#textarea_combo_values').val() != ''){
|
||||
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||
$('#configure_field-4').show();
|
||||
$('input[type=checkbox][name=is_password_type]').change(function (e) {
|
||||
|
@ -155,7 +155,7 @@ $(document).ready (function () {
|
|||
e.preventDefault();
|
||||
});
|
||||
$('input[type=checkbox][name=is_combo_enable]').change(function (e) {
|
||||
if($('input[type=text][name=combo_values]').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
|
||||
if($('#textarea_combo_values').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
|
||||
dialog_message("#message_set_combo");
|
||||
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||
$('#configure_field-4').show();
|
||||
|
|
|
@ -819,24 +819,17 @@ foreach ($fields as $field) {
|
|||
}
|
||||
|
||||
if ($field['combo_values'] !== '') {
|
||||
$data[1] = html_print_select(
|
||||
$combo_values,
|
||||
'customvalue_'.$field['id_field'],
|
||||
$custom_value,
|
||||
'',
|
||||
__('No change'),
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
$data[1] = html_print_input(
|
||||
[
|
||||
'type' => 'select_search',
|
||||
'fields' => $combo_values,
|
||||
'name' => 'customvalue_'.$field['id_field'],
|
||||
'selected' => $custom_value,
|
||||
'nothing' => __('No change'),
|
||||
'nothing_value' => '',
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -4605,6 +4605,28 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
);
|
||||
break;
|
||||
|
||||
case 'select_search':
|
||||
$output .= html_print_select_search(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['dropdownAutoWidth']) === true) ? $data['dropdownAutoWidth'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_metaconsole_nodes':
|
||||
$output .= html_print_select_from_sql(
|
||||
'SELECT `id`, `server_name` FROM `tmetaconsole_setup`',
|
||||
|
@ -5154,3 +5176,147 @@ function html_print_datalist(
|
|||
echo $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print or return selector with search bar.
|
||||
*
|
||||
* @param string $fields Select fields
|
||||
* @param boolean $name Name of input field.
|
||||
* @param array $selected Array with dropdown values. Example:
|
||||
* $fields["value"] = "label".
|
||||
* @param string $script Javascript onChange code.
|
||||
* @param mixed $nothing Label when nothing is selected.
|
||||
* @param array $nothing_value Value when nothing is selected.
|
||||
* @param string $return Return string or dump to output.
|
||||
* @param boolean $multiple Enable multiple select.
|
||||
* @param mixed $sort Sort values or not (default false).
|
||||
* @param boolean $class CSS classes to apply.
|
||||
* @param boolean $disabled Disabled or enabled.
|
||||
* @param boolean $style CSS inline style.
|
||||
* @param string $option_style CSS inline style in array format.
|
||||
* @param string $size Style, size (width) of element.
|
||||
* @param boolean $simple_multiple_options Discovery simple multiple inputs.
|
||||
* @param boolean $required Required input.
|
||||
* @param boolean $dropdownAutoWidth Set dropdown auto width.
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_select_search(
|
||||
$fields=[],
|
||||
$name=null,
|
||||
$selected='',
|
||||
$script='',
|
||||
$nothing='',
|
||||
$nothing_value=0,
|
||||
$return=false,
|
||||
$multiple=false,
|
||||
$sort=false,
|
||||
$class='',
|
||||
$disabled=false,
|
||||
$style=false,
|
||||
$option_style=false,
|
||||
$size=false,
|
||||
$simple_multiple_options=false,
|
||||
$required=false,
|
||||
$dropdownAutoWidth=false
|
||||
) {
|
||||
$output = '';
|
||||
|
||||
ui_require_css_file('select2.min');
|
||||
ui_require_javascript_file('select2.min');
|
||||
|
||||
if ($name === null) {
|
||||
static $idcounter = [];
|
||||
if (isset($idcounter[$name]) === true) {
|
||||
$idcounter[$name]++;
|
||||
} else {
|
||||
$idcounter[$name] = 0;
|
||||
}
|
||||
|
||||
$name = 'select'.$idcounter[$name];
|
||||
}
|
||||
|
||||
if (empty($nothing) === false) {
|
||||
$fields[$nothing_value] = $nothing;
|
||||
}
|
||||
|
||||
$output .= html_print_select(
|
||||
$fields,
|
||||
$name,
|
||||
$selected,
|
||||
$script,
|
||||
$nothing,
|
||||
$nothing_value,
|
||||
$return,
|
||||
$multiple,
|
||||
$sort,
|
||||
$class,
|
||||
$disabled,
|
||||
$style,
|
||||
$option_style,
|
||||
$size,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$simple_multiple_options,
|
||||
$required
|
||||
);
|
||||
|
||||
if (empty($size) === true) {
|
||||
$size = '100%';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<style type="text/css">
|
||||
.select2-search__field {
|
||||
background: url('<?php echo ui_get_full_url('images/zoom.png'); ?>') no-repeat;
|
||||
background-position: right 10px center;
|
||||
background-size: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('select[name="<?php echo $name; ?>"]').each(
|
||||
function() {
|
||||
$(this).select2({
|
||||
multiple: <?php echo ($multiple) ? 'true' : 'false'; ?>,
|
||||
placeholder: "<?php echo __('Please select...'); ?>",
|
||||
debug: 0,
|
||||
width: '<?php echo $size; ?>',
|
||||
dropdownAutoWidth : '<?php echo $dropdownAutoWidth; ?>',
|
||||
templateResult: function(node) {
|
||||
if (!node.id) {
|
||||
return node.text;
|
||||
}
|
||||
return $('<span style="padding-left:' + (5 * node.level) + 'px;">' + node.text + '</span>');
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
<?php
|
||||
if (empty($fields) === true) {
|
||||
?>
|
||||
$('select[name="<?php echo $name; ?>"]').val(null).trigger("change");
|
||||
$('select[name="<?php echo $name; ?>"] option[value=""]').each(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$output .= ob_get_clean();
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
}
|
|
@ -2050,7 +2050,7 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields` (
|
|||
`name` varchar(45) NOT NULL default '',
|
||||
`display_on_front` tinyint(1) NOT NULL default 0,
|
||||
`is_password_type` tinyint(1) NOT NULL default 0,
|
||||
`combo_values` VARCHAR(255) DEFAULT '',
|
||||
`combo_values` TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id_field`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue