-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentry-item.html
210 lines (191 loc) · 8.42 KB
/
entry-item.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<link rel="import" href="nextprot-elements-shared-styles.html">
<link rel="import" href="entry-view-reference.html">
<link rel="import" href="entry-publication-direct-links.html">
<!--
`entry-item`
Protein entry item demo
@demo demo/entry-item-demo.html
-->
<dom-module id="entry-item">
<template>
<style include="nextprot-elements-shared-styles">
:host {
display: block;
border-bottom: var(--publication-item-border-bottom);
margin-bottom: var(--publication-item-padding-bottom);
padding-bottom: var(--publication-item-margin-bottom);
}
.gray {
color: #888;
}
.grayLink {
color: grey;
}
</style>
<template is="dom-if" if="[[data]]">
<!-- Entry view -->
<a href="/entry/[[data.accession]]"><span inner-h-t-m-l=[[_header]]></span></a>
<template is="dom-if" if="[[!summary]]">
<div class="small">
<template is="dom-if" if="[[desc]]">
<template is="dom-if" if="[[!_isSame(desc, shortDesc)]]">
<span>[[displayedDesc]]</span>
<span><a class="grayLink" on-click="_toggleDescription">[[[linkMessage]]]</a></span>
</template>
<template is="dom-if" if="[[_isSame(desc, shortDesc)]]">
<span>[[desc]]</span>
</template>
</template>
<template is="dom-if" if="[[!desc]]">
<span> No functional information for this protein. </span>
</template>
</div>
<div class="gray small">
Chromosomal location: <a href="entry/[[data.accession]]/exons">[[data.chr_loc]]</a>
Isoforms: <a href="entry/[[data.accession]]/sequence">[[data.isoform_num]]</a>
PTMs: <a href="entry/[[data.accession]]/sequence">[[data.ptm_num]]</a>
Sequence length: <a href="entry/[[data.accession]]/sequence">[[data.aa_length]]</a>
Variants: <a href="entry/[[data.accession]]/sequence">[[data.var_num]]</a>
<br>
Disease: <a class$="[[_computeATagClass(isDisease)]]" href="entry/[[data.accession]]/medical">[[_convertBooleanToYesOrNo(isDisease)]]</a>
Expression: <a class$="[[_computeATagClass(isExpression)]]" href="entry/[[data.accession]]/expression">[[_convertBooleanToYesOrNo(isExpression)]]</a>
Mutagenesis: <a class$="[[_computeATagClass(isMutagenesis)]]" href="entry/[[data.accession]]/sequence">[[_convertBooleanToYesOrNo(isMutagenesis)]]</a>
Proteomics: <a class$="[[_computeATagClass(isProteomics)]]" href="entry/[[data.accession]]/proteomics">[[_convertBooleanToYesOrNo(isProteomics)]]</a>
Structure: <a class$="[[_computeATagClass(isStructure)]]" href="entry/[[data.accession]]/structures">[[_convertBooleanToYesOrNo(isStructure)]]</a>
Protein existence: <a href="entry/[[data.accession]]/function">[[protExistence]]</a>
</div>
</template>
<!-- Cited For -->
<template is="dom-if" if="[[data.citedInViews]]">
<entry-view-reference refs="[[data.citedInViews]]"></entry-view-reference>
</template>
<!-- Direct links -->
<template is="dom-if" if="[[data.directLinks]]">
<entry-publication-direct-links dlinks="[[data.directLinks]]" selected-scope="[[_getSelectedScope()]]" ></entry-publication-direct-links>
</template>
</template>
</template>
<script>
Polymer({
is: 'entry-item',
properties: {
data: {
type: Object,
observer: "_handleData"
},
linkMessage: {
type: String,
value: "more"
},
desc: {
type: String
},
shortDesc: {
type: String
},
displayedDesc: {
type: String,
value: ""
},
isDisease: {
type: Boolean
},
isExpression: {
type: Boolean
},
isMutagenesis: {
type: Boolean
},
isProteomics: {
type: Boolean
},
isStructure: {
type: Boolean
},
protExistence: {
type: String
},
summary: {
type: Boolean,
value: false
},
_header: {
type: String
}
},
_handleData: function (data) {
if (data.function_desc) {
this.desc = data.function_desc[0];
this.shortDesc = this._shorten(this.desc);
this.displayedDesc = this.shortDesc;
}
else {
this.desc = this.shortDesc = this.displayedDesc = "No functional information for this protein.";
}
if (data.filters) {
this.isDisease = data.filters.indexOf("filterdisease") !== -1;
this.isExpression = data.filters.indexOf("filterexpressionprofile") !== -1;
this.isMutagenesis = data.filters.indexOf("filtermutagenesis") !== -1;
this.isProteomics = data.filters.indexOf("filterproteomics") !== -1;
this.isStructure = data.filters.indexOf("filterstructure") !== -1;
}
if(data.protein_existence) {
this.protExistence = data.protein_existence.split("_").join(" ");
}
if (!data.var_num) {
data.var_num = 0;
}
if (!data.ptm_num) {
data.ptm_num = 0;
}
this._header = this._createHeader(data);
this._setHostStyle();
},
_setHostStyle: function() {
// pam: tried to set host class but didn't succeed, but this works fine
this.style.borderLeftColor = (this.data.selected ? "#337ab7" : "");
this.style.borderLeftStyle = (this.data.selected ? "solid" : "");
this.style.borderLeftWidth = (this.data.selected ? "5px" : "");
this.style.paddingLeft = (this.data.selected ? "5px" : "");
},
_getSelectedScope: function() {
// pam: used to tell entry-publication-direct-links element to highlight the GeneRif direct links
if (this.data.selected) return "GeneRif";
return "";
},
_createHeader: function(data) {
var header = data.recommended_name;
if (data.ec_name) {
header += " ["+ data.ec_name + "]";
}
if (data.recommended_gene_names) {
header += " ("+ data.recommended_gene_names + ")";
}
header+= " [" + data.accession + "]";
return header;
},
_computeATagClass: function (boolean) {
return (boolean) ? '' : 'inactive';
},
_convertBooleanToYesOrNo: function (boolean) {
return (boolean) ? 'yes' : 'no';
},
_shorten: function (str) {
return (str.length > 300) ? str.substr(0, 300) : str;
},
_isSame: function (str1, str2) {
return str1 === str2;
},
_toggleDescription: function () {
if (this.linkMessage === "more") {
this.linkMessage = "less";
this.displayedDesc = this.desc;
}
else {
this.linkMessage = "more";
this.displayedDesc = this.shortDesc;
}
}
});
</script>
</dom-module>