Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
487c3622
Commit
487c3622
authored
Feb 13, 2019
by
Mathias Maaß
Browse files
Options
Downloads
Patches
Plain Diff
add selector for canvas label and id
parent
c7115932
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
__tests__/src/selectors/index.test.js
+27
-0
27 additions, 0 deletions
__tests__/src/selectors/index.test.js
src/state/selectors/index.js
+12
-0
12 additions, 0 deletions
src/state/selectors/index.js
with
39 additions
and
0 deletions
__tests__/src/selectors/index.test.js
+
27
−
0
View file @
487c3622
...
...
@@ -13,6 +13,7 @@ import {
getThumbnailNavigationPosition
,
getManifestTitle
,
getWindowViewType
,
getIdAndLabelOfCanvases
,
}
from
'
../../../src/state/selectors
'
;
...
...
@@ -254,3 +255,29 @@ describe('getDestructuredMetadata', () => {
expect
(
received
).
toEqual
([]);
});
});
describe
(
'
getIdAndLabelOfCanvases
'
,
()
=>
{
it
(
'
should return id and label of each canvas in manifest
'
,
()
=>
{
const
canvases
=
manifesto
.
create
(
manifestFixture019
)
.
getSequences
()[
0
]
.
getCanvases
();
const
received
=
getIdAndLabelOfCanvases
(
canvases
);
const
expected
=
[
{
id
:
'
http://iiif.io/api/presentation/2.0/example/fixtures/canvas/24/c1.json
'
,
label
:
'
Test 19 Canvas: 1
'
,
},
{
id
:
'
https://purl.stanford.edu/fr426cg9537/iiif/canvas/fr426cg9537_1
'
,
label
:
'
Image 1
'
,
},
];
expect
(
received
).
toEqual
(
expected
);
});
it
(
'
should return empty array if canvas if empty
'
,
()
=>
{
const
received
=
getIdAndLabelOfCanvases
([]);
expect
(
received
).
toEqual
([]);
});
});
This diff is collapsed.
Click to expand it.
src/state/selectors/index.js
+
12
−
0
View file @
487c3622
...
...
@@ -34,6 +34,18 @@ export function getManifestCanvases(manifest) {
return
manifest
.
manifestation
.
getSequences
()[
0
].
getCanvases
();
}
/**
* Return ids and labels of canvases
* @ param {Array} canvases
* @return {Array} - [ {id: 'id', label: 'label' }, ... ]
*/
export
function
getIdAndLabelOfCanvases
(
canvases
)
{
return
canvases
.
map
(
canvas
=>
({
id
:
canvas
.
__jsonld
[
'
@id
'
],
// eslint-disable-line no-underscore-dangle
label
:
canvas
.
__jsonld
.
label
,
// eslint-disable-line no-underscore-dangle
}));
}
/**
* Return the current canvas selected in a window
* @param {object} state
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment