compiled if statement in the read_only mode
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// src/tui/functions/form.rs
|
||||
|
||||
use crate::state::pages::form::FormState;
|
||||
use crate::tui::terminal::GrpcClient;
|
||||
|
||||
pub async fn handle_action(
|
||||
action: &str,
|
||||
form_state: &mut FormState,
|
||||
grpc_client: &mut GrpcClient,
|
||||
current_position: &mut u64,
|
||||
total_count: u64,
|
||||
ideal_cursor_column: &mut usize,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
match action {
|
||||
"previous_entry" => {
|
||||
// Form-specific previous entry logic
|
||||
let new_position = current_position.saturating_sub(1);
|
||||
if new_position >= 1 {
|
||||
*current_position = new_position;
|
||||
let response = grpc_client.get_adresar_by_position(*current_position).await?;
|
||||
form_state.update_from_response(response);
|
||||
Ok(format!("Loaded form entry {}", *current_position))
|
||||
} else {
|
||||
Ok("Already at first form entry".into())
|
||||
}
|
||||
}
|
||||
// Other form-specific actions...
|
||||
_ => Err("Unknown form action".into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user