diff --git a/crates/context_aware_config/src/api/dimension/handlers.rs b/crates/context_aware_config/src/api/dimension/handlers.rs index eac92d92..1792bdaa 100644 --- a/crates/context_aware_config/src/api/dimension/handlers.rs +++ b/crates/context_aware_config/src/api/dimension/handlers.rs @@ -33,7 +33,7 @@ async fn create( ) -> superposition::Result { let DbConnection(mut conn) = db_conn; - if req.priority == 0 { + if req.priority <= 0 { return Err(bad_argument!("Priority should be greater than 0")); } @@ -66,7 +66,7 @@ async fn create( let new_dimension = Dimension { dimension: create_req.dimension, - priority: i32::from(create_req.priority), + priority: create_req.priority, schema: schema_value, created_by: user.get_email(), created_at: Utc::now(), diff --git a/crates/context_aware_config/src/api/dimension/types.rs b/crates/context_aware_config/src/api/dimension/types.rs index 1c81a69e..cb7b7eea 100644 --- a/crates/context_aware_config/src/api/dimension/types.rs +++ b/crates/context_aware_config/src/api/dimension/types.rs @@ -4,7 +4,7 @@ use serde_json::Value; #[derive(Debug, Deserialize)] pub struct CreateReq { pub dimension: String, - pub priority: u16, + pub priority: i32, pub schema: Value, #[serde(default, deserialize_with = "deserialize_option")] pub function_name: Option, diff --git a/crates/frontend/src/components/dimension_form.rs b/crates/frontend/src/components/dimension_form.rs index 8e62a870..6133142e 100644 --- a/crates/frontend/src/components/dimension_form.rs +++ b/crates/frontend/src/components/dimension_form.rs @@ -15,7 +15,7 @@ use web_sys::MouseEvent; #[component] pub fn dimension_form( #[prop(default = false)] edit: bool, - #[prop(default = 0)] priority: u16, + #[prop(default = 0)] priority: u32, #[prop(default = String::new())] dimension_name: String, #[prop(default = String::new())] dimension_type: String, #[prop(default = Value::Null)] dimension_schema: Value, @@ -191,14 +191,26 @@ where = 48 && char_code <= 57) + { + ev.prevent_default(); + } + } on:change=move |ev| { - logging::log!("{:?}", event_target_value(& ev).parse::< u16 > ()); - match event_target_value(&ev).parse::() { + logging::log!("{:?}", event_target_value(&ev).parse::()); + match event_target_value(&ev).parse::() { Ok(i_prio) => set_priority.set(i_prio), - Err(e) => logging::log!("{e}"), + Err(e) => { + set_priority.set(0); + logging::log!("{e}"); + } }; } /> diff --git a/crates/frontend/src/components/dimension_form/types.rs b/crates/frontend/src/components/dimension_form/types.rs index e4e60e1a..9630a79b 100644 --- a/crates/frontend/src/components/dimension_form/types.rs +++ b/crates/frontend/src/components/dimension_form/types.rs @@ -4,7 +4,7 @@ use serde_json::Value; #[derive(Serialize, Clone)] pub struct DimensionCreateReq { pub dimension: String, - pub priority: u16, + pub priority: u32, pub schema: Value, pub function_name: Option, } diff --git a/crates/frontend/src/pages/dimensions.rs b/crates/frontend/src/pages/dimensions.rs index 0ca6e5a2..62e61691 100644 --- a/crates/frontend/src/pages/dimensions.rs +++ b/crates/frontend/src/pages/dimensions.rs @@ -13,7 +13,7 @@ use crate::api::fetch_dimensions; #[derive(Clone, Debug, Default)] pub struct RowData { pub dimension: String, - pub priority: u16, + pub priority: u32, pub schema: Value, pub function_name: Option, } @@ -38,7 +38,7 @@ pub fn Dimensions() -> impl IntoView { logging::log!("Dimension row: {:?}", row); let row_dimension = row["dimension"].to_string().replace('"', ""); let row_priority_str = row["priority"].to_string().replace('"', ""); - let row_priority = row_priority_str.parse::().unwrap_or(0_u16); + let row_priority = row_priority_str.parse::().unwrap_or(0_u32); let schema = row["schema"].clone().to_string(); let schema = serde_json::from_str::(&schema).unwrap_or(Value::Null);