From 03ea5206f7bce5048dbe554b184653dd4cf5ccd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Fri, 27 Nov 2026 21:30:18 -0500 Subject: [PATCH 1/3] fix(engine): say which presentation map pages lose their map --- crates/engine/src/cmd/navigate.rs | 3 +- crates/engine/src/cmd/presentation.rs | 67 ++++++ crates/engine/src/cmd/workspace.rs | 6 +- crates/engine/src/tests.rs | 3 + crates/engine/src/tests/layout_removed_map.rs | 191 ++++++++++++++++++ docs/user-guide/layouts.md | 3 + 6 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 crates/engine/src/tests/layout_removed_map.rs diff --git a/crates/engine/src/cmd/navigate.rs b/crates/engine/src/cmd/navigate.rs index c49a500af4..2b659c7dda 100644 --- a/crates/engine/src/cmd/navigate.rs +++ b/crates/engine/src/cmd/navigate.rs @@ -215,7 +215,7 @@ pub fn commands() -> Vec { } let i = required_map_at(s,p)?; let named = super::layout::maps_layouts_name(&s.project); - s.project.maps.remove(i); + let gone = s.project.maps.remove(i).name; // Deleting another map keeps the one in view (a map tab's close button). let active = s.project.active_map; if i < active { @@ -226,6 +226,7 @@ pub fn commands() -> Vec { s.table_layer = None; } super::layout::say_map_texts(s, &named); + super::presentation::say_pages_without_their_map(s, super::presentation::PagesOf::Map(&gone)); Ok(Value::Null) }).transition(unmodelled_transition).inputs(required_map_inputs).roles(&[]).effects(crate::policy::Effects::NONE) .params(r#"{"name": string}"#), diff --git a/crates/engine/src/cmd/presentation.rs b/crates/engine/src/cmd/presentation.rs index 083fa2a31c..ea1b7a9e4a 100644 --- a/crates/engine/src/cmd/presentation.rs +++ b/crates/engine/src/cmd/presentation.rs @@ -68,6 +68,7 @@ pub fn commands() -> Vec { if let Some(cut) = cut { s.notify(cut, false); } + say_pages_without_their_map(s, PagesOf::Presentation(i)); // Pages often share a title's figure: each warning once, with its count of pages. let mut said: Vec<(String, usize)> = Vec::new(); for k in 0..s.project.presentations[i].pages.len() { @@ -631,6 +632,72 @@ fn page_map<'a>(input: &'a impl super::InputSource, name: &str) -> &'a rustgis_m let s = &context; s.project.maps.iter().find(|m| m.name.eq_ignore_ascii_case(name)).unwrap_or_else(|| s.map()) } + +/// Most map names [`say_pages_without_their_map`] lists: an imported file may name one a page. +const MISSING_MAPS_NAMED: usize = 3; + +/// The map pages [`say_pages_without_their_map`] looks at. +pub(crate) enum PagesOf<'a> { + /// Those naming this map, in every presentation: it has just gone. + Map(&'a str), + /// Those of the presentation at this index, whatever they name: it has just come in. + Presentation(usize), +} + +/// Says, once, how many of the map pages `which` name a map the project doesn't have, which +/// [`page_map`] draws over the active map (#3047). The pages keep the name. +pub(crate) fn say_pages_without_their_map(s: &mut Session, which: PagesOf<'_>) { + use crate::notice_text::NoticeText; + + let (mut pages, mut presentations) = (0usize, Vec::new()); + let (mut named, mut more) = (Vec::<&str>::new(), false); + for (i, pres) in s.project.presentations.iter().enumerate() { + for page in &pres.pages { + let PageKind::Map { map, .. } = &page.kind else { continue }; + let looked_at = match which { + PagesOf::Map(gone) => map.eq_ignore_ascii_case(gone), + PagesOf::Presentation(k) => i == k, + }; + if !looked_at || s.project.maps.iter().any(|m| m.name.eq_ignore_ascii_case(map)) { + continue; + } + pages += 1; + if presentations.last() != Some(&&pres.name) { + presentations.push(&pres.name); + } + if !named.iter().any(|n| n.eq_ignore_ascii_case(map)) { + if named.len() < MISSING_MAPS_NAMED { + named.push(map); + } else { + more = true; + } + } + } + } + let whose = match presentations.as_slice() { + [] => return, + [name] => NoticeText::format("Presentation '{name}'", [("name", (*name).clone().into())]), + several => NoticeText::format("{count} presentations", [("count", several.len().to_string().into())]), + }; + let key = match (pages, named.len()) { + (1, _) => { + "{whose}: {count} map page shows {names}, which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + } + (_, 1) => { + "{whose}: {count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + } + _ => { + "{whose}: {count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until maps of those names come back" + } + }; + let mut names = named.iter().map(|n| format!("'{n}'")).collect::>().join(", "); + if more { + names.push_str(", …"); + } + let notice = NoticeText::format(key, [("whose", whose), ("count", pages.to_string().into()), ("names", names.into())]); + s.notify_text(notice, false); +} + /// Binds the map whose current view initializes the page. fn map_page_inputs(input: &super::InputContext<'_>, p: &Value) -> Result { let map = map_page_source(input, p)?; diff --git a/crates/engine/src/cmd/workspace.rs b/crates/engine/src/cmd/workspace.rs index 6dfbdcf6c9..8bdc0e4885 100644 --- a/crates/engine/src/cmd/workspace.rs +++ b/crates/engine/src/cmd/workspace.rs @@ -297,10 +297,11 @@ pub fn commands() -> Vec { m.offline_area_id = None; } } + let mut gone = None; if let Some(i) = kept && s.project.maps.len() > 1 { - s.project.maps.remove(i); + gone = Some(s.project.maps.remove(i).name); // The active map stays the same map; if it was the removed one, a neighbour. let a = s.project.active_map; s.project.active_map = if a > i { a - 1 } else { a.min(s.project.maps.len().saturating_sub(1)) }; @@ -317,6 +318,9 @@ pub fn commands() -> Vec { s.notify(format!("The offline area's map was the only one, so it was kept as '{kept}'"), false); } super::layout::say_map_texts(s, &named); + if let Some(gone) = gone { + super::presentation::say_pages_without_their_map(s, super::presentation::PagesOf::Map(&gone)); + } Ok(Value::Null) }).roles(&[]).effects(crate::policy::Effects::NONE) .params(r#"{"name": offline area}"#), diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index acc58a9f9a..d666e78b34 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -110,6 +110,9 @@ mod layout_title; #[path = "tests/layout_removed_layer.rs"] mod layout_removed_layer; +#[path = "tests/layout_removed_map.rs"] +mod layout_removed_map; + #[path = "tests/layout_edge.rs"] mod layout_edge; diff --git a/crates/engine/src/tests/layout_removed_map.rs b/crates/engine/src/tests/layout_removed_map.rs new file mode 100644 index 0000000000..c80266d5c5 --- /dev/null +++ b/crates/engine/src/tests/layout_removed_map.rs @@ -0,0 +1,191 @@ +//! A presentation map page whose map the project doesn't have is drawn over the active map: +//! deleting the map, or importing such a presentation, says which pages (#3047). All keep the name. + +use super::*; +use rustgis_map::presentation::{Page, PageKind, Presentation}; + +/// The notices `command` gives about map pages that show a map the project doesn't have. +fn missing(s: &mut Session, command: &str, params: Value) -> Vec { + let mark = s.notice_mark(); + s.run(command, ¶ms).unwrap(); + s.notices_since(mark).iter().map(|n| n.text.clone()).filter(|t| t.contains("which the project doesn't have")).collect() +} + +/// The sample world with a map `Other`, the world in view, and a presentation `Tour`. +fn with_tour() -> Session { + let mut s = world(); + let home = s.map().name.clone(); + s.run("map.new", &json!({"name": "Other"})).unwrap(); + s.run("map.activate", &json!({"name": home})).unwrap(); + s.run("presentation.new", &json!({"name": "Tour"})).unwrap(); + s +} + +fn page(s: &mut Session, map: &str) { + s.run("presentation.mapPage", &json!({"map": map, "title": "Sites"})).unwrap(); +} + +/// The map the frame of page `k` of the first presentation is drawn over. +fn drawn_over(s: &Session, k: usize) -> String { + let pres = &s.project.presentations[0]; + let layout = crate::cmd::presentation::page_layout(s, pres, &pres.pages[k]); + layout + .elements + .iter() + .find_map(|e| match &e.kind { + rustgis_map::layout::ElementKind::MapFrame { map, .. } => Some(map.clone()), + _ => None, + }) + .unwrap() +} + +/// A presentation file with one map page for each of `maps`. +fn file_showing(maps: &[&str]) -> Value { + let pages = maps + .iter() + .map(|map| Page { + title: "Sites".into(), + kind: PageKind::Map { map: (*map).into(), center: rustgis_geom::Coord::new(0.0, 0.0), width_m: 1000.0 }, + notes: String::new(), + seconds: 5.0, + }) + .collect(); + let pres = Presentation { name: "Filed".into(), pages, ..Presentation::default() }; + json!({"text": serde_json::to_string(&pres).unwrap()}) +} + +#[test] +fn deleting_a_map_a_page_shows_says_so_and_the_page_keeps_the_name() { + let mut s = with_tour(); + page(&mut s, "Other"); + assert_eq!( + missing(&mut s, "map.remove", json!({"name": "Other"})), + [ + "Presentation 'Tour': 1 map page shows 'Other', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + ] + ); + assert_eq!(drawn_over(&s, 1), s.map().name); + // Exporting draws it as before, with nothing more said. + assert_eq!(missing(&mut s, "presentation.export", json!({"format": "html"})), Vec::::new()); + // A map of that name brings the page back to it. + s.run("map.new", &json!({"name": "Other"})).unwrap(); + assert_eq!(drawn_over(&s, 1), "Other"); +} + +#[test] +fn undoing_the_deletion_draws_the_page_over_its_map_again() { + let mut s = with_tour(); + page(&mut s, "Other"); + s.run("map.remove", &json!({"name": "Other"})).unwrap(); + assert_eq!(missing(&mut s, "edit.undo", Value::Null), Vec::::new()); + assert_eq!(drawn_over(&s, 1), "Other"); +} + +#[test] +fn pages_of_two_presentations_are_said_once() { + let mut s = with_tour(); + page(&mut s, "Other"); + s.run("presentation.new", &json!({"name": "Second"})).unwrap(); + page(&mut s, "Other"); + assert_eq!( + missing(&mut s, "map.remove", json!({"name": "Other"})), + [ + "2 presentations: 2 map pages show 'Other', which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + ] + ); +} + +#[test] +fn a_page_that_spells_its_map_in_another_case_is_counted() { + let mut s = with_tour(); + page(&mut s, "Other"); + let PageKind::Map { map, .. } = &mut s.project.presentations[0].pages[1].kind else { panic!("a map page") }; + *map = "oTHER".into(); + assert_eq!( + missing(&mut s, "map.remove", json!({"name": "Other"})), + [ + "Presentation 'Tour': 1 map page shows 'oTHER', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + ] + ); +} + +#[test] +fn deleting_a_map_no_page_shows_says_nothing() { + let mut s = with_tour(); + s.run("map.new", &json!({"name": "Spare"})).unwrap(); + page(&mut s, "Other"); + // A page already without its map isn't said again when another map goes. + let PageKind::Map { map, .. } = &mut s.project.presentations[0].pages[1].kind else { panic!("a map page") }; + *map = "Gone".into(); + assert_eq!(missing(&mut s, "map.remove", json!({"name": "Spare"})), Vec::::new()); +} + +#[test] +fn deleting_a_map_with_no_presentation_says_nothing() { + let mut s = world(); + s.run("map.new", &json!({"name": "Other"})).unwrap(); + assert_eq!(missing(&mut s, "map.remove", json!({"name": "Other"})), Vec::::new()); +} + +/// Adds the offline area `Crew`, made from the map `source`. +fn offline_area(s: &mut Session, source: &str) { + let extent = rustgis_geom::Extent::new(0.0, 0.0, 1.0, 1.0); + let area = json!({"name": "Crew", "map": source, "extent": extent, "created": 0.0, "data": s.project.maps[0]}); + s.project.offline_areas.push(serde_json::from_value(area).unwrap()); +} + +#[test] +fn removing_an_offline_area_says_the_pages_that_showed_its_map() { + let mut s = with_tour(); + let home = s.map().name.clone(); + s.run("map.new", &json!({"name": "Crew (offline)"})).unwrap(); + offline_area(&mut s, &home); + page(&mut s, "Crew (offline)"); + assert_eq!( + missing(&mut s, "offline.remove", json!({"name": "Crew"})), + [ + "Presentation 'Tour': 1 map page shows 'Crew (offline)', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + ] + ); +} + +#[test] +fn removing_an_offline_area_whose_map_is_kept_says_nothing() { + let mut s = world(); + s.run("map.rename", &json!({"name": "Crew (offline)"})).unwrap(); + s.run("presentation.new", &json!({"name": "Tour"})).unwrap(); + page(&mut s, "Crew (offline)"); + offline_area(&mut s, "Source"); + assert_eq!(missing(&mut s, "offline.remove", json!({"name": "Crew"})), Vec::::new()); + assert_eq!(drawn_over(&s, 1), "Crew (kept)"); +} + +#[test] +fn importing_a_presentation_says_the_pages_whose_map_is_missing() { + let mut s = world(); + let home = s.map().name.clone(); + assert_eq!( + missing(&mut s, "presentation.import", file_showing(&["Missing", &home, "missing"])), + [ + "Presentation 'Filed': 2 map pages show 'Missing', which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + ] + ); +} + +#[test] +fn importing_a_presentation_whose_maps_are_all_there_says_nothing() { + let mut s = world(); + let home = s.map().name.clone(); + assert_eq!(missing(&mut s, "presentation.import", file_showing(&[&home])), Vec::::new()); +} + +#[test] +fn many_missing_maps_are_named_up_to_three() { + let mut s = world(); + assert_eq!( + missing(&mut s, "presentation.import", file_showing(&["A", "B", "A", "C", "D", "E"])), + [ + "Presentation 'Filed': 6 map pages show 'A', 'B', 'C', …, which the project doesn't have, so they are drawn over the active map until maps of those names come back" + ] + ); +} diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index 27bfeea6d2..ff9050f3b0 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -963,6 +963,9 @@ previews, edits and plays it. coloured page, an **Image** page a picture with a caption, and a **Video** page a video file or URL with an optional poster picture. - Each page has a title, speaker notes and a duration (for **Play**), and can move up or down. +- A **Map** page follows its map by name. While the project has no map of that name, the page is + drawn over the active map; deleting the map, or importing a presentation that names it, says + how many pages. - **Publish › Output › Presentation › Export Presentation** writes an HTML slideshow (arrow keys, `N` for notes, `P` to play; videos play in place), a PDF (kept as vectors as a layout's is), or the first page as PNG. From cddb30225aac70ef33e1e9daca1105bd4d41c229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Fri, 27 Nov 2026 21:46:27 -0500 Subject: [PATCH 2/3] fix(engine): count presentations by position, test the export without a file --- crates/engine/src/cmd/presentation.rs | 6 +++--- crates/engine/src/tests/layout_removed_map.rs | 4 +++- docs/user-guide/layouts.md | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/presentation.rs b/crates/engine/src/cmd/presentation.rs index ea1b7a9e4a..77637af90b 100644 --- a/crates/engine/src/cmd/presentation.rs +++ b/crates/engine/src/cmd/presentation.rs @@ -662,8 +662,8 @@ pub(crate) fn say_pages_without_their_map(s: &mut Session, which: PagesOf<'_>) { continue; } pages += 1; - if presentations.last() != Some(&&pres.name) { - presentations.push(&pres.name); + if presentations.last().is_none_or(|&(last, _)| last != i) { + presentations.push((i, &pres.name)); } if !named.iter().any(|n| n.eq_ignore_ascii_case(map)) { if named.len() < MISSING_MAPS_NAMED { @@ -676,7 +676,7 @@ pub(crate) fn say_pages_without_their_map(s: &mut Session, which: PagesOf<'_>) { } let whose = match presentations.as_slice() { [] => return, - [name] => NoticeText::format("Presentation '{name}'", [("name", (*name).clone().into())]), + [(_, name)] => NoticeText::format("Presentation '{name}'", [("name", (*name).clone().into())]), several => NoticeText::format("{count} presentations", [("count", several.len().to_string().into())]), }; let key = match (pages, named.len()) { diff --git a/crates/engine/src/tests/layout_removed_map.rs b/crates/engine/src/tests/layout_removed_map.rs index c80266d5c5..0fe5c5e64e 100644 --- a/crates/engine/src/tests/layout_removed_map.rs +++ b/crates/engine/src/tests/layout_removed_map.rs @@ -66,7 +66,9 @@ fn deleting_a_map_a_page_shows_says_so_and_the_page_keeps_the_name() { ); assert_eq!(drawn_over(&s, 1), s.map().name); // Exporting draws it as before, with nothing more said. - assert_eq!(missing(&mut s, "presentation.export", json!({"format": "html"})), Vec::::new()); + let mark = s.notice_mark(); + crate::cmd::presentation::export_bytes(&mut s, 0, "html", 120.0).unwrap(); + assert!(s.notices_since(mark).iter().all(|n| !n.text.contains("which the project doesn't have"))); // A map of that name brings the page back to it. s.run("map.new", &json!({"name": "Other"})).unwrap(); assert_eq!(drawn_over(&s, 1), "Other"); diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index ff9050f3b0..8b38d2a471 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -964,8 +964,8 @@ previews, edits and plays it. URL with an optional poster picture. - Each page has a title, speaker notes and a duration (for **Play**), and can move up or down. - A **Map** page follows its map by name. While the project has no map of that name, the page is - drawn over the active map; deleting the map, or importing a presentation that names it, says - how many pages. + drawn over the active map; deleting the map (or the offline area that goes with it), or + importing a presentation that names it, says how many pages. - **Publish › Output › Presentation › Export Presentation** writes an HTML slideshow (arrow keys, `N` for notes, `P` to play; videos play in place), a PDF (kept as vectors as a layout's is), or the first page as PNG. From 2febdee1a09ac94063afe6893a87ca8d99cf6721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 05:22:07 -0500 Subject: [PATCH 3/3] fix(engine): say which presentation pages lose their map --- crates/engine/src/cmd/presentation.rs | 71 +++++++++++++------ crates/engine/src/tests/layout_removed_map.rs | 31 ++++++-- docs/user-guide/layouts.md | 2 +- 3 files changed, 77 insertions(+), 27 deletions(-) diff --git a/crates/engine/src/cmd/presentation.rs b/crates/engine/src/cmd/presentation.rs index 77637af90b..64efe8dce8 100644 --- a/crates/engine/src/cmd/presentation.rs +++ b/crates/engine/src/cmd/presentation.rs @@ -633,8 +633,11 @@ fn page_map<'a>(input: &'a impl super::InputSource, name: &str) -> &'a rustgis_m s.project.maps.iter().find(|m| m.name.eq_ignore_ascii_case(name)).unwrap_or_else(|| s.map()) } -/// Most map names [`say_pages_without_their_map`] lists: an imported file may name one a page. +/// Most map names, presentations and page numbers [`say_pages_without_their_map`] lists: an +/// imported file may hold hundreds of pages, each naming another map. const MISSING_MAPS_NAMED: usize = 3; +const PRESENTATIONS_LISTED: usize = 3; +const PAGES_LISTED: usize = 5; /// The map pages [`say_pages_without_their_map`] looks at. pub(crate) enum PagesOf<'a> { @@ -644,57 +647,85 @@ pub(crate) enum PagesOf<'a> { Presentation(usize), } -/// Says, once, how many of the map pages `which` name a map the project doesn't have, which -/// [`page_map`] draws over the active map (#3047). The pages keep the name. +/// Says, once, which of the map pages `which` name a map the project doesn't have, which +/// [`page_map`] draws over the active map (#3047). Pages are numbered from 1, as the Presentation +/// pane shows them. The pages keep the name. pub(crate) fn say_pages_without_their_map(s: &mut Session, which: PagesOf<'_>) { use crate::notice_text::NoticeText; - let (mut pages, mut presentations) = (0usize, Vec::new()); - let (mut named, mut more) = (Vec::<&str>::new(), false); + /// A presentation listed: where it is, its name, its first pages and how many it has. + struct Place<'a> { + at: usize, + name: &'a str, + numbers: Vec, + pages: usize, + } + + let (mut pages, mut places) = (0usize, Vec::>::new()); + let (mut named, mut more_maps, mut more_places) = (Vec::<&str>::new(), false, false); for (i, pres) in s.project.presentations.iter().enumerate() { - for page in &pres.pages { + for (k, page) in pres.pages.iter().enumerate() { let PageKind::Map { map, .. } = &page.kind else { continue }; let looked_at = match which { PagesOf::Map(gone) => map.eq_ignore_ascii_case(gone), - PagesOf::Presentation(k) => i == k, + PagesOf::Presentation(own) => i == own, }; if !looked_at || s.project.maps.iter().any(|m| m.name.eq_ignore_ascii_case(map)) { continue; } pages += 1; - if presentations.last().is_none_or(|&(last, _)| last != i) { - presentations.push((i, &pres.name)); - } if !named.iter().any(|n| n.eq_ignore_ascii_case(map)) { if named.len() < MISSING_MAPS_NAMED { named.push(map); } else { - more = true; + more_maps = true; + } + } + if places.last().is_none_or(|place| place.at != i) { + if places.len() == PRESENTATIONS_LISTED { + more_places = true; + continue; + } + places.push(Place { at: i, name: &pres.name, numbers: Vec::new(), pages: 0 }); + } + if let Some(place) = places.last_mut() { + place.pages += 1; + if place.numbers.len() < PAGES_LISTED { + place.numbers.push((k + 1).to_string()); } } } } - let whose = match presentations.as_slice() { - [] => return, - [(_, name)] => NoticeText::format("Presentation '{name}'", [("name", (*name).clone().into())]), - several => NoticeText::format("{count} presentations", [("count", several.len().to_string().into())]), + let listed = places.into_iter().map(|place| { + let key = if place.pages == 1 { "presentation '{name}', page {numbers}" } else { "presentation '{name}', pages {numbers}" }; + let mut numbers = place.numbers.join(", "); + if place.pages > PAGES_LISTED { + numbers.push_str(", …"); + } + NoticeText::format(key, [("name", place.name.to_string().into()), ("numbers", numbers.into())]) + }); + let Some(mut places) = listed.reduce(|first, next| NoticeText::format("{first}; {next}", [("first", first), ("next", next)])) else { + return; }; + if more_places { + places = NoticeText::format("{first}; {next}", [("first", places), ("next", "…".to_string().into())]); + } let key = match (pages, named.len()) { (1, _) => { - "{whose}: {count} map page shows {names}, which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + "{count} map page shows {names}, which the project doesn't have, so it is drawn over the active map until a map of that name comes back: {places}" } (_, 1) => { - "{whose}: {count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + "{count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until a map of that name comes back: {places}" } _ => { - "{whose}: {count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until maps of those names come back" + "{count} map pages show {names}, which the project doesn't have, so they are drawn over the active map until maps of those names come back: {places}" } }; let mut names = named.iter().map(|n| format!("'{n}'")).collect::>().join(", "); - if more { + if more_maps { names.push_str(", …"); } - let notice = NoticeText::format(key, [("whose", whose), ("count", pages.to_string().into()), ("names", names.into())]); + let notice = NoticeText::format(key, [("count", pages.to_string().into()), ("names", names.into()), ("places", places)]); s.notify_text(notice, false); } diff --git a/crates/engine/src/tests/layout_removed_map.rs b/crates/engine/src/tests/layout_removed_map.rs index 0fe5c5e64e..b28b114d12 100644 --- a/crates/engine/src/tests/layout_removed_map.rs +++ b/crates/engine/src/tests/layout_removed_map.rs @@ -61,7 +61,7 @@ fn deleting_a_map_a_page_shows_says_so_and_the_page_keeps_the_name() { assert_eq!( missing(&mut s, "map.remove", json!({"name": "Other"})), [ - "Presentation 'Tour': 1 map page shows 'Other', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + "1 map page shows 'Other', which the project doesn't have, so it is drawn over the active map until a map of that name comes back: presentation 'Tour', page 2" ] ); assert_eq!(drawn_over(&s, 1), s.map().name); @@ -92,7 +92,7 @@ fn pages_of_two_presentations_are_said_once() { assert_eq!( missing(&mut s, "map.remove", json!({"name": "Other"})), [ - "2 presentations: 2 map pages show 'Other', which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + "2 map pages show 'Other', which the project doesn't have, so they are drawn over the active map until a map of that name comes back: presentation 'Tour', page 2; presentation 'Second', page 2" ] ); } @@ -106,7 +106,7 @@ fn a_page_that_spells_its_map_in_another_case_is_counted() { assert_eq!( missing(&mut s, "map.remove", json!({"name": "Other"})), [ - "Presentation 'Tour': 1 map page shows 'oTHER', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + "1 map page shows 'oTHER', which the project doesn't have, so it is drawn over the active map until a map of that name comes back: presentation 'Tour', page 2" ] ); } @@ -146,7 +146,7 @@ fn removing_an_offline_area_says_the_pages_that_showed_its_map() { assert_eq!( missing(&mut s, "offline.remove", json!({"name": "Crew"})), [ - "Presentation 'Tour': 1 map page shows 'Crew (offline)', which the project doesn't have, so it is drawn over the active map until a map of that name comes back" + "1 map page shows 'Crew (offline)', which the project doesn't have, so it is drawn over the active map until a map of that name comes back: presentation 'Tour', page 2" ] ); } @@ -169,7 +169,7 @@ fn importing_a_presentation_says_the_pages_whose_map_is_missing() { assert_eq!( missing(&mut s, "presentation.import", file_showing(&["Missing", &home, "missing"])), [ - "Presentation 'Filed': 2 map pages show 'Missing', which the project doesn't have, so they are drawn over the active map until a map of that name comes back" + "2 map pages show 'Missing', which the project doesn't have, so they are drawn over the active map until a map of that name comes back: presentation 'Filed', pages 1, 3" ] ); } @@ -187,7 +187,26 @@ fn many_missing_maps_are_named_up_to_three() { assert_eq!( missing(&mut s, "presentation.import", file_showing(&["A", "B", "A", "C", "D", "E"])), [ - "Presentation 'Filed': 6 map pages show 'A', 'B', 'C', …, which the project doesn't have, so they are drawn over the active map until maps of those names come back" + "6 map pages show 'A', 'B', 'C', …, which the project doesn't have, so they are drawn over the active map until maps of those names come back: presentation 'Filed', pages 1, 2, 3, 4, 5, …" + ] + ); +} + +#[test] +fn pages_past_three_presentations_are_counted_and_not_listed() { + let mut s = with_tour(); + // Five pages in the first presentation, all listed; one in each of three more. + for _ in 0..5 { + page(&mut s, "Other"); + } + for name in ["Second", "Third", "Fourth"] { + s.run("presentation.new", &json!({"name": name})).unwrap(); + page(&mut s, "Other"); + } + assert_eq!( + missing(&mut s, "map.remove", json!({"name": "Other"})), + [ + "8 map pages show 'Other', which the project doesn't have, so they are drawn over the active map until a map of that name comes back: presentation 'Tour', pages 2, 3, 4, 5, 6; presentation 'Second', page 2; presentation 'Third', page 2; …" ] ); } diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index 8b38d2a471..f90d460b0c 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -965,7 +965,7 @@ previews, edits and plays it. - Each page has a title, speaker notes and a duration (for **Play**), and can move up or down. - A **Map** page follows its map by name. While the project has no map of that name, the page is drawn over the active map; deleting the map (or the offline area that goes with it), or - importing a presentation that names it, says how many pages. + importing a presentation that names it, says which pages. - **Publish › Output › Presentation › Export Presentation** writes an HTML slideshow (arrow keys, `N` for notes, `P` to play; videos play in place), a PDF (kept as vectors as a layout's is), or the first page as PNG.