dynamic toggle in wizard input printForm

This commit is contained in:
fbsanchez 2019-11-14 17:45:45 +01:00
parent 3c87efe113
commit 0d3817d64d
4 changed files with 70 additions and 25 deletions

View File

@ -441,6 +441,10 @@ function quickShellSettings()
'value' => $config['gotty_telnet_port'], 'value' => $config['gotty_telnet_port'],
], ],
], ],
[
'toggle' => true,
'toggle_name' => 'Advanced',
'block_content' => [
[ [
'label' => __('Gotty user').ui_print_help_tip( 'label' => __('Gotty user').ui_print_help_tip(
__('Optional, set a user to access gotty service'), __('Optional, set a user to access gotty service'),
@ -463,6 +467,8 @@ function quickShellSettings()
'value' => io_output_password($config['gotty_pass']), 'value' => io_output_password($config['gotty_pass']),
], ],
], ],
],
],
[ [
'arguments' => [ 'arguments' => [
'type' => 'hidden', 'type' => 'hidden',

View File

@ -458,6 +458,7 @@ class Wizard
if (is_array($input['block_content']) === true) { if (is_array($input['block_content']) === true) {
$direct = (bool) $input['direct']; $direct = (bool) $input['direct'];
$toggle = (bool) $input['toggle'];
// Print independent block of inputs. // Print independent block of inputs.
$output .= '<li id="li-'.$input['block_id'].'" class="'.$class.'">'; $output .= '<li id="li-'.$input['block_id'].'" class="'.$class.'">';
@ -471,14 +472,37 @@ class Wizard
$output .= '<ul class="wizard '.$input['block_class'].'">'; $output .= '<ul class="wizard '.$input['block_class'].'">';
} }
foreach ($input['block_content'] as $input) { $html = '';
$output .= $this->printBlock(
$input, foreach ($input['block_content'] as $in) {
$html .= $this->printBlock(
$in,
$return, $return,
(bool) $direct (bool) $direct
); );
} }
if ($toggle === true) {
$output .= ui_print_toggle(
[
'name' => (isset($input['toggle_name']) ? $input['toggle_name'] : 'toggle_'.uniqid()),
'content' => $html,
'title' => $input['toggle_title'],
'id' => $input['toggle_id'],
'hidden_default' => $input['toggle_hidden_default'],
'return' => (isset($input['toggle_return']) ? $input['toggle_return'] : true),
'toggle_class' => $input['toggle_toggle_class'],
'main_class' => $input['toggle_main_class'],
'container_class' => $input['toggle_container_class'],
'img_a' => $input['toggle_img_a'],
'img_b' => $input['toggle_img_b'],
'clean' => (isset($input['toggle_clean']) ? $input['toggle_clean'] : true),
]
);
} else {
$output .= $html;
}
// Close block. // Close block.
if (!$direct) { if (!$direct) {
$output .= '</ul>'; $output .= '</ul>';

View File

@ -3667,6 +3667,7 @@ function ui_print_event_priority(
* @param string $main_class Main object class. * @param string $main_class Main object class.
* @param string $img_a Image (closed). * @param string $img_a Image (closed).
* @param string $img_b Image (opened). * @param string $img_b Image (opened).
* @param string $clean Do not encapsulate with class boxes, clean print.
* *
* @return string HTML. * @return string HTML.
*/ */
@ -3681,7 +3682,8 @@ function ui_toggle(
$container_class='white-box-content', $container_class='white-box-content',
$main_class='box-shadow white_table_graph', $main_class='box-shadow white_table_graph',
$img_a='images/arrow_down_green.png', $img_a='images/arrow_down_green.png',
$img_b='images/arrow_right_green.png' $img_b='images/arrow_right_green.png',
$clean=false
) { ) {
// Generate unique Id. // Generate unique Id.
$uniqid = uniqid(''); $uniqid = uniqid('');
@ -3697,9 +3699,17 @@ function ui_toggle(
$original = $img_a; $original = $img_a;
} }
$header_class = '';
if ($clean === false) {
$header_class = 'white_table_graph_header';
} else {
$main_class = '';
$container_class = 'white-box-content-clean';
}
// Link to toggle. // Link to toggle.
$output = '<div class="'.$main_class.'" id="'.$id.'">'; $output = '<div class="'.$main_class.'" id="'.$id.'">';
$output .= '<div class="white_table_graph_header" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">'.html_print_image( $output .= '<div class="'.$header_class.'" style="cursor: pointer;" id="tgl_ctrl_'.$uniqid.'">'.html_print_image(
$original, $original,
true, true,
[ [
@ -3767,7 +3777,8 @@ function ui_print_toggle($data)
(isset($data['container_class']) === true) ? $data['container_class'] : 'white-box-content', (isset($data['container_class']) === true) ? $data['container_class'] : 'white-box-content',
(isset($data['main_class']) === true) ? $data['main_class'] : 'box-shadow white_table_graph', (isset($data['main_class']) === true) ? $data['main_class'] : 'box-shadow white_table_graph',
(isset($data['img_a']) === true) ? $data['img_a'] : 'images/arrow_down_green.png', (isset($data['img_a']) === true) ? $data['img_a'] : 'images/arrow_down_green.png',
(isset($data['img_b']) === true) ? $data['img_b'] : 'images/arrow_right_green.png' (isset($data['img_b']) === true) ? $data['img_b'] : 'images/arrow_right_green.png',
(isset($data['clean']) === true) ? $data['clean'] : false
); );
} }

View File

@ -5700,6 +5700,10 @@ div#status_pie {
padding: 1em; padding: 1em;
min-width: 100%; min-width: 100%;
} }
.white-box-content-clean {
padding-left: 2em;
padding-top: 1em;
}
.white_table_graph_content { .white_table_graph_content {
border: 1px solid #e2e2e2; border: 1px solid #e2e2e2;