app: Ouverture de la ressource au clic
This commit is contained in:
parent
9734bb401f
commit
27fd1ce027
|
@ -27,15 +27,24 @@ const DiseaseGraph = ({terms, setTerms, results}) =>
|
||||||
*/
|
*/
|
||||||
const render = id =>
|
const render = id =>
|
||||||
{
|
{
|
||||||
|
const term = nodes[id];
|
||||||
const isTerm = terms.some(({id: termId}) => termId === id);
|
const isTerm = terms.some(({id: termId}) => termId === id);
|
||||||
const isDisease = nodes[id].types.includes(termTypes.disease);
|
const isDisease = nodes[id].types.includes(termTypes.disease);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={[
|
<span
|
||||||
|
className={[
|
||||||
'SearchResults_result',
|
'SearchResults_result',
|
||||||
isTerm ? 'SearchResults_result-term' : '',
|
isTerm ? 'SearchResults_result-term' : '',
|
||||||
isDisease ? 'SearchResults_result-disease' : '',
|
isDisease ? 'SearchResults_result-disease' : '',
|
||||||
].join(' ')}>{nodes[id].name}</span>
|
].join(' ')}
|
||||||
|
title={
|
||||||
|
`Cliquez pour plus d’informations sur « ${term.name} »\n`
|
||||||
|
+ '(Ctrl-clic pour l’ajouter à la requête)'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{nodes[id].name}
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,17 +52,23 @@ const DiseaseGraph = ({terms, setTerms, results}) =>
|
||||||
* Gère le clic sur un nœud du graphe.
|
* Gère le clic sur un nœud du graphe.
|
||||||
*
|
*
|
||||||
* @param id Identifiant du nœud cliqué.
|
* @param id Identifiant du nœud cliqué.
|
||||||
|
* @param ev Événement DOM décrivant le clic.
|
||||||
*/
|
*/
|
||||||
const handleNodeClick = id =>
|
const handleNodeClick = (id, ev) =>
|
||||||
{
|
{
|
||||||
const result = results.find(({id: termId}) => termId === id);
|
const result = results.find(({id: termId}) => termId === id);
|
||||||
const termIndex = terms.findIndex(({id: termId}) => termId === id);
|
const termIndex = terms.findIndex(({id: termId}) => termId === id);
|
||||||
|
|
||||||
if (result !== undefined)
|
if (result !== undefined)
|
||||||
{
|
{
|
||||||
if (termIndex >= 0)
|
if (!ev.ctrlKey)
|
||||||
{
|
{
|
||||||
// Retrait d’un terme déjà dans la requête
|
// Clic normal : Ouverture de la ressource
|
||||||
|
window.open(result.url, '_blank');
|
||||||
|
}
|
||||||
|
else if (termIndex >= 0)
|
||||||
|
{
|
||||||
|
// Ctrl-clic : Retrait d’un terme déjà dans la requête
|
||||||
setTerms([
|
setTerms([
|
||||||
...terms.slice(0, termIndex),
|
...terms.slice(0, termIndex),
|
||||||
...terms.slice(termIndex + 1)
|
...terms.slice(termIndex + 1)
|
||||||
|
@ -61,7 +76,7 @@ const DiseaseGraph = ({terms, setTerms, results}) =>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ajout d’un nouveau terme dans la requête
|
// Ctrl-clic : Ajout d’un nouveau terme dans la requête
|
||||||
setTerms(terms.concat([result]));
|
setTerms(terms.concat([result]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,13 +268,13 @@ const Graph = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const mouseUp = () =>
|
const mouseUp = ev =>
|
||||||
{
|
{
|
||||||
if (dragElement !== null)
|
if (dragElement !== null)
|
||||||
{
|
{
|
||||||
if (dragClick)
|
if (dragClick)
|
||||||
{
|
{
|
||||||
onNodeClick(dragNode);
|
onNodeClick(dragNode, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
dragNode = -1;
|
dragNode = -1;
|
||||||
|
|
Loading…
Reference in New Issue