we compiled but buffer doesnt work
This commit is contained in:
@@ -15,9 +15,10 @@ pub enum SaveOutcome {
|
||||
|
||||
pub async fn save(
|
||||
app_state: &mut AppState,
|
||||
path: &str,
|
||||
grpc_client: &mut GrpcClient,
|
||||
) -> Result<SaveOutcome> {
|
||||
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
|
||||
if let Some(fs) = app_state.form_state_for_path(path) {
|
||||
if !fs.has_unsaved_changes {
|
||||
return Ok(SaveOutcome::NoChange);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ pub async fn save(
|
||||
.context("Failed to post new table data")?;
|
||||
|
||||
if response.success {
|
||||
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
|
||||
if let Some(fs) = app_state.form_state_for_path(path) {
|
||||
fs.id = response.inserted_id;
|
||||
fs.total_count += 1;
|
||||
fs.current_position = fs.total_count;
|
||||
@@ -84,7 +85,7 @@ pub async fn save(
|
||||
.context("Failed to put (update) table data")?;
|
||||
|
||||
if response.success {
|
||||
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
|
||||
if let Some(fs) = app_state.form_state_for_path(path) {
|
||||
fs.has_unsaved_changes = false;
|
||||
}
|
||||
SaveOutcome::UpdatedExisting
|
||||
@@ -101,9 +102,10 @@ pub async fn save(
|
||||
|
||||
pub async fn revert(
|
||||
app_state: &mut AppState,
|
||||
path: &str,
|
||||
grpc_client: &mut GrpcClient,
|
||||
) -> Result<String> {
|
||||
if let Some(fs) = app_state.active_form_state_mut(buffer_state) {
|
||||
if let Some(fs) = app_state.form_state_for_path(path) {
|
||||
if fs.id == 0
|
||||
|| (fs.total_count > 0 && fs.current_position > fs.total_count)
|
||||
|| (fs.total_count == 0 && fs.current_position == 1)
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
// src/pages/forms/ui.rs
|
||||
use crate::config::colors::themes::Theme;
|
||||
use crate::state::app::state::AppState;
|
||||
use ratatui::{
|
||||
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
|
||||
style::Style,
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use crate::pages::forms::FormState;
|
||||
use canvas::{
|
||||
render_canvas, render_suggestions_dropdown, DefaultCanvasTheme,
|
||||
render_canvas, render_suggestions_dropdown, DefaultCanvasTheme, FormEditor,
|
||||
};
|
||||
use crate::pages::forms::FormState;
|
||||
|
||||
pub fn render_form_page(
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
app_state: &AppState,
|
||||
form_state: &FormState, // not needed directly anymore, editor holds it
|
||||
editor: &FormEditor<FormState>,
|
||||
table_name: &str,
|
||||
theme: &Theme,
|
||||
total_count: u64,
|
||||
@@ -61,18 +59,14 @@ pub fn render_form_page(
|
||||
f.render_widget(count_para, main_layout[0]);
|
||||
|
||||
// --- FORM RENDERING (Using persistent FormEditor) ---
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ pub fn handle_intro_selection(
|
||||
index: usize,
|
||||
) {
|
||||
let target_view = match index {
|
||||
0 => AppView::Form,
|
||||
0 => AppView::Form("".to_string()), // or better: pick a real path
|
||||
1 => AppView::Admin,
|
||||
2 => AppView::Login,
|
||||
3 => AppView::Register,
|
||||
|
||||
Reference in New Issue
Block a user