Skip to content

Commit 76d5313

Browse files
author
root
committed
external link
1 parent 75dc37c commit 76d5313

3 files changed

Lines changed: 40 additions & 33 deletions

File tree

config.json.template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
"expression_unit": "My unit",
99
"externalSearch": false,
1010
"redirectSearch": "",
11-
"redirectSearchAttribute": ""
11+
"redirectSearchAttribute": "",
12+
"gene_dbxref": [
13+
{"url": "https://test_url_gene/#GENEID", "label": "my gene label"}
14+
],
15+
"protein_dbxref": [
16+
{"url": "https://test_url_protein/#PROTEINID", "label": "my protein label"}
17+
]
1218
},
1319
"externalSearchOptions": {
1420
"url": "http://0.0.0.0:80",

imports/ui/genetable/columns/AttributeValue.jsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,29 @@ function isArray(x) {
1313
}
1414

1515
function notDbxref({ value }) {
16+
if (typeof value === "object" && !Array.isArray(value)){
17+
return true
18+
}
19+
20+
let val = String(value)
1621
return !(
17-
DBXREF_REGEX.go.test(value)
18-
|| DBXREF_REGEX.interpro.test(value)
22+
DBXREF_REGEX.go.test(val)
23+
|| DBXREF_REGEX.interpro.test(val)
1924
);
2025
}
2126

2227
function SimpleAttribute({ value }) {
23-
return value;
28+
// Manage custom dbxref
29+
if (typeof value === "object" && !Array.isArray(value)){
30+
return(
31+
<><a href={value.url}>{value.label}</a></>
32+
)
33+
}
34+
return String(value);
2435
}
2536

2637
function dbxrefTracker({ value: dbxrefId }) {
38+
dbxrefId = String(dbxrefId)
2739
const sub = Meteor.subscribe('dbxref', { dbxrefId });
2840
const loading = !sub.ready();
2941
const dbxref = dbxrefCollection.findOne({ dbxrefId });
@@ -67,7 +79,7 @@ function AttributeValueArray({
6779
values.map((value) => (
6880
<li key={value} className="list-group-item py-0 px-0">
6981
<DetailedSingleAttribute
70-
value={String(value)}
82+
value={value}
7183
/>
7284
</li>
7385
))
@@ -97,16 +109,6 @@ function AttributeValueArray({
97109
}
98110

99111

100-
function AttributeValueObject({attrObject}) {
101-
return (
102-
<ul>
103-
<li key={attrObject.label} className="list-group-item py-0 px-0">
104-
<a href={attrObject.url}>{attrObject.label}</a>
105-
</li>
106-
</ul>
107-
);
108-
}
109-
110112
export default function AttributeValue({ attributeValue }) {
111113
const [showAll, setShowAll] = useState(false);
112114
function toggleShowAll() {
@@ -117,14 +119,6 @@ export default function AttributeValue({ attributeValue }) {
117119
return <p />;
118120
}
119121

120-
if (typeof attributeValue === 'object') {
121-
return (
122-
<AttributeValueObject
123-
attrObject={attributeValue}
124-
/>
125-
);
126-
}
127-
128122
const attrArray = isArray(attributeValue)
129123
? attributeValue
130124
: [attributeValue];

imports/ui/singleGenePage/GeneralInfo.jsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,37 @@ function GeneInfo({
230230
} = gene;
231231
const currentVersion = editHistory[0];
232232

233-
if( Meteor.settings.public.protein_dbxref && typeof Meteor.settings.public.protein_dbxref == "array" && Meteor.settings.public.protein_dbxref.length > 0){
233+
if( Meteor.settings.public.protein_dbxref && Array.isArray(Meteor.settings.public.protein_dbxref) && Meteor.settings.public.protein_dbxref.length > 0){
234+
if (! gene.attributes['Dbxref']){
235+
gene.attributes['Dbxref'] = []
236+
}
237+
234238
const protein_ids = gene.subfeatures
235239
.filter((sub) => sub.type === 'mRNA')
236240
.map((transcript) => transcript.protein_id)
237241
.sort();
238242

239-
for (dbxref in Meteor.settings.public.protein_dbxref ){
240-
if (! dbxref.url){continue}
241-
for (prot_id in protein_ids){
243+
Meteor.settings.public.protein_dbxref.forEach((dbxref) => {
244+
if (! dbxref.url){return}
245+
protein_ids.forEach((prot_id) => {
242246
let prot_url = dbxref.url.replace("#PROTEINID", prot_id)
243247
let prot_label = dbxref.label ? dbxref.label.replace("#PROTEINID", prot_id) : ""
244248
gene.attributes['Dbxref'].unshift({url: prot_url, label: prot_label})
245-
}
246-
}
249+
})
250+
})
247251
}
248252

249-
if( Meteor.settings.public.gene_dbxref && typeof Meteor.settings.public.gene_dbxref == "array" && Meteor.settings.public.gene_dbxref.length > 0){
250-
for (dbxref in Meteor.settings.public.gene_dbxref ){
251-
if (! dbxref.url){continue}
253+
if( Meteor.settings.public.gene_dbxref && Array.isArray(Meteor.settings.public.gene_dbxref) && Meteor.settings.public.gene_dbxref.length > 0){
254+
if (! gene.attributes['Dbxref']){
255+
gene.attributes['Dbxref'] = []
256+
}
252257

258+
Meteor.settings.public.gene_dbxref.forEach((dbxref) => {
259+
if (! dbxref.url){return}
253260
let gene_url = dbxref.url.replace("#GENEID", gene.ID)
254261
let gene_label = dbxref.label ? dbxref.label.replace("#GENEID", gene.ID) : ""
255262
gene.attributes['Dbxref'].unshift({url: gene_url, label: gene_label})
256-
}
263+
})
257264
}
258265

259266
const [reversions, setReversions] = useState(0);

0 commit comments

Comments
 (0)