diff --git a/app/queries/get_user_details.graphql b/app/queries/get_user_details.graphql
index 8df1e2d..478d6f7 100644
--- a/app/queries/get_user_details.graphql
+++ b/app/queries/get_user_details.graphql
@@ -11,6 +11,10 @@ query GetUserDetails($id: String!) {
groups {
id
displayName
+ }
+ attributes {
+ name
+ value
}
}
schema {
diff --git a/app/src/components/form/attribute_input.rs b/app/src/components/form/attribute_input.rs
new file mode 100644
index 0000000..ed08999
--- /dev/null
+++ b/app/src/components/form/attribute_input.rs
@@ -0,0 +1,68 @@
+use yew::{function_component, html, virtual_dom::AttrValue, Callback, InputEvent, Properties, NodeRef};
+use crate::infra::schema::AttributeType;
+
+/*
+
+*/
+
+#[derive(Properties, PartialEq)]
+struct AttributeInputProps {
+ name: AttrValue,
+ attribute_type: AttributeType,
+ #[prop_or(None)]
+ value: Option,
+}
+
+#[function_component(AttributeInput)]
+fn attribute_input(props: &AttributeInputProps) -> Html {
+ let input_type = match props.attribute_type {
+ AttributeType::String => "text",
+ AttributeType::Integer => "number",
+ AttributeType::DateTime => "datetime-local",
+ AttributeType::Jpeg => "file",
+ };
+ let accept = match props.attribute_type {
+ AttributeType::Jpeg => Some("image/jpeg"),
+ _ => None,
+ };
+ html! {
+
+ }
+}
+
+#[derive(Properties, PartialEq)]
+pub struct SingleAttributeInputProps {
+ pub name: AttrValue,
+ pub attribute_type: AttributeType,
+ #[prop_or(None)]
+ pub value: Option,
+}
+
+#[function_component(SingleAttributeInput)]
+pub fn single_attribute_input(props: &SingleAttributeInputProps) -> Html {
+ html! {
+
+
+
+
+ }
+}
diff --git a/app/src/components/form/mod.rs b/app/src/components/form/mod.rs
index dc112e3..b1b006d 100644
--- a/app/src/components/form/mod.rs
+++ b/app/src/components/form/mod.rs
@@ -1,3 +1,4 @@
+pub mod attribute_input;
pub mod checkbox;
pub mod field;
pub mod select;
diff --git a/app/src/infra/schema.rs b/app/src/infra/schema.rs
index 3ef8db2..41fa793 100644
--- a/app/src/infra/schema.rs
+++ b/app/src/infra/schema.rs
@@ -1,7 +1,7 @@
use anyhow::Result;
use std::{fmt::Display, str::FromStr};
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AttributeType {
String,
Integer,
@@ -57,3 +57,32 @@ macro_rules! convert_attribute_type {
}
};
}
+
+#[derive(Clone, PartialEq, Eq)]
+pub struct Attribute {
+ pub name: String,
+ pub value: Vec,
+ pub attribute_type: AttributeType,
+ pub is_list: bool,
+ pub is_editable: bool,
+ pub is_hardcoded: bool,
+}
+
+// Macro to generate traits for converting between AttributeType and the
+// graphql generated equivalents.
+#[macro_export]
+macro_rules! combine_schema_and_values {
+ ($schema_list:ident, $value_list:ident, $output_list:ident) => {
+ let set_attributes = value_list.clone();
+ let mut attribute_schema = schema_list.clone();
+ attribute_schema.retain(|schema| !schema.is_hardcoded);
+ let $output_list = attribute_schema.into_iter().map(|schema| {
+ Attribute {
+ name: schema.name.clone(),
+ value: set_attributes.iter().find(|attribute_value| attribute_value.name == schema.name).unwrap().value.clone(),
+ attribute_type: AttributeType::from(schema.attribute_type),
+ is_list: schema.is_list,
+ }
+ }).collect();
+ };
+}
\ No newline at end of file