adding to have multiple forms pages

This commit is contained in:
filipriec
2025-08-29 16:18:42 +02:00
parent 75da9c0f4b
commit 58f109ca91
7 changed files with 62 additions and 58 deletions

View File

@@ -17,7 +17,7 @@ pub async fn save(
app_state: &mut AppState,
grpc_client: &mut GrpcClient,
) -> Result<SaveOutcome> {
if let Some(fs) = app_state.form_state_mut() {
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
if !fs.has_unsaved_changes {
return Ok(SaveOutcome::NoChange);
}
@@ -62,7 +62,7 @@ pub async fn save(
.context("Failed to post new table data")?;
if response.success {
if let Some(fs) = app_state.form_state_mut() {
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
fs.id = response.inserted_id;
fs.total_count += 1;
fs.current_position = fs.total_count;
@@ -84,7 +84,7 @@ pub async fn save(
.context("Failed to put (update) table data")?;
if response.success {
if let Some(fs) = app_state.form_state_mut() {
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
fs.has_unsaved_changes = false;
}
SaveOutcome::UpdatedExisting
@@ -103,7 +103,7 @@ pub async fn revert(
app_state: &mut AppState,
grpc_client: &mut GrpcClient,
) -> Result<String> {
if let Some(fs) = app_state.form_state_mut() {
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
if fs.id == 0
|| (fs.total_count > 0 && fs.current_position > fs.total_count)
|| (fs.total_count == 0 && fs.current_position == 1)

View File

@@ -61,18 +61,18 @@ pub fn render_form_page(
f.render_widget(count_para, main_layout[0]);
// --- FORM RENDERING (Using persistent FormEditor) ---
if let Some(editor) = &app_state.form_editor {
let active_field_rect = render_canvas(f, main_layout[1], editor, theme);
// --- SUGGESTIONS DROPDOWN ---
if let Some(active_rect) = active_field_rect {
render_suggestions_dropdown(
f,
main_layout[1],
active_rect,
&DefaultCanvasTheme,
editor,
);
if let Some(AppView::Form(path)) = buffer_state.get_active_view() {
if let Some(editor) = app_state.form_editor.get(path) {
let active_field_rect = render_canvas(f, main_layout[1], editor, theme);
if let Some(active_rect) = active_field_rect {
render_suggestions_dropdown(
f,
main_layout[1],
active_rect,
&DefaultCanvasTheme,
editor,
);
}
}
}
}

View File

@@ -18,7 +18,7 @@ pub enum Page {
Admin(AdminState),
AddLogic(AddLogicState),
AddTable(AddTableState),
Form(FormState),
Form(String),
}
pub struct Router {