From 6d4b19a94069df9f8c9b7ab0adf8234318aade81 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Wed, 15 Apr 2026 04:37:06 -0700 Subject: [PATCH] fix(model): default _Measure to Page axis, skip empty page categories (improvise-kos) Virtual categories _Index and _Dim now default to None on new models instead of being forced onto Row/Column. _Measure defaults to Page (the natural home for measure filtering). Fixed page_coords builder to skip Page categories with no items/selection, preventing empty-string contamination of cell keys. Made-with: Cursor --- src/model/types.rs | 5 +++-- src/view/layout.rs | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/model/types.rs b/src/model/types.rs index deca012..bc1ca4f 100644 --- a/src/model/types.rs +++ b/src/model/types.rs @@ -65,6 +65,7 @@ impl Model { view.on_category_added("_Index"); view.on_category_added("_Dim"); view.on_category_added("_Measure"); + view.set_axis("_Measure", crate::view::Axis::Page); } m } @@ -869,7 +870,7 @@ mod model_tests { let v = m.active_view(); assert_eq!(v.axis_of("_Index"), Axis::None); assert_eq!(v.axis_of("_Dim"), Axis::None); - assert_eq!(v.axis_of("_Measure"), Axis::None); + assert_eq!(v.axis_of("_Measure"), Axis::Page); } #[test] @@ -1950,7 +1951,7 @@ mod five_category { assert_eq!(v.axis_of("Product"), Axis::Column); assert_eq!(v.axis_of("Channel"), Axis::Page); assert_eq!(v.axis_of("Time"), Axis::Page); - assert_eq!(v.axis_of("_Measure"), Axis::None); + assert_eq!(v.axis_of("_Measure"), Axis::Page); } #[test] diff --git a/src/view/layout.rs b/src/view/layout.rs index 37c457b..a549b08 100644 --- a/src/view/layout.rs +++ b/src/view/layout.rs @@ -93,14 +93,13 @@ impl GridLayout { let page_coords = page_cats .iter() - .map(|cat| { + .filter_map(|cat| { let items: Vec = model.effective_item_names(cat); let sel = view .page_selection(cat) .map(String::from) - .or_else(|| items.first().cloned()) - .unwrap_or_default(); - (cat.clone(), sel) + .or_else(|| items.first().cloned())?; + Some((cat.clone(), sel)) }) .collect(); @@ -594,6 +593,9 @@ mod tests { ]), CellValue::Number(50.0), ); + // Records mode setup: _Measure should not filter + m.active_view_mut() + .set_axis("_Measure", Axis::None); m }