canvas properly updating table name
This commit is contained in:
@@ -34,6 +34,7 @@ pub enum AddTableFocus {
|
||||
pub struct AddTableState {
|
||||
pub profile_name: String,
|
||||
pub table_name: String,
|
||||
pub table_name_input: String,
|
||||
pub column_name_input: String,
|
||||
pub column_type_input: String,
|
||||
pub columns: Vec<ColumnDefinition>,
|
||||
@@ -53,8 +54,9 @@ 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: String::new(), // Start empty
|
||||
profile_name: "default".to_string(),
|
||||
table_name: String::new(),
|
||||
table_name_input: String::new(),
|
||||
column_name_input: String::new(),
|
||||
column_type_input: String::new(),
|
||||
columns: vec![
|
||||
@@ -108,12 +110,12 @@ impl CanvasState for AddTableState {
|
||||
}
|
||||
|
||||
fn inputs(&self) -> Vec<&String> {
|
||||
vec![&self.table_name, &self.column_name_input, &self.column_type_input]
|
||||
vec![&self.table_name_input, &self.column_name_input, &self.column_type_input]
|
||||
}
|
||||
|
||||
fn get_current_input(&self) -> &str {
|
||||
match self.current_focus {
|
||||
AddTableFocus::InputTableName => &self.table_name,
|
||||
AddTableFocus::InputTableName => &self.table_name_input,
|
||||
AddTableFocus::InputColumnName => &self.column_name_input,
|
||||
AddTableFocus::InputColumnType => &self.column_type_input,
|
||||
_ => "", // Should not happen if called correctly
|
||||
@@ -122,14 +124,10 @@ impl CanvasState for AddTableState {
|
||||
|
||||
fn get_current_input_mut(&mut self) -> &mut String {
|
||||
match self.current_focus {
|
||||
AddTableFocus::InputTableName => &mut self.table_name,
|
||||
AddTableFocus::InputTableName => &mut self.table_name_input,
|
||||
AddTableFocus::InputColumnName => &mut self.column_name_input,
|
||||
AddTableFocus::InputColumnType => &mut self.column_type_input,
|
||||
// This case needs careful handling. If focus isn't on an input,
|
||||
// which mutable string should we return? Returning the first one
|
||||
// might be unexpected. Consider panicking or returning Option if this state is invalid.
|
||||
// For now, returning the first field to avoid panics during rendering.
|
||||
_ => &mut self.table_name,
|
||||
_ => &mut self.table_name_input,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user