mirror of
https://github.com/lldap/lldap.git
synced 2024-11-25 09:06:03 +00:00
test point
This commit is contained in:
parent
66097f1880
commit
5b817980a9
3 changed files with 23 additions and 6 deletions
|
@ -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<String>,
|
||||
|
|
|
@ -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<Self>,
|
||||
/// The user info. If none, the error is in `error`. If `error` is None, then we haven't
|
||||
|
|
|
@ -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<File>,
|
||||
|
@ -286,6 +287,7 @@ impl Component for UserDetailsForm {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{self.user.attributes.iter().map(get_custom_attribute_input).collect::<Vec<_>>()}
|
||||
<Submit
|
||||
text="Save changes"
|
||||
disabled={self.common.is_task_running()}
|
||||
|
@ -334,6 +336,19 @@ fn get_values_from_form_data(
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn get_custom_attribute_input(attribute: &Attribute) -> Html {
|
||||
if attribute.schema.is_list {
|
||||
html!{<p>{"list attr"}</p>}
|
||||
} else {
|
||||
let value = if attribute.value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(attribute.value[0].clone())
|
||||
};
|
||||
html!{<SingleAttributeInput name={attribute.name.clone()} attribute_type={Into::<AttributeType>::into(attribute.schema.attribute_type.clone())} value={value}/>}
|
||||
}
|
||||
}
|
||||
|
||||
impl UserDetailsForm {
|
||||
fn submit_user_update_form(&mut self, ctx: &Context<Self>) -> Result<bool> {
|
||||
if !self.form.validate() {
|
||||
|
|
Loading…
Reference in a new issue