create route file action

This commit is contained in:
vcoppe committed 2026-10-26 19:22:14 +01:00
1 parent 764d0b233a
commit 0f957fb1f2
60 files changed
+211 -85

No files matched your search

+11 -4
View File
@@ -10,11 +10,18 @@ use crate::ts::*;
// File commands
/// Creates a file and selects it. With `lng` and `lat`, it starts with a track and a segment that
/// hold that trackpoint (at `ele`, 0 by default).
/// Creates a file and selects it. With `route`, it starts with a route. With `lng` and `lat`, it
/// starts with a segment that holds that trackpoint (at `ele`, 0 by default): the one of its route
/// with `route`, of a track otherwise.
#[wasm_bindgen]
pub fn new_file(name: &str, lng: Option<f64>, lat: Option<f64>, ele: Option<f64>) -> Outcome {
run(|e| api::new_file(e, name, lng, lat, ele))
pub fn new_file(
name: &str,
lng: Option<f64>,
lat: Option<f64>,
ele: Option<f64>,
route: bool,
) -> Outcome {
run(|e| api::new_file(e, name, lng, lat, ele, route))
}
/// Loads files as a single command (one undo step). The files are in `data`, one after the
+17 -7
View File
@@ -84,7 +84,7 @@ fn uuid_bytes(ids: &[String]) -> Vec<u8> {
fn test_new_file_is_listed_and_selected() {
start();
assert!(run(crate::command::files::new_file(
"route", None, None, None
"route", None, None, None, false
)));
assert_eq!(last_error(), None);
@@ -198,7 +198,9 @@ fn test_the_reason_of_a_failure_can_be_read() {
assert!(!run(crate::command::tools::reverse()));
assert_eq!(last_error().as_deref(), Some("nothing to do"));
// the next call starts afresh
assert!(run(crate::command::files::new_file("a", None, None, None)));
assert!(run(crate::command::files::new_file(
"a", None, None, None, false
)));
assert_eq!(last_error(), None);
// invalid data
@@ -251,7 +253,9 @@ fn test_the_reason_of_a_failure_can_be_read() {
assert!(last_error().is_some());
// answers are not failures
assert!(run(crate::command::files::new_file("b", None, None, None)));
assert!(run(crate::command::files::new_file(
"b", None, None, None, false
)));
assert!(!crate::command::files::can_paste());
assert_eq!(last_error(), None);
}
@@ -260,7 +264,9 @@ fn test_the_reason_of_a_failure_can_be_read() {
fn test_undo_and_redo() {
started_with(&[]);
assert!(!can_undo() && !can_redo());
assert!(run(crate::command::files::new_file("a", None, None, None)));
assert!(run(crate::command::files::new_file(
"a", None, None, None, false
)));
assert!(can_undo() && !can_redo());
assert!(run(undo()));
assert!(order().is_empty());
@@ -386,7 +392,7 @@ fn test_move_elements_takes_js_objects() {
fn test_waypoints() {
started_with(&[]);
assert!(run(crate::command::files::new_file(
"file", None, None, None
"file", None, None, None, false
)));
let file = order().remove(0);
assert!(run(crate::command::waypoints::new_waypoint(
@@ -490,7 +496,9 @@ fn test_editing_tools_change_the_statistics() {
#[wasm_bindgen_test]
fn test_last_update_describes_the_last_call_only() {
started_with(&[]);
assert!(run(crate::command::files::new_file("a", None, None, None)));
assert!(run(crate::command::files::new_file(
"a", None, None, None, false
)));
let update = last_outcome();
assert_eq!(array(get(&update, "added")).length(), 1);
assert_eq!(get(&update, "orderChanged").as_bool(), Some(true));
@@ -502,7 +510,9 @@ fn test_last_update_describes_the_last_call_only() {
assert_eq!(get(&update, "orderChanged").as_bool(), Some(false));
assert_eq!(get(&update, "selectionChanged").as_bool(), Some(false));
assert!(run(crate::command::files::new_file("b", None, None, None)));
assert!(run(crate::command::files::new_file(
"b", None, None, None, false
)));
assert!(!run(crate::command::tools::crop(3, 1)));
let update = last_outcome();
assert_eq!(array(get(&update, "added")).length(), 0);