trigger dropdown, not working at all, needs proper implementation, ready for debug
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
// src/state/pages/auth.rs
|
||||
use crate::state::canvas_state::CanvasState;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref AVAILABLE_ROLES: Vec<String> = vec![
|
||||
"accountant".to_string(),
|
||||
"admin".to_string(),
|
||||
];
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AuthState {
|
||||
@@ -26,6 +34,9 @@ pub struct RegisterState {
|
||||
pub current_field: usize,
|
||||
pub current_cursor_pos: usize,
|
||||
pub has_unsaved_changes: bool,
|
||||
pub show_role_suggestions: bool,
|
||||
pub role_suggestions: Vec<String>,
|
||||
pub selected_suggestion_index: Option<usize>,
|
||||
}
|
||||
|
||||
impl AuthState {
|
||||
@@ -57,10 +68,32 @@ impl RegisterState {
|
||||
current_field: 0,
|
||||
current_cursor_pos: 0,
|
||||
has_unsaved_changes: false,
|
||||
show_role_suggestions: false,
|
||||
role_suggestions: Vec::new(),
|
||||
selected_suggestion_index: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates role suggestions based on current input.
|
||||
pub fn update_role_suggestions(&mut self) {
|
||||
let current_input = self.role.to_lowercase();
|
||||
if current_input.is_empty() {
|
||||
self.role_suggestions = Vec::new(); // Or show all? For now, clear.
|
||||
self.show_role_suggestions = false;
|
||||
self.selected_suggestion_index = None;
|
||||
} else {
|
||||
self.role_suggestions = AVAILABLE_ROLES
|
||||
.iter()
|
||||
.filter(|r| r.to_lowercase().starts_with(¤t_input))
|
||||
.cloned()
|
||||
.collect();
|
||||
self.show_role_suggestions = !self.role_suggestions.is_empty();
|
||||
self.selected_suggestion_index = if self.show_role_suggestions { Some(0) } else { None }; // Default to first suggestion selected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl CanvasState for AuthState {
|
||||
fn current_field(&self) -> usize {
|
||||
self.current_field
|
||||
|
||||
Reference in New Issue
Block a user