Skip to content
Snippets Groups Projects
Commit 1afb02cf authored by Anthony's avatar Anthony
Browse files

WIP add ressource

parent c85b0324
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import EditIcon from '@material-ui/icons/Edit';
import ToggleButton from '@material-ui/lab/ToggleButton';
import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
import flatten from 'lodash/flatten';
import * as actions from 'mirador/dist/es/src/state/actions';
import AnnotationActionsContext from './AnnotationActionsContext';
import { searchManifestAndAddButton } from './utils';
......@@ -30,8 +31,9 @@ class CanvasListItem extends Component {
searchManifestAndAddButton(this.props.children[0][0].props.children[0].props.htmlString)
.then((values) => {
if (values) {
const valuesFlat = values.flat();
this.setState({
manifests: values.flat(),
manifests: valuesFlat,
});
}
});
......@@ -80,8 +82,9 @@ class CanvasListItem extends Component {
}
/** */
handleOpenOtherManifest() {
console.log("Opening TODO");
handleOpenOtherManifest(manifestId) {
console.log('Opening TODO');
actions.addResource(manifestId);
}
/** */
......@@ -147,16 +150,13 @@ class CanvasListItem extends Component {
>
{children}
</li>
{manifests &&
<div>
{manifests &&
manifests.map((o) => (
<button value={o} onClick={() => this.handleOpenOtherManifest(o)}> Ouvrir {o} </button>))
{manifests.length
&& manifests.map((o) => (
<button value={o} onClick={(e) => this.handleOpenOtherManifest(e.target.value)}> Ouvrir {o} </button>))
}
</div>
}
</div>
);
}
......
......@@ -28,8 +28,8 @@ export async function searchManifestAndAddButton(html) {
);
if (urls) {
let requestsArray = urls.map((url) => {
let request = new Request(url, {
const requestsArray = urls.map((url) => {
const request = new Request(url, {
method: 'GET',
});
......@@ -43,6 +43,8 @@ export async function searchManifestAndAddButton(html) {
return data.id;
}
return null;
}).then((data) => {
console.log('Failed to Fatch')
});
}));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment