From 5c8e71b0c371797f5ec950004ad60cc49192d691 Mon Sep 17 00:00:00 2001 From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr> Date: Wed, 25 Jan 2023 12:58:54 +0100 Subject: [PATCH] WIP not working --- src/CanvasListItem.js | 16 ++++++++++++---- src/plugins/canvasAnnotationsPlugin.js | 7 ++++++- src/plugins/miradorAnnotationPlugin.js | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/CanvasListItem.js b/src/CanvasListItem.js index e2e5bd1..085b778 100644 --- a/src/CanvasListItem.js +++ b/src/CanvasListItem.js @@ -84,8 +84,11 @@ class CanvasListItem extends Component { /** */ handleOpenOtherManifest(manifestId) { console.log('Opening TODO'); - let result = actions.addResource(manifestId); - console.log(result); + const { + addResource, + } = this.context; + + addResource('https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json'); } /** */ @@ -154,8 +157,12 @@ class CanvasListItem extends Component { <div> {manifests.length > 0 && manifests.map((o) => ( - <button value={o} onClick={(e) => this.handleOpenOtherManifest(e.target.value)}> Ouvrir {o} </button>)) - } + <button value={o} onClick={(e) => this.handleOpenOtherManifest(e.target.value)}> + {' '} + Ouvrir + {o} + </button> + ))} </div> </div> @@ -169,6 +176,7 @@ CanvasListItem.propTypes = { PropTypes.func, PropTypes.node, ]).isRequired, + }; CanvasListItem.contextType = AnnotationActionsContext; diff --git a/src/plugins/canvasAnnotationsPlugin.js b/src/plugins/canvasAnnotationsPlugin.js index 9102709..ba4724d 100644 --- a/src/plugins/canvasAnnotationsPlugin.js +++ b/src/plugins/canvasAnnotationsPlugin.js @@ -30,7 +30,7 @@ class CanvasAnnotationsWrapper extends Component { render() { const { addCompanionWindow, annotationsOnCanvases, canvases, config, receiveAnnotation, - switchToSingleCanvasView, TargetComponent, targetProps, windowViewType, + switchToSingleCanvasView, TargetComponent, targetProps, windowViewType, addResource } = this.props; const { singleCanvasDialogOpen } = this.state; const props = { @@ -41,6 +41,7 @@ class CanvasAnnotationsWrapper extends Component { <AnnotationActionsContext.Provider value={{ addCompanionWindow, + addResource, annotationsOnCanvases, canvases, config, @@ -68,6 +69,7 @@ class CanvasAnnotationsWrapper extends Component { CanvasAnnotationsWrapper.propTypes = { addCompanionWindow: PropTypes.func.isRequired, + addResource: PropTypes.func.isRequired, annotationsOnCanvases: PropTypes.object, // eslint-disable-line react/forbid-prop-types canvases: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }), @@ -116,6 +118,9 @@ const mapDispatchToProps = (dispatch, props) => ({ addCompanionWindow: (content, additionalProps) => dispatch( actions.addCompanionWindow(props.targetProps.windowId, { content, ...additionalProps }), ), + addResource: (manifestId) => dispatch( + actions.addResource(props.manifestId), + ), receiveAnnotation: (targetId, id, annotation) => dispatch( actions.receiveAnnotation(targetId, id, annotation), ), diff --git a/src/plugins/miradorAnnotationPlugin.js b/src/plugins/miradorAnnotationPlugin.js index e3a06fc..499129e 100644 --- a/src/plugins/miradorAnnotationPlugin.js +++ b/src/plugins/miradorAnnotationPlugin.js @@ -109,6 +109,7 @@ class MiradorAnnotation extends Component { MiradorAnnotation.propTypes = { addCompanionWindow: PropTypes.func.isRequired, + addResource: PropTypes.func.isRequired, canvases: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }), ).isRequired, @@ -130,7 +131,7 @@ MiradorAnnotation.propTypes = { /** */ const mapDispatchToProps = (dispatch, props) => ({ addCompanionWindow: (content, additionalProps) => dispatch( - actions.addCompanionWindow(props.targetProps.windowId, { content, ...additionalProps }), + actions.addCompanionWindow(props.targetProps.windowId, {content, ...additionalProps}), ), switchToSingleCanvasView: () => dispatch( actions.setWindowViewType(props.targetProps.windowId, 'single'), -- GitLab