chore: format
This commit is contained in:
@ -12,8 +12,8 @@ use ratatui::style::Color;
|
||||
use crate::command::cmd::CmdContext;
|
||||
use crate::command::keymap::{Keymap, KeymapSet};
|
||||
use crate::import::wizard::ImportWizard;
|
||||
use crate::model::cell::CellValue;
|
||||
use crate::model::Model;
|
||||
use crate::model::cell::CellValue;
|
||||
use crate::persistence;
|
||||
use crate::ui::grid::{
|
||||
compute_col_widths, compute_row_header_width, compute_visible_cols, parse_number_format,
|
||||
@ -338,7 +338,9 @@ impl App {
|
||||
self.model.categories.values().all(|c| {
|
||||
matches!(
|
||||
c.kind,
|
||||
CategoryKind::VirtualIndex | CategoryKind::VirtualDim | CategoryKind::VirtualMeasure
|
||||
CategoryKind::VirtualIndex
|
||||
| CategoryKind::VirtualDim
|
||||
| CategoryKind::VirtualMeasure
|
||||
)
|
||||
})
|
||||
}
|
||||
@ -389,16 +391,26 @@ impl App {
|
||||
/// Hint text for the status bar (context-sensitive)
|
||||
pub fn hint_text(&self) -> &'static str {
|
||||
match &self.mode {
|
||||
AppMode::Normal => "hjkl:nav i:edit R:records P:prune F/C/V:panels T:tiles [:]:page >:drill ::cmd",
|
||||
AppMode::Normal => {
|
||||
"hjkl:nav i:edit R:records P:prune F/C/V:panels T:tiles [:]:page >:drill ::cmd"
|
||||
}
|
||||
AppMode::Editing { .. } => "Enter:commit Tab:commit+right Esc:cancel",
|
||||
AppMode::FormulaPanel => "n:new d:delete jk:nav Esc:back",
|
||||
AppMode::FormulaEdit { .. } => "Enter:save Esc:cancel — type: Name = expression",
|
||||
AppMode::CategoryPanel => "jk:nav Space:cycle-axis n:new-cat a:add-items d:delete Esc:back",
|
||||
AppMode::CategoryAdd { .. } => "Enter:add & continue Tab:same Esc:done — type a category name",
|
||||
AppMode::ItemAdd { .. } => "Enter:add & continue Tab:same Esc:done — type an item name",
|
||||
AppMode::CategoryPanel => {
|
||||
"jk:nav Space:cycle-axis n:new-cat a:add-items d:delete Esc:back"
|
||||
}
|
||||
AppMode::CategoryAdd { .. } => {
|
||||
"Enter:add & continue Tab:same Esc:done — type a category name"
|
||||
}
|
||||
AppMode::ItemAdd { .. } => {
|
||||
"Enter:add & continue Tab:same Esc:done — type an item name"
|
||||
}
|
||||
AppMode::ViewPanel => "jk:nav Enter:switch n:new d:delete Esc:back",
|
||||
AppMode::TileSelect => "hl:select Enter:cycle r/c/p/n:set-axis Esc:back",
|
||||
AppMode::CommandMode { .. } => ":q quit :w save :import :add-cat :formula :show-item :help",
|
||||
AppMode::CommandMode { .. } => {
|
||||
":q quit :w save :import :add-cat :formula :show-item :help"
|
||||
}
|
||||
AppMode::ImportWizard => "Space:toggle c:cycle Enter:next Esc:cancel",
|
||||
AppMode::Help => "h/l:pages q/Esc:close",
|
||||
_ => "",
|
||||
|
||||
@ -6,7 +6,7 @@ use ratatui::{
|
||||
|
||||
use crate::model::Model;
|
||||
use crate::ui::app::AppMode;
|
||||
use crate::ui::cat_tree::{build_cat_tree, CatTreeEntry};
|
||||
use crate::ui::cat_tree::{CatTreeEntry, build_cat_tree};
|
||||
use crate::ui::panel::PanelContent;
|
||||
use crate::view::Axis;
|
||||
|
||||
|
||||
@ -743,7 +743,7 @@ pub struct ImportJsonHeadless {
|
||||
impl Effect for ImportJsonHeadless {
|
||||
fn apply(&self, app: &mut App) {
|
||||
use crate::import::analyzer::{
|
||||
analyze_records, extract_array_at_path, find_array_paths, FieldKind,
|
||||
FieldKind, analyze_records, extract_array_at_path, find_array_paths,
|
||||
};
|
||||
use crate::import::wizard::ImportPipeline;
|
||||
|
||||
@ -952,8 +952,8 @@ pub fn help_page_set(page: usize) -> Box<dyn Effect> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::model::cell::{CellKey, CellValue};
|
||||
use crate::model::Model;
|
||||
use crate::model::cell::{CellKey, CellValue};
|
||||
|
||||
fn test_app() -> App {
|
||||
let mut m = Model::new("Test");
|
||||
@ -1036,12 +1036,13 @@ mod tests {
|
||||
fn add_formula_adds_target_item_to_category() {
|
||||
let mut app = test_app();
|
||||
// "Margin" does not exist as an item in "Type" before adding the formula
|
||||
assert!(!app
|
||||
.model
|
||||
.category("Type")
|
||||
.unwrap()
|
||||
.ordered_item_names()
|
||||
.contains(&"Margin"));
|
||||
assert!(
|
||||
!app.model
|
||||
.category("Type")
|
||||
.unwrap()
|
||||
.ordered_item_names()
|
||||
.contains(&"Margin")
|
||||
);
|
||||
AddFormula {
|
||||
raw: "Margin = Food * 2".to_string(),
|
||||
target_category: "Type".to_string(),
|
||||
@ -1257,16 +1258,14 @@ mod tests {
|
||||
#[test]
|
||||
fn set_buffer_empty_clears() {
|
||||
let mut app = test_app();
|
||||
app.buffers.insert("formula".to_string(), "old text".to_string());
|
||||
app.buffers
|
||||
.insert("formula".to_string(), "old text".to_string());
|
||||
SetBuffer {
|
||||
name: "formula".to_string(),
|
||||
value: String::new(),
|
||||
}
|
||||
.apply(&mut app);
|
||||
assert_eq!(
|
||||
app.buffers.get("formula").map(|s| s.as_str()),
|
||||
Some(""),
|
||||
);
|
||||
assert_eq!(app.buffers.get("formula").map(|s| s.as_str()), Some(""),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1597,19 +1596,21 @@ mod tests {
|
||||
group: "MyGroup".to_string(),
|
||||
}
|
||||
.apply(&mut app);
|
||||
assert!(app
|
||||
.model
|
||||
.active_view()
|
||||
.is_group_collapsed("Type", "MyGroup"));
|
||||
assert!(
|
||||
app.model
|
||||
.active_view()
|
||||
.is_group_collapsed("Type", "MyGroup")
|
||||
);
|
||||
ToggleGroup {
|
||||
category: "Type".to_string(),
|
||||
group: "MyGroup".to_string(),
|
||||
}
|
||||
.apply(&mut app);
|
||||
assert!(!app
|
||||
.model
|
||||
.active_view()
|
||||
.is_group_collapsed("Type", "MyGroup"));
|
||||
assert!(
|
||||
!app.model
|
||||
.active_view()
|
||||
.is_group_collapsed("Type", "MyGroup")
|
||||
);
|
||||
}
|
||||
|
||||
// ── Cycle axis ──────────────────────────────────────────────────────
|
||||
|
||||
@ -674,8 +674,8 @@ mod tests {
|
||||
|
||||
use super::GridWidget;
|
||||
use crate::formula::parse_formula;
|
||||
use crate::model::cell::{CellKey, CellValue};
|
||||
use crate::model::Model;
|
||||
use crate::model::cell::{CellKey, CellValue};
|
||||
use crate::ui::app::AppMode;
|
||||
use crate::view::GridLayout;
|
||||
|
||||
@ -914,8 +914,10 @@ mod tests {
|
||||
CellValue::Number(600.0),
|
||||
);
|
||||
m.add_formula(parse_formula("Profit = Revenue - Cost", "_Measure").unwrap());
|
||||
m.active_view_mut().set_axis("_Measure", crate::view::Axis::Row);
|
||||
m.active_view_mut().set_axis("Region", crate::view::Axis::Column);
|
||||
m.active_view_mut()
|
||||
.set_axis("_Measure", crate::view::Axis::Row);
|
||||
m.active_view_mut()
|
||||
.set_axis("Region", crate::view::Axis::Column);
|
||||
|
||||
let text = buf_text(&render(&m, 80, 24));
|
||||
assert!(text.contains("400"), "expected '400' (Profit) in:\n{text}");
|
||||
|
||||
Reference in New Issue
Block a user