Skip to content

Commit abd7b96

Browse files
authored
Merge pull request #776 from MichaelWrana/tooltip-links
Modified tooltips to include PC Search Link
2 parents fedeee0 + b361970 commit abd7b96

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

src/client/common/cy/events/show-tooltip.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ const MetadataTip = require('../tooltips/');
44
const bindShowTooltip = (cy,showTooltipsOnEdges) => {
55
const selector= 'node'+(showTooltipsOnEdges ?',edge':'');
66
cy.on('showTooltip', selector, function (evt) {
7+
8+
79
const node = evt.target;
810

911
const data = node.data();
1012
const name = data.label;
1113
const cy = evt.cy;
1214

13-
//Create or get tooltip HTML object
14-
let html = node.scratch('_tooltip');
15-
if (!(html)) {
16-
html = new MetadataTip(name, data, node);
17-
node.scratch('_tooltip', html);
18-
}
19-
2015
//if the selection is a compartment, do not display a tooltip
21-
if(data.class !== "compartment")
16+
if(data.class !== "compartment"){
17+
//Create or get tooltip HTML object
18+
let html = node.scratch('_tooltip');
19+
if (!(html)) {
20+
html = new MetadataTip(name, data, node);
21+
node.scratch('_tooltip', html);
22+
}
2223
html.show(cy);
24+
}
2325
});
2426
};
2527

src/client/common/cy/tooltips/format-content.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ const defaultHandler = (pair) => {
7676
]);
7777
};
7878

79+
//Handle PC Search Related Fields
80+
const searchLinkHandler = (pair) => {
81+
let searchTerm = pair[1];
82+
return h('div.fake-paragraph',
83+
h('a.tooltip-search-link',{href:"/search?q=" + searchTerm,target:"_blank"},'Search Pathway Commons for "' + searchTerm + '"')
84+
);
85+
};
86+
7987
const metaDataKeyMap = new Map()
8088
.set('Standard Name', standardNameHandler)
8189
.set('Display Name', displayNameHandler)
@@ -84,7 +92,8 @@ const metaDataKeyMap = new Map()
8492
.set('Database IDs', databaseHandler)
8593
.set('Publications', publicationHandler)
8694
.set('List',listHandler)
87-
.set('Detailed Views',viwerListHandler);
95+
.set('Detailed Views',viwerListHandler)
96+
.set('Search Link',searchLinkHandler);
8897

8998
/**
9099
* parseMetadata(pair, trim)

src/client/common/cy/tooltips/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ class MetadataTip {
1414
constructor(name, data, cyElement) {
1515
this.name = name;
1616
this.data = data.parsedMetadata;
17+
//Add an extra piece of metadata to generate the search link
18+
//search text needs to be generated differently for 'processes'
19+
if(data.class === "process"){
20+
for(let i in this.data){
21+
if(this.data[i][0]==="Display Name")
22+
this.data.push(["Search Link",this.data[i][1]]);
23+
}
24+
}else{
25+
this.data.push(["Search Link",this.name]);
26+
}
1727
this.cyElement = cyElement;
1828
this.db = config.databases;
1929
this.viewStatus = {};
@@ -83,9 +93,7 @@ class MetadataTip {
8393

8494
if (!(this.data)) { this.data = []; }
8595
return h('div.tooltip-image', [
86-
h('div.tooltip-heading', [
87-
h('a.tooltip-heading-link',{href:"/search?&q="+this.name,target:"_blank"},this.name),
88-
]),
96+
h('div.tooltip-heading', this.name),
8997
h('div.tooltip-internal', h('div', (data).map(item => formatContent.parseMetadata(item, true, expandFunction, this.name)), this))
9098
]);
9199
}
@@ -112,9 +120,7 @@ class MetadataTip {
112120

113121
if (!(this.data)) { this.data = []; }
114122
return h('div.tooltip-image', [
115-
h('div.tooltip-heading', [
116-
h('a.tooltip-heading-link',{href:"/search?&q="+this.name,target:"_blank"},this.name),
117-
]),
123+
h('div.tooltip-heading', this.name),
118124
h('div.tooltip-internal', h('div', (data).map(item => formatContent.parseMetadata(item, !this.isExpanded(item[0]), getExpansionFunction(item), this.name), this)))
119125
]
120126
);

src/styles/features/view/toolTip.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@
133133
line-height: 1.5;
134134
}
135135

136-
.tooltip-heading-link{
136+
.tooltip-search-link{
137137
text-decoration: underline;
138+
font-weight:bold;
138139
display:inline;
139140
color: var(--link);
140141
}

0 commit comments

Comments
 (0)