working admin panel, needs to do buttons for navigation next
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// src/state/pages/admin.rs
|
||||
|
||||
use ratatui::widgets::ListState;
|
||||
use std::collections::HashSet;
|
||||
|
||||
// Define the focus states for the admin panel panes
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
@@ -13,10 +12,11 @@ pub enum AdminFocus {
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct AdminState {
|
||||
pub profiles: Vec<String>,
|
||||
pub profile_list_state: ListState, // State for the profiles list
|
||||
pub table_list_state: ListState, // State for the tables list navigation/highlight
|
||||
pub selected_table_indices: HashSet<usize>, // Indices of tables marked with [*]
|
||||
pub profiles: Vec<String>, // Holds profile names (used by non-admin view)
|
||||
pub profile_list_state: ListState, // Tracks navigation highlight (>) in profiles
|
||||
pub table_list_state: ListState, // Tracks navigation highlight (>) in tables
|
||||
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
|
||||
}
|
||||
|
||||
@@ -86,8 +86,7 @@ impl AdminState {
|
||||
/// Selects a profile by index and resets table selection.
|
||||
pub fn select_profile(&mut self, index: Option<usize>) {
|
||||
self.profile_list_state.select(index);
|
||||
self.table_list_state.select(None); // Reset table selection
|
||||
self.selected_table_indices.clear();
|
||||
self.table_list_state.select(None);
|
||||
}
|
||||
|
||||
/// Selects a table by index.
|
||||
@@ -179,16 +178,5 @@ impl AdminState {
|
||||
};
|
||||
}
|
||||
|
||||
/// Toggles the selection state of the table at the given index.
|
||||
pub fn toggle_table_selection(&mut self, index: usize) {
|
||||
if !self.selected_table_indices.remove(&index) {
|
||||
// If remove returned false, it wasn't present, so insert it.
|
||||
self.selected_table_indices.insert(index);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_table_selected(&self, index: usize) -> bool {
|
||||
self.selected_table_indices.contains(&index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user