readonly and edit functionality to add table

This commit is contained in:
filipriec
2025-04-17 14:14:36 +02:00
parent 57f789290d
commit c5d7f56399
11 changed files with 967 additions and 254 deletions

View File

@@ -28,6 +28,7 @@ use crate::state::{
auth::{AuthState, LoginState, RegisterState},
admin::AdminState,
canvas_state::CanvasState,
add_table::AddTableState,
form::FormState,
intro::IntroState,
},
@@ -349,6 +350,7 @@ impl EventHandler {
form_state,
login_state,
register_state,
&mut admin_state.add_table_state,
&mut self.key_sequence_tracker,
current_position,
total_count,
@@ -383,7 +385,7 @@ impl EventHandler {
let (_should_exit, message) = read_only::handle_read_only_event(
app_state, key, config, form_state, login_state,
register_state, &mut self.key_sequence_tracker,
register_state, &mut admin_state.add_table_state, &mut self.key_sequence_tracker,
current_position, total_count, grpc_client,
&mut self.command_message, &mut self.edit_mode_cooldown,
&mut self.ideal_cursor_column,
@@ -431,6 +433,7 @@ impl EventHandler {
form_state,
login_state,
register_state,
&mut admin_state.add_table_state,
&mut self.ideal_cursor_column,
current_position,
total_count,

View File

@@ -2,6 +2,8 @@
use crate::state::app::state::AppState;
use crate::modes::handlers::event::EventHandler;
use crate::state::app::highlight::HighlightState;
use crate::state::pages::add_table::AddTableFocus;
use crate::state::pages::admin::AdminState;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AppMode {
@@ -29,17 +31,20 @@ impl ModeManager {
return AppMode::General;
}
if app_state.ui.show_login || app_state.ui.show_register {
if event_handler.is_edit_mode {
AppMode::Edit
let is_canvas_view = app_state.ui.show_login
|| app_state.ui.show_register
|| app_state.ui.show_form
|| app_state.ui.show_add_table;
if is_canvas_view {
if app_state.ui.focus_outside_canvas {
AppMode::General
} else {
AppMode::ReadOnly
}
} else if app_state.ui.show_form {
if event_handler.is_edit_mode {
AppMode::Edit
} else {
AppMode::ReadOnly
if event_handler.is_edit_mode {
AppMode::Edit
} else {
AppMode::ReadOnly
}
}
} else {
AppMode::General