diff --git a/app/src/components/form/attribute_input.rs b/app/src/components/form/attribute_input.rs index 14279b2..e56fa9b 100644 --- a/app/src/components/form/attribute_input.rs +++ b/app/src/components/form/attribute_input.rs @@ -45,7 +45,7 @@ fn attribute_input(props: &AttributeInputProps) -> Html { #[derive(Properties, PartialEq)] pub struct SingleAttributeInputProps { - pub name: AttrValue, + pub name: String, pub attribute_type: AttributeType, #[prop_or(None)] pub value: Option, diff --git a/app/src/components/user_details.rs b/app/src/components/user_details.rs index 66e36cd..b8d3f61 100644 --- a/app/src/components/user_details.rs +++ b/app/src/components/user_details.rs @@ -4,8 +4,8 @@ use crate::{ remove_user_from_group::RemoveUserFromGroupComponent, router::{AppRoute, Link}, user_details_form::UserDetailsForm, - }, - infra::common_component::{CommonComponent, CommonComponentParts}, + }, infra::{schema::AttributeType, common_component::{CommonComponent, CommonComponentParts}}, + convert_attribute_type }; use anyhow::{bail, Error, Result}; use graphql_client::GraphQLQuery; @@ -25,6 +25,8 @@ pub type Group = get_user_details::GetUserDetailsUserGroups; pub type Attribute = get_user_details::GetUserDetailsUserAttributes; pub type AttributeSchema = get_user_details::GetUserDetailsUserAttributesSchema; +convert_attribute_type!(get_user_details::AttributeType); + pub struct UserDetails { common: CommonComponentParts, /// The user info. If none, the error is in `error`. If `error` is None, then we haven't diff --git a/app/src/components/user_details_form.rs b/app/src/components/user_details_form.rs index 31fe380..4635a4d 100644 --- a/app/src/components/user_details_form.rs +++ b/app/src/components/user_details_form.rs @@ -2,10 +2,9 @@ use std::str::FromStr; use crate::{ components::{ - form::{field::Field, static_value::StaticValue, submit::Submit}, + form::{attribute_input::SingleAttributeInput, field::Field, static_value::StaticValue, submit::Submit}, user_details::{AttributeSchema, User}, - }, - infra::common_component::{CommonComponent, CommonComponentParts}, + }, convert_attribute_type, infra::{common_component::{CommonComponent, CommonComponentParts}, schema::AttributeType} }; use anyhow::{anyhow, bail, Error, Ok, Result}; use gloo_console::log; @@ -20,6 +19,8 @@ use web_sys::{FileList, FormData, HtmlFormElement, HtmlInputElement, InputEvent} use yew::prelude::*; use yew_form_derive::Model; +use super::user_details::Attribute; + #[derive(Default)] struct JsFile { file: Option, @@ -286,6 +287,7 @@ impl Component for UserDetailsForm { + {self.user.attributes.iter().map(get_custom_attribute_input).collect::>()} Html { + if attribute.schema.is_list { + html!{

{"list attr"}

} + } else { + let value = if attribute.value.is_empty() { + None + } else { + Some(attribute.value[0].clone()) + }; + html!{::into(attribute.schema.attribute_type.clone())} value={value}/>} + } +} + impl UserDetailsForm { fn submit_user_update_form(&mut self, ctx: &Context) -> Result { if !self.form.validate() {