working but not properly displaying search results
This commit is contained in:
@@ -1,35 +1,36 @@
|
|||||||
// client/src/ui/handlers/render.rs
|
// src/ui/handlers/render.rs
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
|
admin::add_logic::render_add_logic,
|
||||||
|
admin::render_add_table,
|
||||||
|
auth::{login::render_login, register::render_register},
|
||||||
|
common::dialog::render_dialog, // Make sure this is imported
|
||||||
|
common::find_file_palette,
|
||||||
|
common::search_palette::render_search_palette,
|
||||||
|
form::form::render_form,
|
||||||
|
handlers::sidebar::{self, calculate_sidebar_layout},
|
||||||
|
intro::intro::render_intro,
|
||||||
render_background,
|
render_background,
|
||||||
render_buffer_list,
|
render_buffer_list,
|
||||||
render_command_line,
|
render_command_line,
|
||||||
render_status_line,
|
render_status_line,
|
||||||
intro::intro::render_intro,
|
|
||||||
handlers::sidebar::{self, calculate_sidebar_layout},
|
|
||||||
form::form::render_form,
|
|
||||||
admin::render_add_table,
|
|
||||||
admin::add_logic::render_add_logic,
|
|
||||||
auth::{login::render_login, register::render_register},
|
|
||||||
common::find_file_palette,
|
|
||||||
common::search_palette::render_search_palette
|
|
||||||
};
|
};
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
|
use crate::modes::general::command_navigation::NavigationState;
|
||||||
|
use crate::state::app::buffer::BufferState;
|
||||||
|
use crate::state::app::highlight::HighlightState;
|
||||||
|
use crate::state::app::state::AppState;
|
||||||
|
use crate::state::pages::admin::AdminState;
|
||||||
|
use crate::state::pages::auth::AuthState;
|
||||||
|
use crate::state::pages::auth::LoginState;
|
||||||
|
use crate::state::pages::auth::RegisterState;
|
||||||
|
use crate::state::pages::canvas_state::CanvasState;
|
||||||
|
use crate::state::pages::form::FormState;
|
||||||
|
use crate::state::pages::intro::IntroState;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Constraint, Direction, Layout},
|
layout::{Constraint, Direction, Layout},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::state::pages::canvas_state::CanvasState;
|
|
||||||
use crate::state::pages::form::FormState;
|
|
||||||
use crate::state::pages::auth::AuthState;
|
|
||||||
use crate::state::pages::auth::LoginState;
|
|
||||||
use crate::state::pages::auth::RegisterState;
|
|
||||||
use crate::state::pages::intro::IntroState;
|
|
||||||
use crate::state::app::buffer::BufferState;
|
|
||||||
use crate::state::app::state::AppState;
|
|
||||||
use crate::state::pages::admin::AdminState;
|
|
||||||
use crate::state::app::highlight::HighlightState;
|
|
||||||
use crate::modes::general::command_navigation::NavigationState;
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn render_ui(
|
pub fn render_ui(
|
||||||
@@ -63,7 +64,7 @@ pub fn render_ui(
|
|||||||
} else if event_handler_command_mode_active {
|
} else if event_handler_command_mode_active {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
0 // Neither is active
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
if command_palette_area_height > 0 {
|
if command_palette_area_height > 0 {
|
||||||
@@ -76,7 +77,6 @@ pub fn render_ui(
|
|||||||
}
|
}
|
||||||
main_layout_constraints.extend(bottom_area_constraints);
|
main_layout_constraints.extend(bottom_area_constraints);
|
||||||
|
|
||||||
|
|
||||||
let root_chunks = Layout::default()
|
let root_chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints(main_layout_constraints)
|
.constraints(main_layout_constraints)
|
||||||
@@ -107,77 +107,99 @@ pub fn render_ui(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
render_intro(f, intro_state, main_content_area, theme);
|
render_intro(f, intro_state, main_content_area, theme);
|
||||||
} else if app_state.ui.show_register {
|
} else if app_state.ui.show_register {
|
||||||
render_register(
|
render_register(
|
||||||
f, main_content_area, theme, register_state, app_state,
|
f,
|
||||||
|
main_content_area,
|
||||||
|
theme,
|
||||||
|
register_state,
|
||||||
|
app_state,
|
||||||
register_state.current_field() < 4,
|
register_state.current_field() < 4,
|
||||||
highlight_state,
|
highlight_state,
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_add_table {
|
} else if app_state.ui.show_add_table {
|
||||||
render_add_table(
|
render_add_table(
|
||||||
f, main_content_area, theme, app_state, &mut admin_state.add_table_state,
|
f,
|
||||||
|
main_content_area,
|
||||||
|
theme,
|
||||||
|
app_state,
|
||||||
|
&mut admin_state.add_table_state,
|
||||||
is_event_handler_edit_mode,
|
is_event_handler_edit_mode,
|
||||||
highlight_state,
|
highlight_state,
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_add_logic {
|
} else if app_state.ui.show_add_logic {
|
||||||
render_add_logic(
|
render_add_logic(
|
||||||
f, main_content_area, theme, app_state, &mut admin_state.add_logic_state,
|
f,
|
||||||
is_event_handler_edit_mode, highlight_state,
|
main_content_area,
|
||||||
|
theme,
|
||||||
|
app_state,
|
||||||
|
&mut admin_state.add_logic_state,
|
||||||
|
is_event_handler_edit_mode,
|
||||||
|
highlight_state,
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_login {
|
} else if app_state.ui.show_login {
|
||||||
render_login(
|
render_login(
|
||||||
f, main_content_area, theme, login_state, app_state,
|
f,
|
||||||
|
main_content_area,
|
||||||
|
theme,
|
||||||
|
login_state,
|
||||||
|
app_state,
|
||||||
login_state.current_field() < 2,
|
login_state.current_field() < 2,
|
||||||
highlight_state,
|
highlight_state,
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
crate::components::admin::admin_panel::render_admin_panel(
|
crate::components::admin::admin_panel::render_admin_panel(
|
||||||
f, app_state, auth_state, admin_state, main_content_area, theme,
|
f,
|
||||||
&app_state.profile_tree, &app_state.selected_profile,
|
app_state,
|
||||||
|
auth_state,
|
||||||
|
admin_state,
|
||||||
|
main_content_area,
|
||||||
|
theme,
|
||||||
|
&app_state.profile_tree,
|
||||||
|
&app_state.selected_profile,
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if app_state.ui.show_form {
|
} else if app_state.ui.show_form {
|
||||||
let (sidebar_area, form_actual_area) = calculate_sidebar_layout(
|
let (sidebar_area, form_actual_area) =
|
||||||
app_state.ui.show_sidebar, main_content_area
|
calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area);
|
||||||
);
|
|
||||||
if let Some(sidebar_rect) = sidebar_area {
|
if let Some(sidebar_rect) = sidebar_area {
|
||||||
sidebar::render_sidebar(
|
sidebar::render_sidebar(
|
||||||
f, sidebar_rect, theme, &app_state.profile_tree, &app_state.selected_profile
|
f,
|
||||||
|
sidebar_rect,
|
||||||
|
theme,
|
||||||
|
&app_state.profile_tree,
|
||||||
|
&app_state.selected_profile,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let available_width = form_actual_area.width;
|
let available_width = form_actual_area.width;
|
||||||
let form_render_area = if available_width >= 80 {
|
let form_render_area = if available_width >= 80 {
|
||||||
Layout::default().direction(Direction::Horizontal)
|
Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Min(0), Constraint::Length(80), Constraint::Min(0)])
|
.constraints([Constraint::Min(0), Constraint::Length(80), Constraint::Min(0)])
|
||||||
.split(form_actual_area)[1]
|
.split(form_actual_area)[1]
|
||||||
} else {
|
} else {
|
||||||
Layout::default().direction(Direction::Horizontal)
|
Layout::default()
|
||||||
.constraints([Constraint::Min(0), Constraint::Length(available_width), Constraint::Min(0)])
|
.direction(Direction::Horizontal)
|
||||||
|
.constraints([
|
||||||
|
Constraint::Min(0),
|
||||||
|
Constraint::Length(available_width),
|
||||||
|
Constraint::Min(0),
|
||||||
|
])
|
||||||
.split(form_actual_area)[1]
|
.split(form_actual_area)[1]
|
||||||
};
|
};
|
||||||
let fields_vec: Vec<&str> = form_state.fields.iter().map(AsRef::as_ref).collect();
|
|
||||||
let values_vec: Vec<&String> = form_state.values.iter().collect();
|
// --- FIX START ---
|
||||||
|
// The call to `form_state.render` is now separate from the popup rendering.
|
||||||
// --- START FIX ---
|
form_state.render(
|
||||||
// Add the missing `&form_state.table_name` argument to this function call.
|
|
||||||
render_form(
|
|
||||||
f,
|
f,
|
||||||
form_render_area,
|
form_render_area,
|
||||||
form_state,
|
|
||||||
&fields_vec,
|
|
||||||
&form_state.current_field,
|
|
||||||
&values_vec,
|
|
||||||
&form_state.table_name, // <-- THIS ARGUMENT WAS MISSING
|
|
||||||
theme,
|
theme,
|
||||||
is_event_handler_edit_mode,
|
is_event_handler_edit_mode,
|
||||||
highlight_state,
|
highlight_state,
|
||||||
form_state.total_count,
|
app_state,
|
||||||
form_state.current_position,
|
|
||||||
);
|
);
|
||||||
// --- END FIX ---
|
// --- FIX END ---
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(area) = buffer_list_area {
|
if let Some(area) = buffer_list_area {
|
||||||
@@ -194,23 +216,43 @@ pub fn render_ui(
|
|||||||
app_state,
|
app_state,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(palette_or_command_area) = command_render_area { // Use the calculated area
|
if let Some(palette_or_command_area) = command_render_area {
|
||||||
if navigation_state.active {
|
if navigation_state.active {
|
||||||
find_file_palette::render_find_file_palette(
|
find_file_palette::render_find_file_palette(
|
||||||
f,
|
f,
|
||||||
palette_or_command_area, // Use the correct area
|
palette_or_command_area,
|
||||||
theme,
|
theme,
|
||||||
navigation_state, // Pass the navigation_state directly
|
navigation_state,
|
||||||
);
|
);
|
||||||
} else if event_handler_command_mode_active {
|
} else if event_handler_command_mode_active {
|
||||||
render_command_line(
|
render_command_line(
|
||||||
f,
|
f,
|
||||||
palette_or_command_area, // Use the correct area
|
palette_or_command_area,
|
||||||
event_handler_command_input,
|
event_handler_command_input,
|
||||||
true, // Assuming it's always active when this branch is hit
|
true,
|
||||||
theme,
|
theme,
|
||||||
event_handler_command_message,
|
event_handler_command_message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- FIX START ---
|
||||||
|
// This block now handles drawing popups over any view. This is the correct place for it.
|
||||||
|
if app_state.ui.show_search_palette {
|
||||||
|
if let Some(search_state) = &app_state.search_state {
|
||||||
|
render_search_palette(f, f.area(), theme, search_state);
|
||||||
|
}
|
||||||
|
} else if app_state.ui.dialog.dialog_show {
|
||||||
|
render_dialog(
|
||||||
|
f,
|
||||||
|
f.area(),
|
||||||
|
theme,
|
||||||
|
&app_state.ui.dialog.dialog_title,
|
||||||
|
&app_state.ui.dialog.dialog_message,
|
||||||
|
&app_state.ui.dialog.dialog_buttons,
|
||||||
|
app_state.ui.dialog.dialog_active_button_index,
|
||||||
|
app_state.ui.dialog.is_loading,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// --- FIX END ---
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user