Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Merge branch '923/sort-by-rank'
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Mar 22, 2017
2 parents 8682d79 + 7d4898b commit 02ce637
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 19 deletions.
29 changes: 20 additions & 9 deletions census/static/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion census/static/css/styles.css.map

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion census/static/scripts/site/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ define(['jquery', 'bootstrap', 'chroma', 'tablesorter', 'stickykit'],
11: {sorter: false}
}
},
tablesorterPlaceIndexOptions = {
sortList: [[0, 0]],
headers: {
2: {sorter: false},
3: {sorter: false},
4: {sorter: false},
5: {sorter: false},
6: {sorter: false},
7: {sorter: false},
8: {sorter: false},
9: {sorter: false},
10: {sorter: false},
11: {sorter: false}
}
},
tablesorterDatasetOptions = {
sortList: [[0, 0]],
headers: {
Expand Down Expand Up @@ -71,6 +86,7 @@ define(['jquery', 'bootstrap', 'chroma', 'tablesorter', 'stickykit'],
sortFlag = true;

$('#places_overview_table').tablesorter(tablesorterPlaceOptions);
$('#places_overview_table_index').tablesorter(tablesorterPlaceIndexOptions);
$('#datasets_overview_table').tablesorter(tablesorterDatasetOptions);
$('#slice-table').tablesorter(tablesorterSliceOptions);
$('#slice-table-index').tablesorter(tablesorterSliceIndexOptions);
Expand All @@ -82,7 +98,7 @@ define(['jquery', 'bootstrap', 'chroma', 'tablesorter', 'stickykit'],

$('.content').on('click', '.sort_rank, .sort_place',
function(e) {
$('#places_overview_table').trigger('sorton',
$('#places_overview_table, #places_overview_table_index').trigger('sorton',
[[[$(e.target).hasClass('sort_place') / 1, sortFlag]]]);
$('.headerSortDown').removeClass('headerSortDown');
$('.headerSortUp').removeClass('headerSortUp');
Expand Down
9 changes: 6 additions & 3 deletions census/static/scss/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,18 @@ td.previous-results {
}


#places_overview_table thead tr th, #datasets_overview_table thead tr th, .slice-table thead tr th {
#places_overview_table thead tr th,
#places_overview_table_index thead tr th,
#datasets_overview_table thead tr th,
.slice-table thead tr th {
&.clickable {
cursor: pointer;
color: lighten(black, 15%);
}
}

#places_overview_table {

#places_overview_table,
#places_overview_table_index {
tr td {
padding: 8px 4px 8px 4px !important;

Expand Down
14 changes: 10 additions & 4 deletions census/views/includes/dataviews/table_places.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{% import "macros/popovers.html" as popovers %}

{% if is_index %}
{% set table_id = "places_overview_table_index" %}
{% set sortby = "rank" %}
{% else %}
{% set table_id = "places_overview_table" %}
{% set sortby = "name" %}
{% endif %}
<div class="table-responsive">
<table id="places_overview_table" class="table data-table sexyTable">
<table id="{{ table_id }}" class="table data-table sexyTable">
<thead>
<tr>
<th class="clickable sort_rank header" title="{{ gettext('Sort by Rank') }}" style="width: 71px;">{{ gettext('Rank') }}</th>
<th class="clickable sort_place header headerSortDown" title="{{ gettext('Sort by A-Z') }}" style="width: 71px;">{{ gettext('Place') }}</th>
<th class="clickable sort_place header" title="{{ gettext('Sort by A-Z') }}" style="width: 71px;">{{ gettext('Place') }}</th>
{% for dataset in datasets %}
<th class="datasetHeader">
<div><a href="{{ format('/dataset/%(dataset)s', {dataset: dataset.id}) }}">{{ dataset.name }}</a></div>
Expand All @@ -15,7 +21,7 @@
</tr>
</thead>
<tbody>
{% for place in places|sort(false, false, 'name') %}
{% for place in places|sort(false, false, sortby) %}
<tr data-rank="{{ place.rank }}" data-score="{{ place.computedRelativeScore}}" data-place="{{ place.id }}" data-name="{{ place.name }}">
<td class="rank" data-rank="{{ place.rank }}">
<div>{{ place.rank }}</div>
Expand Down
4 changes: 3 additions & 1 deletion census/views/includes/dataviews/table_slice_dataset.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div class="table-responsive">
{% if is_index %}
{% set tableId = 'slice-table-index' %}
{% set sortby = 'rank' %}
{% else %}
{% set tableId = 'slice-table' %}
{% set sortby = 'name' %}
{% endif %}
<table id="{{ tableId }}" class="table slice-table data-table table-header-stuck">
{% if is_index %}
Expand Down Expand Up @@ -41,7 +43,7 @@
</tr>
</thead>
<tbody>
{% for place in places|sort(false, false, 'name') %}
{% for place in places|sort(false, false, sortby) %}
{% set entry = entries|find({'place': place.id, 'dataset': dataset.id}) %}
{% set submissions = pending|where({'place': place.id, 'dataset': dataset.id}) %}
<tr id="{{ place.id }}" class="entry" data-rank="{{ place.rank }}" data-score="{{ place.computedScore }}" data-place="{{ place.id }}" data-name="{{ place.name }}">
Expand Down

0 comments on commit 02ce637

Please sign in to comment.