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
Culture
culture-views
Commits
102e6485f0c3
Commit
ac233dd6
authored
Sep 24, 2020
by
Fabien Amarger
Browse files
feat: [BienCulturelClass] Filter by the graph source
parent
82fad1c046aa
Pipeline
#15220
failed with stages
in 3 minutes and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bienCulturelClass/bienCulturelClass.tsx
View file @
102e6485
...
...
@@ -61,6 +61,10 @@ const BienCulturelClass: React.FC<BienCulturelClassProps> = (props) => {
function
toggleSelectedType
(
type
:
string
):
void
{
selectedType
===
type
?
setSelectedType
(
null
)
:
setSelectedType
(
type
);
}
const
[
selectedGraph
,
setSelectedGraph
]
=
React
.
useState
<
string
|
null
>
(
null
);
function
toggleSelectedGraph
(
graph
:
string
):
void
{
selectedGraph
===
graph
?
setSelectedGraph
(
null
)
:
setSelectedGraph
(
graph
);
}
React
.
useEffect
(()
=>
{
Promise
.
all
(
...
...
@@ -122,15 +126,44 @@ const BienCulturelClass: React.FC<BienCulturelClassProps> = (props) => {
center
=
L
.
latLngBounds
(
bienCulturelLocations
.
map
(({
location
})
=>
[
location
.
lat
,
location
.
lng
])).
getCenter
();
}
const
allGraphSource
:
string
[]
=
[];
if
(
bienCulturelInstances
!==
null
)
{
for
(
const
instance
of
bienCulturelInstances
)
{
if
(
instance
.
graph
!==
undefined
&&
!
allGraphSource
.
includes
(
instance
.
graph
))
{
allGraphSource
.
push
(
instance
.
graph
);
}
}
}
return
(
<>
<
h1
>
{
label
}
</
h1
>
{
types
!==
null
?
(
types
.
map
((
type
)
=>
(
<
span
onClick
=
{
()
=>
toggleSelectedType
(
type
)
}
style
=
{
{
cursor
:
'
pointer
'
}
}
>
<
URIBadge
key
=
{
type
}
uri
=
{
type
}
dataFetcher
=
{
dataFetcher
}
selected
=
{
selectedType
===
type
}
/>
</
span
>
))
<
div
>
<
h3
>
Filtrer par type alternatif :
</
h3
>
{
types
.
map
((
type
)
=>
(
<
span
onClick
=
{
()
=>
toggleSelectedType
(
type
)
}
style
=
{
{
cursor
:
'
pointer
'
}
}
>
<
URIBadge
key
=
{
type
}
uri
=
{
type
}
dataFetcher
=
{
dataFetcher
}
selected
=
{
selectedType
===
type
}
/>
</
span
>
))
}
</
div
>
)
:
(
<></>
)
}
{
allGraphSource
.
length
>
0
?
(
<
div
>
<
h3
>
Filtrer par source :
</
h3
>
{
allGraphSource
.
map
((
currentGraph
)
=>
(
<
span
onClick
=
{
()
=>
toggleSelectedGraph
(
currentGraph
)
}
style
=
{
{
cursor
:
'
pointer
'
}
}
>
<
URIBadge
key
=
{
currentGraph
}
uri
=
{
currentGraph
}
selected
=
{
selectedGraph
===
currentGraph
}
/>
</
span
>
))
}
</
div
>
)
:
(
<></>
)
}
...
...
@@ -144,6 +177,7 @@ const BienCulturelClass: React.FC<BienCulturelClassProps> = (props) => {
.
filter
(
({
bienCulturel
})
=>
selectedType
===
null
||
bienCulturel
.
typeUris
.
includes
(
selectedType
)
)
.
filter
(({
bienCulturel
})
=>
selectedGraph
===
null
||
bienCulturel
.
graph
===
selectedGraph
)
.
map
((
bienCulturelLocation
)
=>
(
<
Marker
key
=
{
bienCulturelLocation
.
bienCulturel
.
locationUri
}
...
...
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