Skip to content

Commit 8e7c2f9

Browse files
committed
-> collection display alternative
1 parent 4095dba commit 8e7c2f9

3 files changed

Lines changed: 57 additions & 8 deletions

File tree

static/css/bootstrap-idc.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,23 @@
6363

6464
.collection-header .collection-buttons {
6565
margin-bottom: 20px;
66+
}
67+
68+
.collex-divider {
69+
margin: 25px 20px 25px 20px;
70+
border-bottom: 1px solid black;
71+
}
72+
73+
.is-hidden {
74+
display: none !important;
75+
}
76+
77+
.show-more, .show-less {
78+
cursor: pointer;
79+
font-weight: bold;
80+
font-size: smaller;
81+
}
82+
83+
.show-more:hover, .show-less:hover {
84+
text-decoration: none;
6685
}

static/js/collection_details.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,20 @@ require(['jquery', 'datatables.net','jqueryui', 'bootstrap', 'base', 'tooltips']
2222
download_btn.attr('data-disabled-type','download-all-disabled');
2323
download_btn.addClass('is-disabled');
2424
}
25+
26+
$('#collection_details').on('click', '.show-more, .show-less', function(){
27+
const clicked = $(this);
28+
if(clicked.hasClass('show-more')) {
29+
let xtra_vals = $(clicked.attr('data-show-target')).find('.extra-values');
30+
xtra_vals.removeClass('is-hidden');
31+
$('.show-more-count').hide();
32+
}
33+
if(clicked.hasClass('show-less')) {
34+
let xtra_vals = $(clicked.attr('data-hide-target')).find('.extra-values');
35+
xtra_vals.addClass('is-hidden');
36+
$('.show-more-count').show();
37+
}
38+
clicked.siblings('.show-sib').removeClass('is-hidden');
39+
clicked.addClass('is-hidden');
40+
});
2541
});

templates/collections/collection_details.html

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h4>Details</h4>
8282
</p>
8383
{% endif %}
8484
<p>
85-
<b>Cancer Type: </b>{{ cancer_type }}
85+
<b>Cancer Type(s): </b>{{ cancer_type }}
8686
</p>
8787
{% if species != "" %}
8888
<p>
@@ -94,15 +94,29 @@ <h4>Details</h4>
9494
<b>Supporting Data: </b>{{ supporting_data }}
9595
</p>
9696
{% endif %}
97-
{% if collections != "" %}
98-
<p>
99-
<b>Collections: </b>
97+
{% if collections != "" %}
98+
<p class="collex-divider"></p>
99+
<p>
100+
<b>Collections</b>
101+
{% with col_count=collections|length %}
102+
{% if col_count > 5 %}
103+
<p>
104+
<a class="show-more show-sib" data-show-target=".ar-collex-set"><i class="fa-solid fa-plus-circle"></i> show more</a>
105+
<a class="show-less show-sib is-hidden" data-hide-target=".ar-collex-set"><i class="fa-solid fa-minus-circle"></i> show less</a>
106+
</p>
107+
{% endif %}
108+
<ul class="ar-collex-set">
100109
{% for col in collections %}
101-
<a href="{% url 'collection_details' col %}">{{ col }}</a>
110+
<li class="ar-collex{% if forloop.counter > 5 %} extra-values is-hidden{% endif %}"><a href="{% url 'collection_details' col.collection_id %}">{{ col.collection_name }}</a></li>
111+
{% if forloop.counter == 6 %}
112+
<li class="show-more-count">... {{ col_count|add:-5 }} more collections</li>
113+
{% endif %}
102114
{% endfor %}
103-
</p>
104-
{% endif %}
105-
<p style="margin-left: 20px; margin-right: 20px; margin-top: 25px; margin-bottom: 25px; border-bottom: 1px solid black;"></p>
115+
</ul>
116+
{% endwith %}
117+
</p>
118+
{% endif %}
119+
<p class="collex-divider"></p>
106120
{% for doi in dois %}
107121
<p><i class="fa fa-solid fa-globe"></i> <a href="https://doi.org/{{ doi }}" target="_blank" rel="nofollow noreferrer">{{ doi }}</a></p>
108122
{% endfor %}

0 commit comments

Comments
 (0)