Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky headers for assessment grid #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 86 additions & 1 deletion FAIRshakeHub/static/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,89 @@ h1 {
transform: rotate(360deg);
}
}
/* END https://loading.io/css/ */
/* END https://loading.io/css/ */

.table-sticky-header {
background-color: white;
position: relative;
z-index: 0;
}

.table-sticky-header tr, .table-sticky-header td {
z-index: 0;
}

.table-sticky-header > thead {
background-color: white;
border: 1px solid #ddd;
position: sticky;
top: 0;
z-index: 3;
}
.table-sticky-header > thead > tr > th {
border-top: 1px solid black;
z-index: 4;
}
.table-sticky-header > thead > tr > th.tbody-thead {
z-index: 4;
}
.table-sticky-header th.tbody-thead {
background-color: white;
border: 1px solid #ddd;
position: sticky;
left: 0;
z-index: 2;
padding: 0 !important;
margin: 0;
display: table-cell;
}
.table-sticky-header th.tbody-thead > div {
display: flex;
justify-items: stretch;
align-items: stretch;
}
.table-sticky-header th.tbody-thead > div > div {
flex: 1 1 0;
min-width: 0;
word-wrap: break-word;
border: 1px solid #ddd;
padding: 0;
margin: 0;
}

/*
.table {
position: relative;
display: table-column;
flex-direction: column;
border: 1px solid black;
}
.table-thead {
flex: 0 0 auto;
display: flex;
}
.table-tr {
display: flex;
flex-direction: row;
}
.table-thead {
position: sticky;
top: 0;
}
.table-tbody > .table-tr > .table-th {
position: sticky;
left: 0;
}
.table-td, .table-th {}
.table-tbody {}

table.table-sticky-th thead tr th {
position: -webkit-sticky;
position: sticky;
top: 0;
}
table.table-sticky-th tbody tr th {
position: -webkit-sticky;
position: sticky;
left: 0;
} */
138 changes: 71 additions & 67 deletions FAIRshakeHub/templates/fairshake/generic/assessments.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,75 @@
<div class="col-sm-12">
<hr />
<h2 class="text-left">{{ model|unslugify }} Assessments ({{ items.paginator.count }})</h2>
<div class="table-responsive">
<br />
<table class="table table-bordered table-hover" style="overflow-x: auto; max-width: 100%;">
<tbody>
<tr>
<th colspan="{% if model == 'metric' %}4{% else %}3{% endif %}">
Assessment
</th>
<th colspan="100%">
Metrics
</th>
</tr>
<tr>
<br />
<table class="table table-bordered table-hover table-sticky-header" style="max-width: 100%;">
<thead>
<tr>
<th colspan="{% if model == 'metric' %}4{% else %}3{% endif %}">
Assessment
</th>
<th colspan="100%">
Metrics
</th>
</tr>
<tr>
<th colspan="{% if model == 'metric' %}4{% else %}3{% endif %}" class="tbody-thead"><div>
{% if model != "digital_object" %}
<th>
<div>
Target
</th>
</div>
{% endif %}
{% if model != "rubric" %}
<th>
<div>
Rubric
</th>
</div>
{% endif %}
{% if model != "project" %}
<th>
<div>
Project
</th>
</div>
{% endif %}
<th>
<div>
&nbsp;
</div>
</div></th>
{% for metric in metrics %}
<th>
<a href="{% url 'metric-detail' pk=metric.pk %}">
{{ metric.title }}
</a>
</th>
{% for metric in metrics %}
<th>
<a href="{% url 'metric-detail' pk=metric.pk %}">
{{ metric.title }}
</a>
</th>
{% endfor %}
</tr>
{% for assessment in items %}
<tr>
{% if model != "digital_object" %}
<th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for assessment in items %}
<tr>
<th class="tbody-thead" colspan="{% if model == 'metric' %}4{% else %}3{% endif %}"><div>
{% if model != "digital_object" %}
<div>
<a href="{% url 'digital_object-detail' pk=assessment.target.pk %}">
{{ assessment.target.title }}
</a>
</th>
{% endif %}
{% if model != "rubric" %}
<th>
</div>
{% endif %}
{% if model != "rubric" %}
<div>
<a href="{% url 'rubric-detail' pk=assessment.rubric.pk %}">
{{ assessment.rubric.title }}
</a>
</th>
{% endif %}
{% if model != "project" %}
<th>
</div>
{% endif %}
{% if model != "project" %}
<div>
{% if assessment.project %}
<a href="{% url 'project-detail' pk=assessment.project.pk %}">
{{ assessment.project.title }}
</a>
{% endif %}
</th>
{% endif %}
<th>
</div>
{% endif %}
<div>
<div
class="insignia"
style="width: 40px; height: 40px; min-width:40px; min-height: 40px;"
Expand All @@ -84,30 +88,30 @@ <h2 class="text-left">{{ model|unslugify }} Assessments ({{ items.paginator.coun
Details
</a>
{% endif %}
</th>
{% for metric in metrics %}
{% with assessment_pk=assessment.pk|jsonify metric_pk=metric.pk|jsonify %}
{% with assessment_metric=assessment_pk|add:"-"|add:metric_pk %}
{% with answer=answers|return_item:assessment_metric %}
{% if answer %}
<td style="white-space: nowrap; background-color: {{ answer.color }};">
{{ answer.annotate }} ({{ answer.answer }})
</td>
{% else %}
<td style="white-space: nowrap; background-color: rgba(221,221,221,0.25);">
&nbsp;
</td>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% include "fairshake/generic/page_nav.html" %}
</div>
</div>
</div></th>
{% for metric in metrics %}
{% with assessment_pk=assessment.pk|jsonify metric_pk=metric.pk|jsonify %}
{% with assessment_metric=assessment_pk|add:"-"|add:metric_pk %}
{% with answer=answers|return_item:assessment_metric %}
{% if answer %}
<td style="white-space: nowrap; background-color: {{ answer.color }};">
{{ answer.annotate }} ({{ answer.answer|stringformat:"0.2f" }})
</td>
{% else %}
<td style="white-space: nowrap; background-color: rgba(221,221,221,0.25);">
&nbsp;
</td>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% include "fairshake/generic/page_nav.html" %}
</div>
</div>
</div>