form pages robust finish chnages
This commit is contained in:
@@ -113,6 +113,13 @@ impl AppState {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn is_canvas_edit_mode_at(&self, path: &str) -> bool {
|
||||
self.form_editor
|
||||
.get(path)
|
||||
.map(|e| matches!(e.mode(), canvas::AppMode::Edit))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
// Mutable editor accessor
|
||||
pub fn editor_for_path(&mut self, path: &str) -> Option<&mut FormEditor<FormState>> {
|
||||
self.form_editor.get_mut(path)
|
||||
|
||||
@@ -151,12 +151,13 @@ pub fn render_ui(
|
||||
} else {
|
||||
(0, 1)
|
||||
};
|
||||
let table_name = path.split('/').nth(1).unwrap_or("");
|
||||
|
||||
render_form_page(
|
||||
f,
|
||||
form_render_area,
|
||||
editor,
|
||||
app_state.current_view_table_name.as_deref().unwrap_or(""),
|
||||
table_name,
|
||||
theme,
|
||||
total_count,
|
||||
current_position,
|
||||
|
||||
@@ -446,6 +446,9 @@ pub async fn run_ui() -> Result<()> {
|
||||
AppView::AddLogic => router.navigate(Page::AddLogic(admin_state.add_logic_state.clone())),
|
||||
AppView::Form(path) => {
|
||||
// Router now carries the path; just navigate with it
|
||||
if let Some((profile, table)) = path.split_once('/') {
|
||||
app_state.set_current_view_table(profile.to_string(), table.to_string());
|
||||
}
|
||||
router.navigate(Page::Form(path.clone()));
|
||||
}
|
||||
AppView::Scratch => {}
|
||||
@@ -610,7 +613,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
|
||||
if let Page::Form(path) = &router.current {
|
||||
if !table_just_switched {
|
||||
if position_changed && !app_state.is_canvas_edit_mode() {
|
||||
if position_changed && !app_state.is_canvas_edit_mode_at(path) {
|
||||
position_logic_needs_redraw = true;
|
||||
|
||||
if let Some(form_state) = app_state.form_state_for_path(path) {
|
||||
@@ -648,7 +651,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
form_state.current_cursor_pos =
|
||||
event_handler.ideal_cursor_column.min(max_cursor_pos);
|
||||
}
|
||||
} else if !position_changed && !app_state.is_canvas_edit_mode() {
|
||||
} else if !position_changed && !app_state.is_canvas_edit_mode_at(path) {
|
||||
if let Some(form_state) = app_state.form_state_for_path(path) {
|
||||
let current_input_str = form_state.get_current_input();
|
||||
let current_input_len = current_input_str.chars().count();
|
||||
|
||||
Reference in New Issue
Block a user