From 6d940810b298f9d98d5dfd45354380a50ea6dfbf Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 15 Jan 2025 23:01:17 -0500 Subject: [PATCH] QA: Enable Drag and Drop for Links Pages --- links.php | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/links.php b/links.php index 8e1de8b6d1..b81df52934 100644 --- a/links.php +++ b/links.php @@ -61,6 +61,14 @@ header('Location: links.php'); break; + case 'ajax_dnd': + $new_order = get_nfilter_request_var('dnd'); + + links_reorder($new_order); + + header('Location: links.php'); + + break; case 'save': $save['id'] = isset_request_var('id') ? get_filter_request_var('id') : 0; $save['title'] = form_input_validate(get_nfilter_request_var('title'), 'title', '', false, 3); @@ -126,7 +134,6 @@ bottom_footer(); break; - default: top_header(); @@ -137,6 +144,23 @@ break; } +function links_reorder($new_order) { + if (cacti_sizeof($new_order)) { + $sort = 1; + + foreach($new_order as $l) { + $link_id = str_replace('line', '', $l); + + db_execute_prepared('UPDATE external_links + SET sortorder = ? + WHERE id = ?', + array($sort, $link_id)); + + $sort++; + } + } +} + function form_actions() { global $actions; @@ -312,16 +336,17 @@ function pages() { foreach ($pages as $page) { form_alternate_row('line' . $page['id']); - $menuicons = ''; + $menuicons = ''; if ($page['enabled'] == 'on') { - $menuicons .= ''; + $menuicons .= ''; } - form_selectable_cell($menuicons, $page['id'], '50'); + form_selectable_cell($menuicons, $page['id'], '3%'); form_selectable_ecell($page['contentfile'], $page['id']); form_selectable_ecell($page['title'], $page['id']); form_selectable_ecell($style_translate[$page['style']] . ($page['style'] == 'CONSOLE' ? ' ( ' . ($page['extendedstyle'] == '' ? __('External Links') : $page['extendedstyle']) . ' )' : ''), $page['id']); + form_selectable_cell(($page['enabled'] == 'on' ? __('Yes') : __('No')), $page['id']); if (get_request_var('sort_column') == 'sortorder') { @@ -357,10 +382,26 @@ function pages() { print $nav; } - draw_actions_dropdown($actions); form_end(); + + if (get_request_var('sort_column') == 'sortorder' && read_config_option('drag_and_drop') == 'on') { + ?> + +