suggestions in the dropdown menu now works amazingly well
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use crate::config::colors::themes::Theme;
|
||||
use crate::state::app::highlight::HighlightState;
|
||||
use crate::state::pages::canvas_state::CanvasState;
|
||||
use common::proto::multieko2::search::search_response::Hit; // Import Hit
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::Frame;
|
||||
use std::collections::HashMap;
|
||||
@@ -12,7 +13,8 @@ use std::collections::HashMap;
|
||||
pub struct FieldDefinition {
|
||||
pub display_name: String,
|
||||
pub data_key: String,
|
||||
pub is_link: bool, // --- NEW --- To identify FK fields
|
||||
pub is_link: bool,
|
||||
pub link_target_table: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -28,10 +30,11 @@ pub struct FormState {
|
||||
pub has_unsaved_changes: bool,
|
||||
pub current_cursor_pos: usize,
|
||||
|
||||
// --- NEW AUTOCOMPLETE STATE ---
|
||||
// --- MODIFIED AUTOCOMPLETE STATE ---
|
||||
pub autocomplete_active: bool,
|
||||
pub autocomplete_suggestions: Vec<String>,
|
||||
pub autocomplete_suggestions: Vec<Hit>, // Changed to use the Hit struct
|
||||
pub selected_suggestion_index: Option<usize>,
|
||||
pub autocomplete_loading: bool, // To show a loading indicator
|
||||
}
|
||||
|
||||
impl FormState {
|
||||
@@ -56,6 +59,7 @@ impl FormState {
|
||||
autocomplete_active: false,
|
||||
autocomplete_suggestions: Vec::new(),
|
||||
selected_suggestion_index: None,
|
||||
autocomplete_loading: false, // Initialize loading state
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +168,7 @@ impl FormState {
|
||||
self.autocomplete_active = false;
|
||||
self.autocomplete_suggestions.clear();
|
||||
self.selected_suggestion_index = None;
|
||||
self.autocomplete_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +221,14 @@ impl CanvasState for FormState {
|
||||
}
|
||||
|
||||
// --- MODIFIED: Implement autocomplete trait methods ---
|
||||
|
||||
/// Returns None because this state uses rich suggestions.
|
||||
fn get_suggestions(&self) -> Option<&[String]> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns rich suggestions.
|
||||
fn get_rich_suggestions(&self) -> Option<&[Hit]> {
|
||||
if self.autocomplete_active {
|
||||
Some(&self.autocomplete_suggestions)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user