mirror of
https://github.com/lldap/lldap.git
synced 2026-03-31 15:07:48 +01:00
test point
This commit is contained in:
@@ -45,7 +45,7 @@ fn attribute_input(props: &AttributeInputProps) -> Html {
|
|||||||
|
|
||||||
#[derive(Properties, PartialEq)]
|
#[derive(Properties, PartialEq)]
|
||||||
pub struct SingleAttributeInputProps {
|
pub struct SingleAttributeInputProps {
|
||||||
pub name: AttrValue,
|
pub name: String,
|
||||||
pub attribute_type: AttributeType,
|
pub attribute_type: AttributeType,
|
||||||
#[prop_or(None)]
|
#[prop_or(None)]
|
||||||
pub value: Option<String>,
|
pub value: Option<String>,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use crate::{
|
|||||||
remove_user_from_group::RemoveUserFromGroupComponent,
|
remove_user_from_group::RemoveUserFromGroupComponent,
|
||||||
router::{AppRoute, Link},
|
router::{AppRoute, Link},
|
||||||
user_details_form::UserDetailsForm,
|
user_details_form::UserDetailsForm,
|
||||||
},
|
}, infra::{schema::AttributeType, common_component::{CommonComponent, CommonComponentParts}},
|
||||||
infra::common_component::{CommonComponent, CommonComponentParts},
|
convert_attribute_type
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Error, Result};
|
use anyhow::{bail, Error, Result};
|
||||||
use graphql_client::GraphQLQuery;
|
use graphql_client::GraphQLQuery;
|
||||||
@@ -25,6 +25,8 @@ pub type Group = get_user_details::GetUserDetailsUserGroups;
|
|||||||
pub type Attribute = get_user_details::GetUserDetailsUserAttributes;
|
pub type Attribute = get_user_details::GetUserDetailsUserAttributes;
|
||||||
pub type AttributeSchema = get_user_details::GetUserDetailsUserAttributesSchema;
|
pub type AttributeSchema = get_user_details::GetUserDetailsUserAttributesSchema;
|
||||||
|
|
||||||
|
convert_attribute_type!(get_user_details::AttributeType);
|
||||||
|
|
||||||
pub struct UserDetails {
|
pub struct UserDetails {
|
||||||
common: CommonComponentParts<Self>,
|
common: CommonComponentParts<Self>,
|
||||||
/// The user info. If none, the error is in `error`. If `error` is None, then we haven't
|
/// 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::{
|
use crate::{
|
||||||
components::{
|
components::{
|
||||||
form::{field::Field, static_value::StaticValue, submit::Submit},
|
form::{attribute_input::SingleAttributeInput, field::Field, static_value::StaticValue, submit::Submit},
|
||||||
user_details::{AttributeSchema, User},
|
user_details::{AttributeSchema, User},
|
||||||
},
|
}, convert_attribute_type, infra::{common_component::{CommonComponent, CommonComponentParts}, schema::AttributeType}
|
||||||
infra::common_component::{CommonComponent, CommonComponentParts},
|
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail, Error, Ok, Result};
|
use anyhow::{anyhow, bail, Error, Ok, Result};
|
||||||
use gloo_console::log;
|
use gloo_console::log;
|
||||||
@@ -20,6 +19,8 @@ use web_sys::{FileList, FormData, HtmlFormElement, HtmlInputElement, InputEvent}
|
|||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yew_form_derive::Model;
|
use yew_form_derive::Model;
|
||||||
|
|
||||||
|
use super::user_details::Attribute;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct JsFile {
|
struct JsFile {
|
||||||
file: Option<File>,
|
file: Option<File>,
|
||||||
@@ -286,6 +287,7 @@ impl Component for UserDetailsForm {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{self.user.attributes.iter().map(get_custom_attribute_input).collect::<Vec<_>>()}
|
||||||
<Submit
|
<Submit
|
||||||
text="Save changes"
|
text="Save changes"
|
||||||
disabled={self.common.is_task_running()}
|
disabled={self.common.is_task_running()}
|
||||||
@@ -334,6 +336,19 @@ fn get_values_from_form_data(
|
|||||||
.collect()
|
.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 {
|
impl UserDetailsForm {
|
||||||
fn submit_user_update_form(&mut self, ctx: &Context<Self>) -> Result<bool> {
|
fn submit_user_update_form(&mut self, ctx: &Context<Self>) -> Result<bool> {
|
||||||
if !self.form.validate() {
|
if !self.form.validate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user