mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-09 12:02:49 +00:00
Open the Header & Footer dialog on the sheet's saved header and footer (#523)
This commit is contained in:
1 parent
3926d21aa9
commit
194a1204ab
2 files changed
+23
-1
No files matched your search
@@ -368,7 +368,11 @@ impl Dialog {
|
||||
Text { key: "header", label: "Header (&L left, &C center, &R right; &P page, &N pages, &D date, &A sheet):" },
|
||||
Text { key: "footer", label: "Footer:" },
|
||||
],
|
||||
json!({"header": "", "footer": "&CPage &P of &N"}),
|
||||
{
|
||||
let sheet = app.session.active().and_then(|d| d.wb.active());
|
||||
let (header, footer) = sheet.map(|s| (s.print.header.clone(), s.print.footer.clone())).unwrap_or_default();
|
||||
json!({"header": header, "footer": footer})
|
||||
},
|
||||
),
|
||||
"pageSetup" => Dialog::form(
|
||||
"pageSetup",
|
||||
|
||||
@@ -630,3 +630,21 @@ fn rotated_wrapped_text_is_drawn_rotated_inside_its_cell() {
|
||||
assert!(clip.width() < 70.0, "clip spans one 6-character column, got {clip:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn header_footer_dialog_opens_on_the_saved_header_and_footer() {
|
||||
// #523: the dialog started from a fixed empty header and `&CPage &P of &N`, so OK replaced the sheet's text.
|
||||
let mut s = blank();
|
||||
s.execute("pageLayout.headerFooter", json!({"header": "&LLeft", "footer": "&CConfidential"})).unwrap();
|
||||
let mut h = harness(s);
|
||||
h.state_mut().open_dialog("headerFooter", json!({}));
|
||||
h.run_steps(2);
|
||||
let d = h.state_mut().dialog.as_mut().unwrap();
|
||||
assert_eq!(d.values["header"], json!("&LLeft"));
|
||||
assert_eq!(d.values["footer"], json!("&CConfidential"));
|
||||
d.values.insert("header".into(), json!("&CNew"));
|
||||
let vals = json!(d.values.clone());
|
||||
h.state_mut().run("pageLayout.headerFooter", vals).unwrap();
|
||||
let pr = &h.state().session.active().unwrap().wb.active().unwrap().print;
|
||||
assert_eq!((pr.header.as_str(), pr.footer.as_str()), ("&CNew", "&CConfidential"));
|
||||
}
|
||||
Reference in new issue
Block a user