dialog in add_table is now working properly well

This commit is contained in:
filipriec
2025-04-18 12:29:29 +02:00
parent 39dcf38462
commit c90233b56f

View File

@@ -256,19 +256,38 @@ pub fn handle_add_table_navigation(
} }
AddTableFocus::DeleteSelectedButton => { AddTableFocus::DeleteSelectedButton => {
// --- Show Confirmation Dialog --- // --- Show Confirmation Dialog ---
let columns_to_delete: Vec<String> = add_table_state // Collect tuples of (index, name, type) for selected columns
let columns_to_delete: Vec<(usize, String, String)> = add_table_state
.columns .columns
.iter() .iter()
.filter(|col| col.selected) .enumerate() // Get index along with the column
.map(|col| col.name.clone()) .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(); .collect();
if columns_to_delete.is_empty() { if columns_to_delete.is_empty() {
*command_message = "No columns selected for deletion.".to_string(); *command_message = "No columns selected for deletion.".to_string();
} else { } 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::<Vec<String>>()
.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()]; 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 => { AddTableFocus::CancelButton => {