Added a checkboxes in the list of elements for to make more easy the deletion of item in visual map. TICKET: #1687

This commit is contained in:
mdtrooper 2015-01-29 16:53:52 +01:00
parent 6d25709d3c
commit e4d26b0bd6
2 changed files with 129 additions and 14 deletions

View File

@ -60,7 +60,10 @@ $table->head[1] = __('Image') . ' / ' . __('Module');
$table->head[2] = __('Width x Height<br>Max value'); $table->head[2] = __('Width x Height<br>Max value');
$table->head[3] = __('Period') . ' / ' . __('Position'); $table->head[3] = __('Period') . ' / ' . __('Position');
$table->head[4] = __('Parent') . ' / ' . __('Map linked'); $table->head[4] = __('Parent') . ' / ' . __('Map linked');
$table->head[5] = '<span title="' . __('Action') . '">' . $table->head[5] = "";
$table->head[5] .= html_print_checkbox('head_multiple_delete',
'', false, true, false, 'toggle_checkbox_multiple_delete();');
$table->head[5] .= '<span title="' . __('Action') . '">' .
__('A.') . '</span>'; __('A.') . '</span>';
$table->size = array(); $table->size = array();
@ -248,16 +251,35 @@ foreach ($layoutDatas as $layoutData) {
//Delete row button //Delete row button
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$table->data[$i + 1][5] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/visual_console_builder&tab=' . $url_delete = "index.php?" .
$activeTab . '&action=delete&id_visual_console=' . $visualConsole["id"] . '&id_element=' . $idLayoutData . '" ' . "sec=reporting&" .
'onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>'; "sec2=godmode/reporting/visual_console_builder&" .
"tab=" . $activeTab . "&" .
"action=delete&" .
"id_visual_console=" . $visualConsole["id"] . "&" .
"id_element=" . $idLayoutData;
$table->data[$i + 1][5] = "";
$table->data[$i + 1][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true);
$table->data[$i + 1][5] .= '<a href="' . $url_delete . '" ' .
'onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
html_print_image('images/cross.png', true) . '</a>';
} }
else { else {
$pure = get_parameter('pure', 0); $url_delete = "index.php?" .
"operation=edit_visualmap&" .
"sec=screen&" .
"sec2=screens/screens&" .
"action=visualmap&" .
"pure=" . (int)get_parameter('pure', 0) . "&" .
"tab=list_elements&" .
"action2=delete&" .
"id_visual_console=" . $visualConsole["id"] . "&" .
"id_element=" . $idLayoutData;
$table->data[$i + 1][5] = '<a href="index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap' . $table->data[$i + 1][5] = '<a href="' . $url_delete . '" ' .
'&pure=' . $pure . '&tab=list_elements&action2=delete&id_visual_console=' . $visualConsole["id"] . '&id_element=' . $idLayoutData . '" ' . 'onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
'onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>'; html_print_image('images/cross.png', true) . '</a>';
} }
@ -400,8 +422,12 @@ foreach ($layoutDatas as $layoutData) {
break; break;
default: default:
$table->data[$i + 2][4] = html_print_select_from_sql( $table->data[$i + 2][4] = html_print_select_from_sql(
'SELECT id, name FROM tlayout WHERE id != ' . $idVisualConsole, 'SELECT id, name
'map_linked_' . $idLayoutData, $layoutData['id_layout_linked'], '', 'None', '', true, false, true, '', false, "width: 120px"); FROM tlayout
WHERE id != ' . $idVisualConsole,
'map_linked_' . $idLayoutData,
$layoutData['id_layout_linked'], '', 'None', '', true,
false, true, '', false, "width: 120px");
break; break;
} }
@ -435,16 +461,56 @@ if (!defined('METACONSOLE')) {
else { else {
html_print_input_hidden ('action2', 'update'); html_print_input_hidden ('action2', 'update');
} }
echo "<br>";
html_print_input_hidden ('id_visual_console', $visualConsole["id"]); html_print_input_hidden ('id_visual_console', $visualConsole["id"]);
html_print_submit_button (__('Update'), 'go', false, 'class="sub next"'); html_print_submit_button (__('Update'), 'go', false, 'class="sub next"');
echo "&nbsp;";
html_print_button(__('Delete'), 'delete', false, 'submit_delete_multiple_items();', 'class="sub delete"');
echo '</div>'; echo '</div>';
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 (__('Update'), 'go', false, 'class="sub next"'); html_print_submit_button (__('Update'), 'go', false, 'class="sub next"');
echo "&nbsp;";
html_print_button(__('Delete'), 'delete', false, 'submit_delete_multiple_items();', 'class="sub delete"');
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
// Form for multiple delete
if (!defined('METACONSOLE')) {
$url_multiple_delete = "index.php?" .
"sec=reporting&" .
"sec2=godmode/reporting/visual_console_builder&" .
"tab=" . $activeTab . "&" .
"id_visual_console=" . $visualConsole["id"];
echo '<form id="form_multiple_delete" method="post" action="' . $url_multiple_delete . '">';
}
else {
$url_multiple_delete = "index.php?" .
"operation=edit_visualmap&" .
"sec=screen&" .
"sec2=screens/screens&" .
"action=visualmap&" .
"pure=0&" .
"tab=list_elements&" .
"id_visual_console=" . $idVisualConsole;
echo "<form id='form_multiple_delete' method='post' action=" . $url_multiple_delete . ">";
}
if (!defined('METACONSOLE')) {
html_print_input_hidden ('action', 'multiple_delete');
}
else {
html_print_input_hidden ('action2', 'multiple_delete');
}
html_print_input_hidden ('id_visual_console', $visualConsole["id"]);
html_print_input_hidden('id_item_json', '');
echo '</form>';
//Trick for it have a traduct text for javascript. //Trick for it have a traduct text for javascript.
echo '<span id="ip_text" style="display: none;">' . __('IP') . '</span>'; echo '<span id="ip_text" style="display: none;">' . __('IP') . '</span>';
?> ?>
@ -530,4 +596,23 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
tinyMCE.activeEditor.setContent(label); tinyMCE.activeEditor.setContent(label);
$("#dialog_label_editor").dialog("open"); $("#dialog_label_editor").dialog("open");
} }
function toggle_checkbox_multiple_delete() {
checked_head_multiple = $("input[name='head_multiple_delete']")
.is(":checked");
$("input[name='multiple_delete_items']")
.prop("checked", checked_head_multiple);
}
function submit_delete_multiple_items() {
delete_items = [];
jQuery.each($("input[name='multiple_delete_items']:checked"), function(i, item) {
delete_items.push($(item).val());
});
$("input[name='id_item_json']").val(JSON.stringify(delete_items));
$("#form_multiple_delete").submit();
}
</script> </script>

View File

@ -41,12 +41,16 @@ else {
$id_layout = 0; $id_layout = 0;
if (!defined('METACONSOLE')) { if (!defined('METACONSOLE')) {
$action = get_parameterBetweenListValues('action', array('new', 'save', 'edit', 'update', 'delete'), 'new'); $action_name_parameter = 'action';
} }
else { else {
$action = get_parameterBetweenListValues('action2', array('new', 'save', 'edit', 'update', 'delete'), 'new'); $action_name_parameter = 'action2';
} }
$action = get_parameterBetweenListValues($action_name_parameter,
array('new', 'save', 'edit', 'update', 'delete', 'multiple_delete'),
'new');
$activeTab = get_parameterBetweenListValues('tab', array('data', 'list_elements', 'wizard', 'wizard_services', 'editor'), 'data'); $activeTab = get_parameterBetweenListValues('tab', array('data', 'list_elements', 'wizard', 'wizard_services', 'editor'), 'data');
$refr = (int) get_parameter ('refr', $config['vc_refr']); $refr = (int) get_parameter ('refr', $config['vc_refr']);
@ -137,6 +141,32 @@ switch ($activeTab) {
case 'list_elements': case 'list_elements':
switch ($action) { switch ($action) {
case 'multiple_delete':
$delete_items_json = io_safe_output(
get_parameter("id_item_json",
json_encode(array())));
$delete_items = json_decode($delete_items_json, true);
$id_visual_console = (int)get_parameter(
'id_visual_console', 0);
if (!empty($delete_items)) {
$result = (bool)db_process_sql_delete(
'tlayout_data',
array('id_layout' => $id_visual_console,
'id' => $delete_items));
}
else {
$result = false;
}
$statusProcessInDB = array(
'flag' => true,
'message' => ui_print_result_message($result,
__('Successfully multiple delete.'),
__('Unsuccessfull multiple delete.'), '', true));
break;
case 'update': case 'update':
//Update background //Update background
@ -497,11 +527,11 @@ if (!defined('METACONSOLE')) {
$buttons); $buttons);
} }
//The source code for PAINT THE PAGE
if ($statusProcessInDB !== null) { if ($statusProcessInDB !== null) {
echo $statusProcessInDB['message']; echo $statusProcessInDB['message'];
} }
//The source code for PAINT THE PAGE
switch ($activeTab) { switch ($activeTab) {
case 'wizard': case 'wizard':
require_once($config['homedir'] . '/godmode/reporting/visual_console_builder.wizard.php'); require_once($config['homedir'] . '/godmode/reporting/visual_console_builder.wizard.php');