Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
SemWeb
libview
Commits
b5ce151270e2
Commit
501f4098
authored
Jun 27, 2018
by
Laurent Wouters
Browse files
Rendering entities
parent
1711c150bdf3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/components/App.re
View file @
b5ce1512
...
...
@@ -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
)
=>
...
...
src/components/Rendering.re
View file @
b5ce1512
...
...
@@ -74,4 +74,35 @@ let renderCollection =
|>
ReasonReact
.
array
)
</
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment