Commit 501f4098 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Rendering entities

parent 1711c150bdf3
......@@ -127,8 +127,13 @@ let renderLoadedWithData =
| _ => []
};
Rendering.renderCollection(self, goto, arrayType, values);
| Hypermedia.ObjectType(_) =>
<div> (ReasonReact.string("TODO: Display the object")) </div>
| Hypermedia.ObjectType(objectType) =>
let obj =
switch (data) {
| Hypermedia.ValueObject(x) => x
| _ => {properties: []}
};
Rendering.renderEntity(self, goto, objectType, obj);
| Hypermedia.RootType(rootSchema) =>
Rendering.renderRoot(self, goto, rootSchema)
| Hypermedia.PrimitiveType(ptype) =>
......
......@@ -75,3 +75,34 @@ let renderCollection =
)
</div>;
};
let renderEntity =
(
self: ReasonReact.self(_, _, _),
goto,
schema: Hypermedia.schemaObjectType,
data: Hypermedia.entity,
) => {
let schema_title =
switch (schema.title) {
| Some(x) => x
| None => ""
};
<div>
<h1> (ReasonReact.string(schema_title)) </h1>
<div>
(
data.properties
|> List.map((property: Hypermedia.entityProperty) => {
let value = Hypermedia.as_string(property.value);
<div>
<div> (ReasonReact.string(property.name)) </div>
<div> (ReasonReact.string(value)) </div>
</div>
})
|> Array.of_list
|> ReasonReact.array
)
</div>
</div>;
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment