From 012e5273b1efb511e4aa668b0343e9dde04b8924 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 26 Sep 2024 13:34:42 +0200 Subject: [PATCH] update --- src/routes/item/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/routes/item/mod.rs b/src/routes/item/mod.rs index 1f1d582..2bd97cb 100644 --- a/src/routes/item/mod.rs +++ b/src/routes/item/mod.rs @@ -146,8 +146,18 @@ pub async fn unique_field_route( .ok_or_else(variant_does_not_exist_error)?; match field { - "origin" => Ok(json!(variant.get_unique_origins().await)), - "destination" => Ok(json!(variant.get_unique_destinations().await)), + "origin" => Ok(json!(variant + .get_unique_origins() + .await + .into_iter() + .filter(|x| !x.starts_with("flow::")) + .collect::>())), + "destination" => Ok(json!(variant + .get_unique_destinations() + .await + .into_iter() + .filter(|x| !x.starts_with("flow::")) + .collect::>())), _ => Err(api_error("Unknown field")), } } @@ -196,9 +206,11 @@ pub async fn move_transaction_route(id: &str, form: Json) -> Fa .await .ok_or_else(|| api_error("No such transaction"))? .change() - .location(Some( - reference_of!(Location, new_loc).ok_or_else(|| api_error("No such location"))?, - )) + .location(if form.to.is_empty() { + None + } else { + Some(reference_of!(Location, new_loc).ok_or_else(|| api_error("No such location"))?) + }) .update() .await .unwrap();