From c90233b56fc172bfe6f3a2170095295bff658b88 Mon Sep 17 00:00:00 2001 From: filipriec Date: Fri, 18 Apr 2025 12:29:29 +0200 Subject: [PATCH] dialog in add_table is now working properly well --- .../modes/navigation/add_table_nav.rs | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/client/src/functions/modes/navigation/add_table_nav.rs b/client/src/functions/modes/navigation/add_table_nav.rs index 752f968..ae758ba 100644 --- a/client/src/functions/modes/navigation/add_table_nav.rs +++ b/client/src/functions/modes/navigation/add_table_nav.rs @@ -256,19 +256,38 @@ pub fn handle_add_table_navigation( } AddTableFocus::DeleteSelectedButton => { // --- Show Confirmation Dialog --- - let columns_to_delete: Vec = add_table_state + // Collect tuples of (index, name, type) for selected columns + let columns_to_delete: Vec<(usize, String, String)> = add_table_state .columns .iter() - .filter(|col| col.selected) - .map(|col| col.name.clone()) + .enumerate() // Get index along with the column + .filter(|(_index, col)| col.selected) // Filter based on selection + .map(|(index, col)| (index, col.name.clone(), col.data_type.clone())) // Map to (index, name, type) .collect(); if columns_to_delete.is_empty() { *command_message = "No columns selected for deletion.".to_string(); } else { - let message = format!("Delete the following columns?\n\n{}", columns_to_delete.join("\n")); + // Format the message to include index, name, and type + let column_details: String = columns_to_delete + .iter() + // Add 1 to index for 1-based numbering for user display + .map(|(index, name, dtype)| format!("{}. {} ({})", index + 1, name, dtype)) + .collect::>() + .join("\n"); + + // Use the formatted column_details string in the message + let message = format!( + "Delete the following columns?\n\n{}", + column_details + ); let buttons = vec!["Confirm".to_string(), "Cancel".to_string()]; - app_state.show_dialog("Confirm Deletion", &message, buttons, DialogPurpose::ConfirmDeleteColumns); + app_state.show_dialog( + "Confirm Deletion", + &message, + buttons, + DialogPurpose::ConfirmDeleteColumns, + ); } } AddTableFocus::CancelButton => {