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
This commit is contained in:
Edward Langley
2026-04-15 04:37:06 -07:00
parent 709f2df11f
commit 6d4b19a940
2 changed files with 9 additions and 6 deletions

View File

@ -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]

View File

@ -93,14 +93,13 @@ impl GridLayout {
let page_coords = page_cats
.iter()
.map(|cat| {
.filter_map(|cat| {
let items: Vec<String> = 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
}