Fixed emoji sorting in organization list and service list views.

This commit is contained in:
Christian P. MOMON 2022-01-21 19:41:41 +01:00
parent ebff7251e8
commit a1b0c34645
2 changed files with 78 additions and 14 deletions

View file

@ -47,14 +47,47 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() $(document).ready(function()
{ {
$.fn.dataTable.moment( 'DD/MM/YYYY' ); $.fn.dataTable.moment('DD/MM/YYYY');
$.extend($.fn.dataTable.ext.type.order,
{
"custom-sort-asc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return -1;
else if (isNaN(y))
return +1;
else
return x-y;
},
"custom-sort-desc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return +1;
else if (isNaN(y))
return -1;
else
return y-x;
}
} );
$('#organizations').DataTable( $('#organizations').DataTable(
{ {
paging: false, paging: false,
ordering: true, ordering: true,
"order": [[ 2, "desc" ]], "order": [[ 2, "desc" ]],
language: dataTableFrench language: dataTableFrench,
"columnDefs":
[
{ targets: 2, "type": 'custom-sort' },
{ targets: 3, "type": 'custom-sort' },
{ targets: 4, "type": 'custom-sort' }
]
}); });
} ); } );
</script> </script>

View file

@ -136,14 +136,45 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() $(document).ready(function()
{ {
$.fn.dataTable.moment( 'DD/MM/YYYY' ); $.fn.dataTable.moment('DD/MM/YYYY');
$.extend($.fn.dataTable.ext.type.order,
{
"custom-sort-asc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return -1;
else if (isNaN(y))
return +1;
else
return x-y;
},
"custom-sort-desc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return +1;
else if (isNaN(y))
return -1;
else
return y-x;
}
} );
$('#serviceListTable').DataTable( $('#serviceListTable').DataTable(
{ {
paging: false, paging: false,
ordering: true, ordering: true,
"order": [[ 2, "desc" ]], "order": [[ 2, "desc" ]],
language: dataTableFrench language: dataTableFrench,
"columnDefs":
[
{ targets: 4, "type": 'custom-sort' },
{ targets: 5, "type": 'custom-sort' }
]
}); });
}); });
</script> </script>