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

Fix several issues with Datatables #3750

Merged
merged 10 commits into from
Dec 17, 2024
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
document.addEventListener("DOMContentLoaded", event => {
$("#challengeCostsOverviewTable").DataTable({
order: [[2, "desc"]],
order: [
[2, "desc"],
jmsmkn marked this conversation as resolved.
Show resolved Hide resolved
[3, "desc"],
],
lengthChange: false,
pageLength: 100,
});
Expand Down
3 changes: 0 additions & 3 deletions app/grandchallenge/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ def get_queryset(self):
.with_available_compute()
.with_most_recent_submission_datetime()
.prefetch_related("phase_set")
.order_by(
F("most_recent_submission_datetime").desc(nulls_last=True)
)
)


Expand Down
1 change: 1 addition & 0 deletions app/grandchallenge/core/static/css/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $pagination-disabled-bg: lighten($blue, 15%) !default;
@import "../vendored/bootswatch/dist/flatly/variables";
@import "../vendored/bootstrap/scss/bootstrap";
@import "../vendored/bootswatch/dist/flatly/bootswatch";
@import "datatables";

// Fix https://github.com/comic/grand-challenge.org/issues/1201
.custom-select {
Expand Down
26 changes: 0 additions & 26 deletions app/grandchallenge/core/static/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,29 +242,3 @@ a[aria-expanded="false"] .fa-chevron-down {
.htmx-request.htmx-indicator {
display: inline-block;
}

/* datatables */
.dt-layout-start,
.dt-layout-end {
padding-top: 0.2rem;
padding-bottom: 0.2rem;
}

.dt-container ul.pagination {
justify-content: right;
}

.dt-layout-full,
.dt-layout-start,
.dt-layout-end {
padding-left: 0 !important;
padding-right: 0 !important;
}

.dt-scroll-body {
border-bottom: none !important;
}

.dt-orderable-none .dt-column-order {
display: none;
}
25 changes: 25 additions & 0 deletions app/grandchallenge/core/static/css/datatables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

.dt-layout-start,
.dt-layout-end {
padding-top: $spacer * 0.5;
padding-bottom: $spacer * 0.5;
}

.dt-container ul.pagination {
justify-content: right;
}

.dt-layout-full,
.dt-layout-start,
.dt-layout-end {
padding-left: 0 !important;
padding-right: 0 !important;
}

.dt-scroll-body {
border-bottom: none !important;
}

.dt-orderable-none .dt-column-order {
display: none;
}
11 changes: 11 additions & 0 deletions app/grandchallenge/core/static/js/datatables.defaults.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ $.extend($.fn.dataTable.defaults, {
orderable: false,
},
],
drawCallback: function () {
const api = this.api();
api.columns().every(function () {
if (this.orderable) {
this.header().setAttribute(
"title",
"Activate to sort. Hold Shift to sort by multiple columns.",
);
}
});
},
});

$(document).on("init.dt", () => {
Expand Down
Loading