Skip to content

Commit

Permalink
Update seq select icon background ...
Browse files Browse the repository at this point in the history
color, update getCurrentCanvas
  • Loading branch information
MImranAsghar committed Nov 19, 2020
1 parent c97d5da commit f92b5dd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
8 changes: 6 additions & 2 deletions __tests__/fixtures/version-3/001.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"type": "Canvas",
"label": "Whole Page",
"label": {
"en": [
"Whole Page"
]
},
"width": 5776,
"height": 9125,
"items": [
Expand Down Expand Up @@ -360,4 +364,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions src/containers/WindowSideBarCanvasPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ const styles = theme => ({
},
select: {
'& .MuiSelect-icon': {
backgroundColor: 'white',
backgroundColor: theme.palette.background.paper,
},
'&:focus': {
backgroundColor: theme.palette.background.paper,
},
},
selectEmpty: {
'& .MuiSelect-icon': {
backgroundColor: 'white',
backgroundColor: theme.palette.background.paper,
},
backgroundColor: theme.palette.background.paper,
},
Expand Down
15 changes: 7 additions & 8 deletions src/state/selectors/canvases.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,23 @@ export const getCurrentCanvas = createSelector(
getWindow,
],
(sequence, window) => {
let canvas;
if (!sequence || !window) return undefined;

if (!window.canvasId && (typeof sequence.getCanvasByIndex == 'function')) {
canvas = sequence.getCanvasByIndex(0);
} else if (!window.canvasId) {
return sequence.getCanvasByIndex(0);
}

if (!window.canvasId) {
const { items } = sequence;
const [firstCanvas] = items;
canvas = firstCanvas;
return firstCanvas;
}

if (typeof sequence.getCanvasById == 'function') {
canvas = sequence.getCanvasById(window.canvasId);
} else if (sequence.items) {
canvas = sequence.items.filter(c => c.id === window.canvasId) || [];
return sequence.getCanvasById(window.canvasId);
}

return canvas;
return sequence.items.filter(c => c.id === window.canvasId) || [];
},
);

Expand Down
11 changes: 10 additions & 1 deletion src/state/selectors/sequences.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ export const getSequences = createSelector(
if (v2TopRanges.length === 0 && topRangesOrRoot.length === 1) {
v3RangeSequences = topRangesOrRoot[0].getRanges().filter(r => r.getBehavior() === 'sequence');

/** Add manifesto canvases (items) to the ranges if 'items' property of ranges
* is empty
*/
if (v3RangeSequences.length > 0 && manifest.items && manifest.items.length > 0
&& manifest.items[0].items && manifest.items[0].items.length > 0) {
/** Use manifesto canvases provided in manifest 'items' property to populate
* range 'items'/canvases
*/
const canvases = manifest.items[0].items;

v3RangeSequences.map((sequence) => {
Expand All @@ -36,7 +42,10 @@ export const getSequences = createSelector(
}
}

// v3 sequence (not range sequence): assign id if not there
/** v3 sequence (not range sequence): assign id if not there
* Case: only sequence (not range) for v3 manifest is created by manifesto from all
* the items/canvases to display as default; this has id listed as undefined
*/
const manifestSequences = manifest.getSequences();
if (v3RangeSequences && manifestSequences && manifestSequences.length > 0
&& !manifestSequences[0].id) {
Expand Down

0 comments on commit f92b5dd

Please sign in to comment.