suggestions in the dropdown menu now works amazingly well

This commit is contained in:
filipriec
2025-06-15 23:11:27 +02:00
parent 0e69df8282
commit 512e7fb9e7
7 changed files with 541 additions and 118 deletions

View File

@@ -98,6 +98,7 @@ pub async fn run_ui() -> Result<()> {
display_name: col_name.clone(),
data_key: col_name,
is_link: false,
link_target_table: None,
})
.collect();
@@ -347,19 +348,18 @@ pub async fn run_ui() -> Result<()> {
.map(|c| c.name.clone())
.collect();
// 1. Process regular columns first, filtering out FKs
let mut field_definitions: Vec<FieldDefinition> =
filter_user_columns(all_columns)
.into_iter()
.filter(|col_name| !col_name.ends_with("_id")) // Exclude FKs
.filter(|col_name| !col_name.ends_with("_id"))
.map(|col_name| FieldDefinition {
display_name: col_name.clone(),
data_key: col_name,
is_link: false, // Regular fields are not links
is_link: false,
link_target_table: None, // Regular fields have no target
})
.collect();
// 2. Process linked tables to create the correct labels
let linked_tables: Vec<String> = app_state
.profile_tree
.profiles
@@ -375,19 +375,22 @@ pub async fn run_ui() -> Result<()> {
.split_once('_')
.map_or(linked_table_name.as_str(), |(_, rest)| rest);
let data_key = format!("{}_id", base_name);
let display_name = linked_table_name;
let display_name = linked_table_name.clone(); // Clone for use below
field_definitions.push(FieldDefinition {
display_name,
data_key,
is_link: true, // These fields ARE links
is_link: true,
// --- POPULATE THE NEW FIELD ---
link_target_table: Some(linked_table_name),
});
}
// --- END OF MODIFIED LOGIC ---
form_state = FormState::new(
prof_name.clone(),
tbl_name.clone(),
field_definitions,
field_definitions, // This now contains the complete definitions
);
if let Err(e) = UiService::fetch_and_set_table_count(