add table page1
This commit is contained in:
@@ -19,8 +19,8 @@ impl AppView {
|
||||
AppView::Intro => "Intro",
|
||||
AppView::Login => "Login",
|
||||
AppView::Register => "Register",
|
||||
AppView::Admin => "Admin_panel",
|
||||
AppView::AddTable => "Add_table",
|
||||
AppView::Admin => "Admin_Panel",
|
||||
AppView::AddTable => "Add_Table",
|
||||
AppView::Form(name) => name.as_str(),
|
||||
AppView::Scratch => "*scratch*",
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ pub mod form;
|
||||
pub mod auth;
|
||||
pub mod admin;
|
||||
pub mod intro;
|
||||
pub mod add_table;
|
||||
pub mod canvas_state;
|
||||
|
||||
68
client/src/state/pages/add_table.rs
Normal file
68
client/src/state/pages/add_table.rs
Normal file
@@ -0,0 +1,68 @@
|
||||
// src/state/pages/add_table.rs
|
||||
use ratatui::widgets::TableState;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ColumnDefinition {
|
||||
pub name: String,
|
||||
pub data_type: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct LinkDefinition {
|
||||
pub linked_table_name: String,
|
||||
pub is_required: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum AddTableFocus {
|
||||
#[default]
|
||||
TableName,
|
||||
Columns,
|
||||
Indexes,
|
||||
Links,
|
||||
SaveButton,
|
||||
CancelButton,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddTableState {
|
||||
pub profile_name: String,
|
||||
pub table_name: String,
|
||||
pub columns: Vec<ColumnDefinition>,
|
||||
pub indexes: Vec<String>,
|
||||
pub links: Vec<LinkDefinition>,
|
||||
pub current_focus: AddTableFocus,
|
||||
pub column_table_state: TableState,
|
||||
pub index_table_state: TableState,
|
||||
pub link_table_state: TableState,
|
||||
pub table_name_cursor_pos: usize,
|
||||
}
|
||||
|
||||
impl Default for AddTableState {
|
||||
fn default() -> Self {
|
||||
// Initialize with some dummy data for demonstration
|
||||
AddTableState {
|
||||
profile_name: "default".to_string(), // Should be set dynamically
|
||||
table_name: "new_table".to_string(),
|
||||
columns: vec![
|
||||
ColumnDefinition { name: "id".to_string(), data_type: "INTEGER".to_string() },
|
||||
ColumnDefinition { name: "name".to_string(), data_type: "TEXT".to_string() },
|
||||
],
|
||||
indexes: vec!["id".to_string()],
|
||||
links: vec![
|
||||
LinkDefinition { linked_table_name: "related_table".to_string(), is_required: true },
|
||||
LinkDefinition { linked_table_name: "another_table".to_string(), is_required: false },
|
||||
],
|
||||
current_focus: AddTableFocus::TableName,
|
||||
column_table_state: TableState::default().with_selected(0),
|
||||
index_table_state: TableState::default().with_selected(0),
|
||||
link_table_state: TableState::default().with_selected(0),
|
||||
table_name_cursor_pos: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddTableState {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// src/state/pages/admin.rs
|
||||
|
||||
use ratatui::widgets::ListState;
|
||||
use crate::state::pages::add_table::AddTableState;
|
||||
|
||||
// Define the focus states for the admin panel panes
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
@@ -21,6 +22,7 @@ pub struct AdminState {
|
||||
pub selected_profile_index: Option<usize>, // Index with [*] in profiles (persistent)
|
||||
pub selected_table_index: Option<usize>, // Index with [*] in tables (persistent)
|
||||
pub current_focus: AdminFocus, // Tracks which pane is focused
|
||||
pub add_table_state: AddTableState,
|
||||
}
|
||||
|
||||
impl AdminState {
|
||||
|
||||
Reference in New Issue
Block a user