changed in welcome tips forms

This commit is contained in:
Daniel Cebrian 2023-03-16 17:22:53 +01:00
parent a22b5479d9
commit 20b177d121
4 changed files with 191 additions and 91 deletions

View File

@ -436,7 +436,14 @@ class TipsWindow
'title', 'title',
'text', 'text',
'enable', 'enable',
'actions', [
'text' => 'edit',
'class' => 'table_action_buttons',
],
[
'text' => 'delete',
'class' => 'table_action_buttons',
],
]; ];
$columnNames = [ $columnNames = [
@ -444,7 +451,8 @@ class TipsWindow
__('Title'), __('Title'),
__('Text'), __('Text'),
__('Enable'), __('Enable'),
__('Actions'), __('Edit'),
__('Delete'),
]; ];
// Load datatables user interface. // Load datatables user interface.
@ -452,7 +460,9 @@ class TipsWindow
[ [
'id' => 'list_tips_windows', 'id' => 'list_tips_windows',
'class' => 'info_table', 'class' => 'info_table',
'style' => 'width: 100%', 'style' => 'width: 99%',
'dom_elements' => 'lpfti',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
'columns' => $columns, 'columns' => $columns,
'column_names' => $columnNames, 'column_names' => $columnNames,
'ajax_url' => $this->ajaxController, 'ajax_url' => $this->ajaxController,
@ -475,18 +485,21 @@ class TipsWindow
], ],
] ]
); );
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p" style="width: 100%">';
echo '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create">'; $buttonCreate = '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create">';
html_print_submit_button( $buttonCreate .= html_print_submit_button(
__('Create tip'), __('Create tip'),
'create', 'create',
false, false,
[ [
'class' => 'sub', 'class' => 'sub',
'icon' => 'create_file', 'icon' => 'create_file',
] ''
],
true
); );
echo '</a>'; $buttonCreate .= '</a>';
html_print_action_buttons($buttonCreate);
echo '</div>'; echo '</div>';
} catch (Exception $e) { } catch (Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
@ -586,16 +599,15 @@ class TipsWindow
$data[$key]['title'] = io_safe_output($row['title']); $data[$key]['title'] = io_safe_output($row['title']);
$data[$key]['text'] = io_safe_output($row['text']); $data[$key]['text'] = io_safe_output($row['text']);
$data[$key]['url'] = io_safe_output($row['url']); $data[$key]['url'] = io_safe_output($row['url']);
$data[$key]['actions'] = '<div class="buttons_actions">'; $data[$key]['edit'] = '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&idTip='.$row['id'].'">';
$data[$key]['actions'] .= '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&idTip='.$row['id'].'">'; $data[$key]['edit'] .= html_print_image(
$data[$key]['actions'] .= html_print_image(
'images/edit.svg', 'images/edit.svg',
true, true,
['class' => 'main_menu_icon'] ['class' => 'main_menu_icon']
); );
$data[$key]['actions'] .= '</a>'; $data[$key]['edit'] .= '</a>';
$data[$key]['actions'] .= '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&action=delete">'; $data[$key]['delete'] .= '<form name="grupo" method="post" class="rowPair table_action_buttons" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&action=delete">';
$data[$key]['actions'] .= html_print_input_image( $data[$key]['delete'] .= html_print_input_image(
'button_delete_tip', 'button_delete_tip',
'images/delete.svg', 'images/delete.svg',
'', '',
@ -603,12 +615,11 @@ class TipsWindow
true, true,
[ [
'onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', 'onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;',
'class' => 'main_menu_icon', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data[$key]['actions'] .= html_print_input_hidden('idTip', $row['id'], true); $data[$key]['delete'] .= html_print_input_hidden('idTip', $row['id'], true);
$data[$key]['actions'] .= '</form>'; $data[$key]['delete'] .= '</form>';
$data[$key]['actions'] .= '</div>';
} }
if (empty($data) === true) { if (empty($data) === true) {
@ -681,14 +692,50 @@ class TipsWindow
</script>'; </script>';
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filter-table-adv';
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'width: 50%';
$table->data = []; $table->data = [];
$table->data[0][0] = __('Images'); $table->data[0][0] = html_print_label_input_block(
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true); __('Language'),
$table->data[0][1] .= html_print_div( html_print_select_from_sql(
'SELECT id_language, name FROM tlanguage',
'id_lang',
'',
'',
'',
'0',
true,
false,
true,
false,
'width: 100%;'
)
);
$table->data[0][1] = html_print_label_input_block(
__('Profile'),
html_print_select($profiles, 'id_profile', '0', '', __('All'), 0, true)
);
$table->data[1][0] = html_print_label_input_block(
__('Title'),
html_print_input_text('title', '', '', 35, 100, true)
);
$table->data[1][1] = html_print_label_input_block(
__('Url'),
html_print_input_text('url', '', '', 35, 100, true)
);
$table->data[2][0] = html_print_label_input_block(
__('Text'),
html_print_textarea('text', 5, 50, '', '', true),
);
$table->data[2][1] = html_print_label_input_block(
__('Enable'),
html_print_checkbox_switch('enable', true, true, true)
);
$inputImages = html_print_div(['id' => 'inputs_images'], true);
$inputImages .= html_print_div(
[ [
'id' => 'notices_images', 'id' => 'notices_images',
'class' => 'invisible', 'class' => 'invisible',
@ -696,41 +743,36 @@ class TipsWindow
], ],
true true
); );
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true); $inputImages .= html_print_div(
$table->data[1][0] = __('Language'); [
$table->data[1][1] = html_print_select_from_sql( 'id' => 'notices_images',
'SELECT id_language, name FROM tlanguage', 'class' => 'invisible empty_input_images',
'id_lang', 'content' => '<p>'.__('Please select a image').'</p>',
'', ],
'',
'',
'0',
true true
); );
$table->data[2][0] = __('Profile'); $inputImages .= html_print_button(__('Add image'), 'button_add_image', false, '', ['class' => 'button-add-image'], true);
$table->data[2][1] = html_print_select($profiles, 'id_profile', '0', '', __('All'), 0, true);
$table->data[3][0] = __('Title');
$table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true);
$table->data[4][0] = __('Text');
$table->data[4][1] = html_print_textarea('text', 5, 50, '', '', true);
$table->data[5][0] = __('Url');
$table->data[5][1] = html_print_input_text('url', '', '', 35, 100, true);
$table->data[6][0] = __('Enable');
$table->data[6][1] = html_print_checkbox_switch('enable', true, true, true);
echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create&action=create" enctype="multipart/form-data">'; $table->data[3][0] = html_print_label_input_block(
__('Images'),
$inputImages
);
echo '<form method="post" class="max_floating_element_size" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=create&action=create" enctype="multipart/form-data">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(
$actionButtons = html_print_submit_button(
__('Send'), __('Send'),
'submit_button', 'submit_button',
false, false,
[ [
'class' => 'sub', 'class' => 'sub',
'icon' => 'update', 'icon' => 'update',
] ],
true
); );
html_print_submit_button( $actionButtons .= html_print_submit_button(
__('Preview'), __('Preview'),
'preview_button', 'preview_button',
false, false,
@ -738,8 +780,11 @@ class TipsWindow
'class' => 'sub preview', 'class' => 'sub preview',
'id' => 'prev_button', 'id' => 'prev_button',
'icon' => 'preview', 'icon' => 'preview',
] ],
true
); );
html_print_action_buttons($actionButtons);
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
html_print_div(['id' => 'tips_window_modal_preview']); html_print_div(['id' => 'tips_window_modal_preview']);
@ -813,16 +858,52 @@ class TipsWindow
</script>'; </script>';
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filter-table-adv';
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'width: 50%';
$table->data = []; $table->data = [];
$table->data[0][0] = __('Images');
$table->data[0][1] .= $outputImagesTip; $table->data[0][0] = html_print_label_input_block(
$table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true); __('Language'),
$table->data[0][1] .= html_print_input_hidden('images_to_delete', '{}', true); html_print_select_from_sql(
$table->data[0][1] .= html_print_div( 'SELECT id_language, name FROM tlanguage',
'id_lang',
$tip['id_lang'],
'',
'',
'0',
true,
false,
true,
false,
'width: 100%;'
)
);
$table->data[0][1] = html_print_label_input_block(
__('Profile'),
html_print_select($profiles, 'id_profile', $tip['id_profile'], '', __('All'), 0, true)
);
$table->data[1][0] = html_print_label_input_block(
__('Title'),
html_print_input_text('title', $tip['title'], '', 35, 100, true)
);
$table->data[1][1] = html_print_label_input_block(
__('Url'),
html_print_input_text('url', $tip['url'], '', 35, 100, true)
);
$table->data[2][0] = html_print_label_input_block(
__('Text'),
html_print_textarea('text', 5, 50, $tip['text'], '', true),
);
$table->data[2][1] = html_print_label_input_block(
__('Enable'),
html_print_checkbox_switch('enable', 1, ($tip['enable'] === '1') ? true : false, true)
);
$inputImages = $outputImagesTip;
$inputImages .= html_print_div(['id' => 'inputs_images'], true);
$inputImages .= html_print_input_hidden('images_to_delete', '{}', true);
$inputImages .= html_print_div(
[ [
'id' => 'notices_images', 'id' => 'notices_images',
'class' => 'invisible', 'class' => 'invisible',
@ -830,41 +911,35 @@ class TipsWindow
], ],
true true
); );
$table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true); $inputImages .= html_print_div(
$table->data[1][0] = __('Language'); [
$table->data[1][1] = html_print_select_from_sql( 'id' => 'notices_images',
'SELECT id_language, name FROM tlanguage', 'class' => 'invisible empty_input_images',
'id_lang', 'content' => '<p>'.__('Please select a image').'</p>',
$tip['id_lang'], ],
'',
'',
'0',
true true
); );
$table->data[2][0] = __('Profile'); $inputImages .= html_print_button(__('Add image'), 'button_add_image', false, '', ['class' => 'button-add-image'], true);
$table->data[2][1] = html_print_select($profiles, 'id_profile', $tip['id_profile'], '', __('All'), 0, true);
$table->data[3][0] = __('Title'); $table->data[3][0] = html_print_label_input_block(
$table->data[3][1] = html_print_input_text('title', $tip['title'], '', 35, 100, true); __('Images'),
$table->data[4][0] = __('Text'); $inputImages
$table->data[4][1] = html_print_textarea('text', 5, 50, $tip['text'], '', true); );
$table->data[5][0] = __('Url');
$table->data[5][1] = html_print_input_text('url', $tip['url'], '', 35, 100, true);
$table->data[6][0] = __('Enable');
$table->data[6][1] = html_print_checkbox_switch('enable', 1, ($tip['enable'] === '1') ? true : false, true);
echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&action=edit&idTip='.$tip['id'].'" enctype="multipart/form-data">'; echo '<form name="grupo" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=welcome_tips&view=edit&action=edit&idTip='.$tip['id'].'" enctype="multipart/form-data">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button( $actionButtons = html_print_submit_button(
__('Send'), __('Send'),
'submit_button', 'submit_button',
false, false,
[ [
'class' => 'sub', 'class' => 'sub',
'icon' => 'update', 'icon' => 'update',
] ],
true
); );
html_print_submit_button( $actionButtons .= html_print_submit_button(
__('Preview'), __('Preview'),
'preview_button', 'preview_button',
false, false,
@ -872,9 +947,12 @@ class TipsWindow
'class' => 'sub preview', 'class' => 'sub preview',
'id' => 'prev_button', 'id' => 'prev_button',
'icon' => 'preview', 'icon' => 'preview',
] ],
true
); );
html_print_action_buttons($actionButtons);
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
html_print_div(['id' => 'tips_window_modal_preview']); html_print_div(['id' => 'tips_window_modal_preview']);

View File

@ -2,15 +2,16 @@
$(document).ready(function() { $(document).ready(function() {
$("#button-button_add_image").on("click", function() { $("#button-button_add_image").on("click", function() {
var numberImages = $("#inputs_images").children().length; var numberImages = $("#inputs_images").children().length;
$(".input-file").each(function(index) {
$(this).attr("name", "file_" + index);
});
var div_image = document.createElement("div"); var div_image = document.createElement("div");
$(div_image).attr("class", "action_image"); $(div_image).attr("class", "action_image");
$(div_image).append( $(div_image).append(
`<input type="file" accept="image/png,image/jpeg,image/gif" name="file_${numberImages + `<input type="file" accept="image/png,image/jpeg,image/gif" class="input-file" name="file_${numberImages}" onchange="checkImage(this)"/>`
1}" onchange="checkImage(this)"/>`
); );
$(div_image).append( $(div_image).append(
`<input type="image" src="images/delete.svg" onclick="removeInputImage('file_${numberImages + `<input type="image" src="images/delete.svg" onclick="removeInputImage(this);" class="remove-image" value="-"/>`
1}');" class="remove-image" value="-"/>`
); );
$("#inputs_images").append(div_image); $("#inputs_images").append(div_image);
}); });
@ -72,8 +73,8 @@ function activeCarousel() {
$(".carousel .images").bxSlider({ controls: true }); $(".carousel .images").bxSlider({ controls: true });
} }
} }
function removeInputImage(name) { function removeInputImage(e) {
$(`input[name=${name}]`) $(e)
.parent() .parent()
.remove(); .remove();
if ($(".action_image").length === 0) { if ($(".action_image").length === 0) {
@ -314,7 +315,7 @@ function previewTip() {
//Images in client //Images in client
var totalInputsFiles = $("input[type=file]").length; var totalInputsFiles = $("input[type=file]").length;
if (totalInputsFiles > 0) { if (totalInputsFiles > 0 && validateImages()) {
extradata["totalFiles64"] = totalInputsFiles; extradata["totalFiles64"] = totalInputsFiles;
$("input[type=file]").each(function(index) { $("input[type=file]").each(function(index) {
var reader = new FileReader(); var reader = new FileReader();
@ -352,3 +353,15 @@ function previewTip() {
}); });
} }
} }
function validateImages() {
$(".empty_input_images").addClass("invisible");
let validate = true;
$("input[type=file]").each(function() {
if (this.files.length == 0) {
$(".empty_input_images").removeClass("invisible");
validate = false;
}
});
return validate;
}

View File

@ -172,17 +172,17 @@ span.count-round-tip.active {
} }
span.enable { span.enable {
display: block; display: block;
width: 15px; width: 40px;
height: 15px; height: 20px;
border-radius: 15px; border-radius: 4px;
background-color: #82b92e; background-color: #82b92e;
margin: 0 auto; margin: 0 auto;
} }
span.disable { span.disable {
display: block; display: block;
width: 15px; width: 40px;
height: 15px; height: 20px;
border-radius: 15px; border-radius: 4px;
background-color: #e63c52; background-color: #e63c52;
margin: 0 auto; margin: 0 auto;
} }
@ -212,3 +212,12 @@ span.disable {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
} }
#list_tips_windows .main_menu_icon {
padding: 0px;
}
#list_tips_windows .table_action_buttons {
text-align: center;
}
.button-add-image {
max-width: fit-content;
}

View File

@ -83,7 +83,7 @@ $output .= '<a href="'.$url.'" class="'.$link_class.'" target="_blank" id="url_t
$output .= '</div>'; $output .= '</div>';
$output .= '<div class="ui-dialog-buttonset">'; $output .= '<div class="ui-dialog-buttonset">';
// TODO Delete this buttons and use html_print_button when merge new design
$output .= html_print_button( $output .= html_print_button(
__('Maybe later'), __('Maybe later'),
'', '',