add_table dialog is now working properly well

This commit is contained in:
filipriec
2025-04-18 12:20:08 +02:00
parent efa27cd2dd
commit 39dcf38462
6 changed files with 61 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ use crate::state::{
use crossterm::event::{KeyEvent};
use ratatui::widgets::TableState;
use crate::tui::functions::common::add_table::handle_add_column_action;
use crate::tui::functions::common::add_table::handle_delete_selected_columns;
use crate::ui::handlers::context::DialogPurpose;
/// Handles navigation events specifically for the Add Table view.
/// Returns true if the event was handled, false otherwise.
@@ -255,7 +255,21 @@ pub fn handle_add_table_navigation(
// TODO: Implement logic
}
AddTableFocus::DeleteSelectedButton => {
handle_delete_selected_columns(add_table_state, command_message);
// --- Show Confirmation Dialog ---
let columns_to_delete: Vec<String> = add_table_state
.columns
.iter()
.filter(|col| col.selected)
.map(|col| col.name.clone())
.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"));
let buttons = vec!["Confirm".to_string(), "Cancel".to_string()];
app_state.show_dialog("Confirm Deletion", &message, buttons, DialogPurpose::ConfirmDeleteColumns);
}
}
AddTableFocus::CancelButton => {
*command_message = "Action: Cancel Add Table".to_string();