diff --git a/frontend/src/pages/did.rs b/frontend/src/pages/did.rs index f9f54a3..9068202 100644 --- a/frontend/src/pages/did.rs +++ b/frontend/src/pages/did.rs @@ -12,7 +12,8 @@ pub struct Did { did_number: String, target_type: String, target: Option, - active: bool + active: bool, + trunk: String, } #[derive(Properties, PartialEq)] @@ -22,6 +23,7 @@ pub struct DidProps { pub target_type: String, pub target: String, pub active: bool, + pub trunk: String, pub on_changed: Callback<()> } @@ -33,6 +35,7 @@ pub fn DidComponent(props: &DidProps) -> Html { let target_type = use_state(||props.target_type.clone()); let target = use_state(||props.target.clone()); let active= use_state(||props.active); + let trunk= use_state(||props.trunk.clone()); let on_changed = props.on_changed.clone(); let dialog_ref: NodeRef = use_node_ref(); @@ -87,10 +90,21 @@ pub fn DidComponent(props: &DidProps) -> Html { .unwrap(); target_type.set(t.value()); changed.set(true); - gloo_console::log!(t.value()); } )}; + let handle_trunk_change = { + let trunk = trunk.clone(); + let changed = changed.clone(); + Callback::from(move |event: Event| { + let t = event + .target() + .and_then(|t| t.dyn_into::().ok()) + .unwrap(); + trunk.set(t.value()); + changed.set(true); + } + )}; let handle_save = { let changed = changed.clone(); let did_number = did_number.clone(); @@ -106,7 +120,8 @@ pub fn DidComponent(props: &DidProps) -> Html { did_number: (*did_number).clone(), target_type: (*target_type).clone(), target: Some((*target).clone()), - active: (*active).clone() + active: (*active).clone(), + trunk: (*trunk).clone(), }; let url = if id == 0 { API_BASE.to_string() @@ -187,6 +202,15 @@ pub fn DidComponent(props: &DidProps) -> Html { oninput={handle_target_input.clone()} /> + + + + Html { target_type={"NoService"} target={""} active=true + trunk="3229" on_changed={handle_change.clone()} /> @@ -282,6 +307,7 @@ pub fn DidListComponent() -> Html { {"DID number"} {"Target type"} {"Target"} + {"Trunk"} {"Active"} @@ -296,6 +322,7 @@ pub fn DidListComponent() -> Html { target_type={d.target_type.clone()} target={d.target.clone().unwrap_or_default()} active ={d.active} + trunk = {d.trunk.clone()} on_changed={handle_change.clone()} /> }