fix(records): include _Measure as visible column in records mode (improvise-rbv)
The records mode column filter excluded all categories starting with '_', which hid _Measure. Changed to explicitly exclude only _Index and _Dim, making _Measure visible as a data column. Updated the blank-model editing test to reflect the new column order (_Measure first, Value last). Made-with: Cursor
This commit is contained in:
@ -744,7 +744,8 @@ mod tests {
|
||||
|
||||
/// Regression: editing the first row in a blank model's records view
|
||||
/// should persist the typed value even though plain records mode does not
|
||||
/// use drill state.
|
||||
/// use drill state. With _Measure as the first column, `o` lands on it;
|
||||
/// type a measure name, Tab to Value, type the number, Enter to commit.
|
||||
#[test]
|
||||
fn edit_record_row_in_blank_model_persists_value() {
|
||||
use crate::model::cell::CellKey;
|
||||
@ -753,15 +754,30 @@ mod tests {
|
||||
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
// `o` adds a record row and enters edit at (0, 0) = _Measure column
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('o'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
// Type a measure name
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('e'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('v'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
// Tab to commit _Measure and move to Value column
|
||||
app.handle_key(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
// Type the value
|
||||
app.handle_key(KeyEvent::new(KeyCode::Char('5'), KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
// Enter to commit
|
||||
app.handle_key(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE))
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
app.model.get_cell(&CellKey::new(vec![])),
|
||||
app.model.get_cell(&CellKey::new(vec![
|
||||
("_Measure".to_string(), "Rev".to_string()),
|
||||
])),
|
||||
Some(&crate::model::cell::CellValue::Number(5.0)),
|
||||
"editing a synthetic row in plain records mode should write the value"
|
||||
);
|
||||
|
||||
@ -160,7 +160,7 @@ impl GridLayout {
|
||||
let cat_names: Vec<String> = model
|
||||
.category_names()
|
||||
.into_iter()
|
||||
.filter(|c| !c.starts_with('_'))
|
||||
.filter(|c| *c != "_Index" && *c != "_Dim")
|
||||
.map(String::from)
|
||||
.collect();
|
||||
let mut col_items: Vec<AxisEntry> = cat_names
|
||||
@ -698,6 +698,35 @@ mod tests {
|
||||
assert_eq!(dim, "Region");
|
||||
}
|
||||
|
||||
/// Regression test for improvise-rbv: records mode should include _Measure
|
||||
/// as a _Dim column so the measure name is visible per-record, and "Value"
|
||||
/// must remain the last column.
|
||||
#[test]
|
||||
fn records_mode_includes_measure_in_dim_columns() {
|
||||
let mut m = records_model();
|
||||
let v = m.active_view_mut();
|
||||
v.set_axis("_Index", Axis::Row);
|
||||
v.set_axis("_Dim", Axis::Column);
|
||||
let layout = GridLayout::new(&m, m.active_view());
|
||||
assert!(layout.is_records_mode());
|
||||
let cols: Vec<String> = (0..layout.col_count())
|
||||
.map(|i| layout.col_label(i))
|
||||
.collect();
|
||||
assert!(
|
||||
cols.contains(&"_Measure".to_string()),
|
||||
"records mode should include _Measure column; got {:?}",
|
||||
cols
|
||||
);
|
||||
assert!(cols.contains(&"Region".to_string()));
|
||||
assert!(cols.contains(&"Value".to_string()));
|
||||
assert_eq!(
|
||||
cols.last().unwrap(),
|
||||
"Value",
|
||||
"Value must be the last column so cursor defaults land on it; got {:?}",
|
||||
cols
|
||||
);
|
||||
}
|
||||
|
||||
fn coord(pairs: &[(&str, &str)]) -> CellKey {
|
||||
CellKey::new(
|
||||
pairs
|
||||
|
||||
Reference in New Issue
Block a user