suggestions on tab, still not working yet
This commit is contained in:
@@ -4,8 +4,10 @@ use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref AVAILABLE_ROLES: Vec<String> = vec![
|
||||
"accountant".to_string(),
|
||||
"admin".to_string(),
|
||||
"moderator".to_string(),
|
||||
"accountant".to_string(),
|
||||
"viewer".to_string(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -37,6 +39,7 @@ pub struct RegisterState {
|
||||
pub show_role_suggestions: bool,
|
||||
pub role_suggestions: Vec<String>,
|
||||
pub selected_suggestion_index: Option<usize>,
|
||||
pub in_suggestion_mode: bool,
|
||||
}
|
||||
|
||||
impl AuthState {
|
||||
@@ -71,6 +74,7 @@ impl RegisterState {
|
||||
show_role_suggestions: false,
|
||||
role_suggestions: Vec::new(),
|
||||
selected_suggestion_index: None,
|
||||
in_suggestion_mode: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +82,7 @@ impl RegisterState {
|
||||
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;
|
||||
self.role_suggestions = AVAILABLE_ROLES.to_vec();
|
||||
} else {
|
||||
self.role_suggestions = AVAILABLE_ROLES
|
||||
.iter()
|
||||
@@ -88,7 +90,6 @@ impl RegisterState {
|
||||
.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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,7 +270,7 @@ impl CanvasState for RegisterState {
|
||||
|
||||
fn get_suggestions(&self) -> Option<&[String]> {
|
||||
// Only show suggestions for the role field (index 4) when requested
|
||||
if self.current_field == 4 && self.show_role_suggestions {
|
||||
if self.current_field == 4 && self.in_suggestion_mode && self.show_role_suggestions {
|
||||
Some(&self.role_suggestions)
|
||||
} else {
|
||||
None
|
||||
@@ -277,8 +278,7 @@ impl CanvasState for RegisterState {
|
||||
}
|
||||
|
||||
fn get_selected_suggestion_index(&self) -> Option<usize> {
|
||||
// Only return index if suggestions are shown for the role field
|
||||
if self.current_field == 4 && self.show_role_suggestions {
|
||||
if self.current_field == 4 && self.in_suggestion_mode && self.show_role_suggestions {
|
||||
self.selected_suggestion_index
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user