add table and add logic removal from ui.rs and event.rs
This commit is contained in:
51
client/src/pages/admin_panel/add_table/event.rs
Normal file
51
client/src/pages/admin_panel/add_table/event.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
// src/pages/admin_panel/add_table/event.rs
|
||||
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::movement::MovementAction;
|
||||
use crate::pages::admin_panel::add_table::nav;
|
||||
use crate::pages::admin_panel::add_table::nav::SaveTableResultSender;
|
||||
use crate::pages::admin_panel::add_table::state::{AddTableFocus, AddTableState};
|
||||
use crate::services::GrpcClient;
|
||||
use crate::state::app::state::AppState;
|
||||
use crossterm::event::KeyEvent;
|
||||
|
||||
/// Handle all AddTable page-specific events in one place.
|
||||
/// - First try movement actions (Up/Down/Select/Esc) via AddTableState::handle_movement
|
||||
/// - Then, if not handled, try rich actions via nav::handle_add_table_navigation
|
||||
///
|
||||
/// Returns true if the key was handled (caller should stop propagation).
|
||||
pub fn handle_add_table_event(
|
||||
key_event: KeyEvent,
|
||||
movement_action: Option<MovementAction>,
|
||||
config: &Config,
|
||||
app_state: &mut AppState,
|
||||
state: &mut AddTableState,
|
||||
grpc_client: GrpcClient,
|
||||
save_result_sender: SaveTableResultSender,
|
||||
command_message: &mut String,
|
||||
) -> bool {
|
||||
// 1) Try movement first (keeps focus cycling consistent)
|
||||
if let Some(ma) = movement_action {
|
||||
if state.handle_movement(ma) {
|
||||
let is_canvas_input = matches!(
|
||||
state.current_focus,
|
||||
AddTableFocus::InputTableName
|
||||
| AddTableFocus::InputColumnName
|
||||
| AddTableFocus::InputColumnType
|
||||
);
|
||||
app_state.ui.focus_outside_canvas = !is_canvas_input;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Rich actions/navigation for AddTable
|
||||
nav::handle_add_table_navigation(
|
||||
key_event,
|
||||
config,
|
||||
app_state,
|
||||
state,
|
||||
grpc_client,
|
||||
save_result_sender,
|
||||
command_message,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user