Skip to content

Commit 25e4029

Browse files
committed
trim display ids on UI and enumeration
1 parent 4d7ad61 commit 25e4029

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/main/resources/static/js/knox.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ function longestListLength(listoflists) {
184184
return maxLength;
185185
}
186186

187+
//split by / for SBOL identity
188+
//this may not work well with other import formats
189+
export function splitElementID(elementID){
190+
let splitArr = elementID.split('/');
191+
return splitArr.length > 1 ? splitArr[splitArr.length-2] : elementID;
192+
}
193+
187194
export function getSBOLImage(role){
188195
const sbolpath = "./img/sbol/";
189196
switch (role) {
@@ -353,7 +360,8 @@ $('#enumerate-designs-tooltip').click(() => {
353360
para.appendChild(document.createTextNode("["));
354361
const length = list.length;
355362
list.map((element, i) => {
356-
para.appendChild(document.createTextNode(element.id));
363+
para.appendChild(document.createTextNode(splitElementID(element.id)));
364+
//append comma if there are more elements
357365
if (length !== i+1){
358366
para.appendChild(document.createTextNode(","));
359367
}

src/main/resources/static/js/target.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import {knoxClass, getSBOLImage} from "./knox.js";
2+
import {knoxClass, getSBOLImage, splitElementID} from "./knox.js";
33

44
// The target class observes an SVG element on the page, and
55
// provides methods for setting and clearing graph data. A variable
@@ -92,7 +92,16 @@ export default class Target{
9292
.attr("class", "sboltip")
9393
.attr("title", (d) => {
9494
if (d.hasOwnProperty("componentIDs")) {
95-
return d["componentIDs"].toString();
95+
let titleStr = "";
96+
const length = d["componentIDs"].length;
97+
for(let i=0; i<d["componentIDs"].length; i++){
98+
titleStr += splitElementID(d["componentIDs"][i]);
99+
if (length !== i+1){
100+
titleStr += ",";
101+
}
102+
}
103+
104+
return titleStr;
96105
}
97106
})
98107
.attr("xlink:href", (d) => {

0 commit comments

Comments
 (0)