This commit is contained in:
Ross
2022-01-10 14:26:16 +00:00
parent e3dbdb2615
commit 2d5968c014
2 changed files with 56 additions and 53 deletions
+46 -44
View File
@@ -15,9 +15,9 @@
</div> </div>
<div> <div>
<span id="manage-span"> <span id="manage-span">
{% render_table table %} {% render_table table %}
</span> </span>
</div> </div>
<details> <details>
@@ -102,51 +102,51 @@
{% block js %} {% block js %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.11.3/r-2.2.9/datatables.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.11.3/r-2.2.9/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.11.3/r-2.2.9/datatables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.11.3/r-2.2.9/datatables.min.js"></script>
<script> <script>
jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) { jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) {
var esc = function ( t ) { var esc = function ( t ) {
return t return t
.replace( /&/g, '&amp;' ) .replace( /&/g, '&amp;' )
.replace( /</g, '&lt;' ) .replace( /</g, '&lt;' )
.replace( />/g, '&gt;' ) .replace( />/g, '&gt;' )
.replace( /"/g, '&quot;' ); .replace( /"/g, '&quot;' );
}; };
return function ( d, type, row ) { return function ( d, type, row ) {
// Order, search and type get the original data // Order, search and type get the original data
if ( type !== 'display' ) { if ( type !== 'display' ) {
return d; return d;
} }
if ( typeof d !== 'number' && typeof d !== 'string' ) { if ( typeof d !== 'number' && typeof d !== 'string' ) {
return d; return d;
} }
d = d.toString(); // cast numbers d = d.toString(); // cast numbers
if ( d.length <= cutoff ) { if ( d.length <= cutoff ) {
return d; return d;
} }
var shortened = d.substr(0, cutoff-1); var shortened = d.substr(0, cutoff-1);
// Find the last white space character in the string // Find the last white space character in the string
if ( wordbreak ) { if ( wordbreak ) {
shortened = shortened.replace(/\s([^\s]*)$/, ''); shortened = shortened.replace(/\s([^\s]*)$/, '');
} }
// Protect against uncontrolled HTML input // Protect against uncontrolled HTML input
if ( escapeHtml ) { if ( escapeHtml ) {
shortened = esc( shortened ); shortened = esc( shortened );
} }
return '<span class="ellipsis" title="'+esc(d)+'">'+shortened+'&#8230;</span>'; return '<span class="ellipsis" title="'+esc(d)+'">'+shortened+'&#8230;</span>';
}; };
}; };
function postAjax(data) { function postAjax(data) {
@@ -200,13 +200,15 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml )
$(document).ready(function () { $(document).ready(function () {
$("table").DataTable({ {% if exams %}
columnDefs: [ { $("table").DataTable({
targets: [6,7,8,9,10], columnDefs: [ {
render: $.fn.dataTable.render.ellipsis( 17, true ) targets: [6,7,8,9,10],
} ], render: $.fn.dataTable.render.ellipsis( 17, true )
"paging": false, } ],
}); "paging": false,
});
{% endif %}
$("#toggle-internal").click((evt) => { $("#toggle-internal").click((evt) => {
data = getGenericData(); data = getGenericData();
+1
View File
@@ -1326,6 +1326,7 @@ class CidUserExamView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
context["longs_exams"] = longs_exams context["longs_exams"] = longs_exams
context["anatomy_exams"] = anatomy_exams context["anatomy_exams"] = anatomy_exams
context["cid_user_groups"] = cid_user_groups context["cid_user_groups"] = cid_user_groups
context["exams"] = True
return context return context
class CidUserView(CidManagerRequiredMixin, SingleTableMixin, FilterView): class CidUserView(CidManagerRequiredMixin, SingleTableMixin, FilterView):