Skip to content

Commit 3b8092e

Browse files
committed
Add a search box to the Summary Map
1 parent 50a3c2a commit 3b8092e

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

  • gocam_connections/templates/gocam_connections

gocam_connections/templates/gocam_connections/index.html

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@
4545
font-size: 105%;
4646
}
4747
#panel-buttons, #actions {
48-
padding: 0.2em 0.5em;
48+
padding: 0.4em 0.5em;
4949
background: #f8f8f8a0;
5050
}
51+
#search-input {
52+
font-size: 105%;
53+
}
5154
#actions {
5255
bottom: 1em;
5356
}
@@ -75,7 +78,7 @@
7578
flex: 0 0 auto;
7679
}
7780
#node-details {
78-
padding: 2em 0 0 0.2em;
81+
padding: 2.5em 0 0 0.2em;
7982
height: 100%;
8083
overflow: auto;
8184
background-color: #fbfbfb;
@@ -129,6 +132,7 @@
129132
<div id="cy-container">
130133
<div id="cy"></div>
131134
<div id="panel-buttons">
135+
<input id="search-input" placeholder="Search pathway titles ..."/>
132136
<button id="zoom-out" title="Zoom out" onclick="modelZoomOut()">
133137
<img width="16px" height="16px" src='data:image/svg+xml;charset=utf-8,<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="10mm" height="10mm" viewBox="0 0 12 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g transform="matrix(0.09090916,0,0,0.09090916,-2.2369372,-4.0168636)"> <rect style="fill:%23000000;stroke-width:0.264583" width="116.41666" height="31.75" x="31.75" y="95.25" ry="0.26052997" /> </g> </svg>'/>
134138
</button>
@@ -173,8 +177,10 @@
173177

174178
const modelSummaryById = {};
175179

180+
const modelNodes = modelConnections.nodes;
181+
176182
const elements = {
177-
nodes: modelConnections.nodes.map(node => {
183+
nodes: modelNodes.map(node => {
178184
const summ = { title: node.title };
179185
modelSummaryById[node.id] = summ;
180186
const idNoPrefix = node.id.split(':')[1];
@@ -326,7 +332,7 @@
326332
});
327333

328334
for (const currentModel of currentModels) {
329-
cy.$('#' + currentModel.id).style('border-width', 5);
335+
cy.$('#' + currentModel.id).style('border-width', 8);
330336
}
331337
};
332338

@@ -372,6 +378,28 @@
372378
contentDiv.innerHTML = newContent;
373379
}
374380

381+
const searchModels = (searchText) => {
382+
let matchCount = 0;
383+
modelNodes.map(node => {
384+
const title = node.title.toLowerCase();
385+
if (title.includes(searchText)) {
386+
addToCurrent([node.id]);
387+
matchCount++;
388+
}
389+
});
390+
return matchCount;
391+
};
392+
393+
const searchInput = document.getElementById('search-input');
394+
searchInput.addEventListener("input", (e) => {
395+
const searchText = e.target.value.trim().toLowerCase();
396+
clearCurrentModels();
397+
if (searchText.length > 1) {
398+
searchModels(searchText);
399+
}
400+
updateDetails();
401+
});
402+
375403
cy.on('box', 'node', function( e ){
376404
const node = e.target;
377405
const id = node.data().id;

0 commit comments

Comments
 (0)