we are suggesting properly table column names now
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use crate::services::grpc_client::GrpcClient;
|
||||
use crate::state::pages::form::FormState;
|
||||
use crate::tui::functions::common::form::SaveOutcome;
|
||||
use crate::state::pages::add_logic::AddLogicState;
|
||||
use crate::state::app::state::AppState;
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
@@ -37,6 +38,49 @@ impl UiService {
|
||||
Ok(column_names)
|
||||
}
|
||||
|
||||
pub async fn initialize_add_logic_table_data(
|
||||
grpc_client: &mut GrpcClient,
|
||||
add_logic_state: &mut AddLogicState,
|
||||
) -> Result<String> {
|
||||
let profile_name_clone_opt = Some(add_logic_state.profile_name.clone());
|
||||
let table_name_opt_clone = add_logic_state.selected_table_name.clone();
|
||||
|
||||
if let (Some(profile_name_clone), Some(table_name_clone)) = (profile_name_clone_opt, table_name_opt_clone) {
|
||||
match grpc_client.get_table_structure(profile_name_clone.clone(), table_name_clone.clone()).await {
|
||||
Ok(response) => {
|
||||
let column_names: Vec<String> = response.columns
|
||||
.into_iter()
|
||||
.map(|col| col.name)
|
||||
.collect();
|
||||
|
||||
// This mutable borrow is now fine
|
||||
add_logic_state.set_table_columns(column_names.clone());
|
||||
|
||||
Ok(format!(
|
||||
"Loaded {} columns for table '{}' in profile '{}'",
|
||||
column_names.len(),
|
||||
table_name_clone, // Use cloned value
|
||||
profile_name_clone // Use cloned value
|
||||
))
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(
|
||||
"Failed to fetch table structure for {}.{}: {}",
|
||||
profile_name_clone, // Use cloned value
|
||||
table_name_clone, // Use cloned value
|
||||
e
|
||||
);
|
||||
Ok(format!(
|
||||
"Warning: Could not load table structure for '{}'. Autocomplete will use basic suggestions.",
|
||||
table_name_clone // Use cloned value
|
||||
))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Ok("No table selected or profile name missing for Add Logic".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn initialize_adresar_count(
|
||||
grpc_client: &mut GrpcClient,
|
||||
app_state: &mut AppState,
|
||||
|
||||
Reference in New Issue
Block a user