fixing 8
This commit is contained in:
@@ -3,8 +3,7 @@ use crate::config::colors::themes::Theme;
|
|||||||
use crate::state::app::highlight::HighlightState;
|
use crate::state::app::highlight::HighlightState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
use crate::state::pages::add_logic::{AddLogicFocus, AddLogicState};
|
use crate::state::pages::add_logic::{AddLogicFocus, AddLogicState};
|
||||||
use canvas::{render_canvas_default, render_canvas};
|
use canvas::{render_canvas, FormEditor};
|
||||||
use canvas::canvas::HighlightState as CanvasHighlightState;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
@@ -15,15 +14,6 @@ use ratatui::{
|
|||||||
use crate::components::common::{dialog, autocomplete}; // Added autocomplete
|
use crate::components::common::{dialog, autocomplete}; // Added autocomplete
|
||||||
use crate::config::binds::config::EditorKeybindingMode;
|
use crate::config::binds::config::EditorKeybindingMode;
|
||||||
|
|
||||||
// Helper function to convert between HighlightState types
|
|
||||||
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
|
|
||||||
match local {
|
|
||||||
HighlightState::Off => CanvasHighlightState::Off,
|
|
||||||
HighlightState::Characterwise { anchor } => CanvasHighlightState::Characterwise { anchor: *anchor },
|
|
||||||
HighlightState::Linewise { anchor_line } => CanvasHighlightState::Linewise { anchor_line: *anchor_line },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn render_add_logic(
|
pub fn render_add_logic(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
area: Rect,
|
area: Rect,
|
||||||
@@ -31,7 +21,6 @@ pub fn render_add_logic(
|
|||||||
app_state: &AppState,
|
app_state: &AppState,
|
||||||
add_logic_state: &mut AddLogicState,
|
add_logic_state: &mut AddLogicState,
|
||||||
is_edit_mode: bool,
|
is_edit_mode: bool,
|
||||||
highlight_state: &HighlightState,
|
|
||||||
) {
|
) {
|
||||||
let main_block = Block::default()
|
let main_block = Block::default()
|
||||||
.title(" Add New Logic Script ")
|
.title(" Add New Logic Script ")
|
||||||
@@ -169,16 +158,12 @@ pub fn render_add_logic(
|
|||||||
| AddLogicFocus::InputDescription
|
| AddLogicFocus::InputDescription
|
||||||
);
|
);
|
||||||
|
|
||||||
let canvas_highlight_state = convert_highlight_state(highlight_state);
|
let editor = FormEditor::new(add_logic_state.clone());
|
||||||
let active_field_rect = render_canvas(
|
let active_field_rect = render_canvas(f, canvas_area, &editor, theme);
|
||||||
f,
|
|
||||||
canvas_area,
|
|
||||||
add_logic_state, // will later be wrapped in FormEditor
|
|
||||||
);
|
|
||||||
|
|
||||||
// --- Render Autocomplete for Target Column ---
|
// --- Render Autocomplete for Target Column ---
|
||||||
// `is_edit_mode` here refers to the general edit mode of the EventHandler
|
// `is_edit_mode` here refers to the general edit mode of the EventHandler
|
||||||
if is_edit_mode && add_logic_state.current_field() == 1 { // Target Column field
|
if is_edit_mode && editor.current_field() == 1 { // Target Column field
|
||||||
if add_logic_state.in_target_column_suggestion_mode && add_logic_state.show_target_column_suggestions {
|
if add_logic_state.in_target_column_suggestion_mode && add_logic_state.show_target_column_suggestions {
|
||||||
if !add_logic_state.target_column_suggestions.is_empty() {
|
if !add_logic_state.target_column_suggestions.is_empty() {
|
||||||
if let Some(input_rect) = active_field_rect {
|
if let Some(input_rect) = active_field_rect {
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ use crate::config::colors::themes::Theme;
|
|||||||
use crate::state::app::highlight::HighlightState;
|
use crate::state::app::highlight::HighlightState;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
use crate::state::pages::add_table::{AddTableFocus, AddTableState};
|
use crate::state::pages::add_table::{AddTableFocus, AddTableState};
|
||||||
use canvas::{render_canvas_default, render_canvas};
|
use canvas::{render_canvas_default, render_canvas, FormEditor};
|
||||||
use canvas::canvas::HighlightState as CanvasHighlightState;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
@@ -14,15 +13,6 @@ use ratatui::{
|
|||||||
};
|
};
|
||||||
use crate::components::common::dialog;
|
use crate::components::common::dialog;
|
||||||
|
|
||||||
// Helper function to convert between HighlightState types
|
|
||||||
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
|
|
||||||
match local {
|
|
||||||
HighlightState::Off => CanvasHighlightState::Off,
|
|
||||||
HighlightState::Characterwise { anchor } => CanvasHighlightState::Characterwise { anchor: *anchor },
|
|
||||||
HighlightState::Linewise { anchor_line } => CanvasHighlightState::Linewise { anchor_line: *anchor_line },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Renders the Add New Table page layout, structuring the display of table information,
|
/// Renders the Add New Table page layout, structuring the display of table information,
|
||||||
/// input fields, and action buttons. Adapts layout based on terminal width.
|
/// input fields, and action buttons. Adapts layout based on terminal width.
|
||||||
pub fn render_add_table(
|
pub fn render_add_table(
|
||||||
@@ -358,12 +348,8 @@ pub fn render_add_table(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// --- Canvas Rendering (Column Definition Input) - USING CANVAS LIBRARY ---
|
// --- Canvas Rendering (Column Definition Input) - USING CANVAS LIBRARY ---
|
||||||
let canvas_highlight_state = convert_highlight_state(highlight_state);
|
let editor = FormEditor::new(add_table_state.clone());
|
||||||
let _active_field_rect = render_canvas(
|
let _active_field_rect = render_canvas(f, canvas_area, &editor, theme);
|
||||||
f,
|
|
||||||
canvas_area,
|
|
||||||
add_table_state, // will later be wrapped in FormEditor
|
|
||||||
);
|
|
||||||
|
|
||||||
// --- Button Style Helpers ---
|
// --- Button Style Helpers ---
|
||||||
let get_button_style = |button_focus: AddTableFocus, current_focus| {
|
let get_button_style = |button_focus: AddTableFocus, current_focus| {
|
||||||
|
|||||||
@@ -19,20 +19,6 @@ use canvas::{
|
|||||||
render_suggestions_dropdown,
|
render_suggestions_dropdown,
|
||||||
DefaultCanvasTheme,
|
DefaultCanvasTheme,
|
||||||
};
|
};
|
||||||
use canvas::canvas::HighlightState as CanvasHighlightState;
|
|
||||||
|
|
||||||
// Helper function to convert between HighlightState types
|
|
||||||
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
|
|
||||||
match local {
|
|
||||||
HighlightState::Off => CanvasHighlightState::Off,
|
|
||||||
HighlightState::Characterwise { anchor } => {
|
|
||||||
CanvasHighlightState::Characterwise { anchor: *anchor }
|
|
||||||
}
|
|
||||||
HighlightState::Linewise { anchor_line } => {
|
|
||||||
CanvasHighlightState::Linewise { anchor_line: *anchor_line }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn render_login(
|
pub fn render_login(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
@@ -69,11 +55,8 @@ pub fn render_login(
|
|||||||
])
|
])
|
||||||
.split(inner_area);
|
.split(inner_area);
|
||||||
|
|
||||||
// --- FORM RENDERING (Using new canvas API) ---
|
|
||||||
let _canvas_highlight_state = convert_highlight_state(highlight_state);
|
|
||||||
|
|
||||||
// Wrap LoginState in FormEditor (no clone needed)
|
// Wrap LoginState in FormEditor (no clone needed)
|
||||||
let editor = FormEditor::new(login_state);
|
let editor = FormEditor::new(login_state.clone());
|
||||||
|
|
||||||
// Use DefaultCanvasTheme instead of app Theme
|
// Use DefaultCanvasTheme instead of app Theme
|
||||||
let input_rect = render_canvas(
|
let input_rect = render_canvas(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
use crate::tui::terminal::core::TerminalCore;
|
use crate::tui::terminal::core::TerminalCore;
|
||||||
use crate::state::app::state::AppState;
|
use crate::state::app::state::AppState;
|
||||||
use crate::state::pages::{form::FormState, auth::LoginState, auth::RegisterState};
|
use crate::state::pages::{form::FormState, auth::LoginState, auth::RegisterState};
|
||||||
use canvas::canvas::CanvasState;
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
pub struct CommandHandler;
|
pub struct CommandHandler;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::state::pages::admin::AdminState;
|
|||||||
use crate::ui::handlers::context::UiContext;
|
use crate::ui::handlers::context::UiContext;
|
||||||
use crate::modes::handlers::event::EventOutcome;
|
use crate::modes::handlers::event::EventOutcome;
|
||||||
use crate::modes::general::command_navigation::{handle_command_navigation_event, NavigationState};
|
use crate::modes::general::command_navigation::{handle_command_navigation_event, NavigationState};
|
||||||
use canvas::canvas::CanvasState;
|
use canvas::DataProvider;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
pub async fn handle_navigation_event(
|
pub async fn handle_navigation_event(
|
||||||
@@ -90,10 +90,10 @@ pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_
|
|||||||
if app_state.focused_button_index == 0 {
|
if app_state.focused_button_index == 0 {
|
||||||
app_state.ui.focus_outside_canvas = false;
|
app_state.ui.focus_outside_canvas = false;
|
||||||
if app_state.ui.show_login {
|
if app_state.ui.show_login {
|
||||||
let last_field_index = login_state.fields().len().saturating_sub(1);
|
let last_field_index = login_state.field_count().saturating_sub(1);
|
||||||
login_state.set_current_field(last_field_index);
|
login_state.set_current_field(last_field_index);
|
||||||
} else {
|
} else {
|
||||||
let last_field_index = register_state.fields().len().saturating_sub(1);
|
let last_field_index = register_state.field_count().saturating_sub(1);
|
||||||
register_state.set_current_field(last_field_index);
|
register_state.set_current_field(last_field_index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ pub fn render_ui(
|
|||||||
register_state,
|
register_state,
|
||||||
app_state,
|
app_state,
|
||||||
register_state.current_field() < 4, // Now using CanvasState trait method
|
register_state.current_field() < 4, // Now using CanvasState trait method
|
||||||
highlight_state, // Uses local version
|
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_add_table {
|
} else if app_state.ui.show_add_table {
|
||||||
render_add_table(
|
render_add_table(
|
||||||
@@ -146,7 +145,6 @@ pub fn render_ui(
|
|||||||
app_state,
|
app_state,
|
||||||
&mut admin_state.add_table_state,
|
&mut admin_state.add_table_state,
|
||||||
is_event_handler_edit_mode,
|
is_event_handler_edit_mode,
|
||||||
highlight_state, // Uses local version
|
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_add_logic {
|
} else if app_state.ui.show_add_logic {
|
||||||
render_add_logic(
|
render_add_logic(
|
||||||
@@ -156,7 +154,6 @@ pub fn render_ui(
|
|||||||
app_state,
|
app_state,
|
||||||
&mut admin_state.add_logic_state,
|
&mut admin_state.add_logic_state,
|
||||||
is_event_handler_edit_mode,
|
is_event_handler_edit_mode,
|
||||||
highlight_state, // Uses local version
|
|
||||||
);
|
);
|
||||||
} else if app_state.ui.show_login {
|
} else if app_state.ui.show_login {
|
||||||
render_login(
|
render_login(
|
||||||
@@ -166,7 +163,6 @@ pub fn render_ui(
|
|||||||
login_state,
|
login_state,
|
||||||
app_state,
|
app_state,
|
||||||
login_state.current_field() < 2, // Now using CanvasState trait method
|
login_state.current_field() < 2, // Now using CanvasState trait method
|
||||||
highlight_state, // Uses local version
|
|
||||||
);
|
);
|
||||||
} 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(
|
||||||
|
|||||||
Reference in New Issue
Block a user