TEST datetime sort
This commit is contained in:
parent
48725b8703
commit
25d1c2400e
@ -674,7 +674,8 @@ class course extends common
|
|||||||
? $pages[$this->getData(['enrolment', $courseId, $userId, 'lastPageView'])]['title']
|
? $pages[$this->getData(['enrolment', $courseId, $userId, 'lastPageView'])]['title']
|
||||||
: '',
|
: '',
|
||||||
$this->getData(['enrolment', $courseId, $userId, 'datePageView'])
|
$this->getData(['enrolment', $courseId, $userId, 'datePageView'])
|
||||||
? helper::dateUTF8('%d %B %Y - %H:%M', $this->getData(['enrolment', $courseId, $userId, 'datePageView']))
|
? $this->getData(['enrolment', $courseId, $userId, 'datePageView'])
|
||||||
|
//? helper::dateUTF8('%d %B %Y - %H:%M', $this->getData(['enrolment', $courseId, $userId, 'datePageView']))
|
||||||
: '',
|
: '',
|
||||||
$this->getData(['user', $userId, 'tags']),
|
$this->getData(['user', $userId, 'tags']),
|
||||||
template::button('userHistory' . $userId, [
|
template::button('userHistory' . $userId, [
|
||||||
|
@ -28,6 +28,10 @@ $(document).ready((function () {
|
|||||||
},
|
},
|
||||||
locale: 'fr',
|
locale: 'fr',
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
target: 3,
|
||||||
|
render: DataTable.render.moment( 'YYYY/MM/DD', 'Do MMM YY', 'fr' )
|
||||||
|
},
|
||||||
{
|
{
|
||||||
target: 6,
|
target: 6,
|
||||||
orderable: false,
|
orderable: false,
|
||||||
|
133
core/vendor/datatables/datetime.js
vendored
Normal file
133
core/vendor/datatables/datetime.js
vendored
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*! © SpryMedia Ltd - datatables.net/license */
|
||||||
|
|
||||||
|
(function( factory ){
|
||||||
|
if ( typeof define === 'function' && define.amd ) {
|
||||||
|
// AMD
|
||||||
|
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||||
|
return factory( $, window, document );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
else if ( typeof exports === 'object' ) {
|
||||||
|
// CommonJS
|
||||||
|
var jq = require('jquery');
|
||||||
|
var cjsRequires = function (root, $) {
|
||||||
|
if ( ! $.fn.dataTable ) {
|
||||||
|
require('datatables.net')(root, $);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
module.exports = function (root, $) {
|
||||||
|
if ( ! root ) {
|
||||||
|
// CommonJS environments without a window global must pass a
|
||||||
|
// root. This will give an error otherwise
|
||||||
|
root = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $ ) {
|
||||||
|
$ = jq( root );
|
||||||
|
}
|
||||||
|
|
||||||
|
cjsRequires( root, $ );
|
||||||
|
return factory( $, root, root.document );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cjsRequires( window, jq );
|
||||||
|
module.exports = factory( jq, window, window.document );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Browser
|
||||||
|
factory( jQuery, window, document );
|
||||||
|
}
|
||||||
|
}(function( $, window, document, undefined ) {
|
||||||
|
'use strict';
|
||||||
|
var DataTable = $.fn.dataTable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE - As of DataTables 1.12, DataTables has a built in date / time renderer
|
||||||
|
* which should be used in place of this renderer. See
|
||||||
|
* [the manual](https://datatables.net/manual/data/renderers#Date-and-time-helpers)
|
||||||
|
* for details.
|
||||||
|
*
|
||||||
|
* Date / time formats often from back from server APIs in a format that you
|
||||||
|
* don't wish to display to your end users (ISO8601 for example). This rendering
|
||||||
|
* helper can be used to transform any source date / time format into something
|
||||||
|
* which can be easily understood by your users when reading the table, and also
|
||||||
|
* by DataTables for sorting the table.
|
||||||
|
*
|
||||||
|
* The [MomentJS library](http://momentjs.com/) is used to accomplish this and
|
||||||
|
* you simply need to tell it which format to transfer from, to and specify a
|
||||||
|
* locale if required.
|
||||||
|
*
|
||||||
|
* This function should be used with the `dt-init columns.render` configuration
|
||||||
|
* option of DataTables.
|
||||||
|
*
|
||||||
|
* It accepts one, two or three parameters:
|
||||||
|
*
|
||||||
|
* * `DataTable.render.moment( to );`
|
||||||
|
* * `DataTable.render.moment( from, to );`
|
||||||
|
* * `DataTable.render.moment( from, to, locale );`
|
||||||
|
*
|
||||||
|
* Where:
|
||||||
|
*
|
||||||
|
* * `to` - the format that will be displayed to the end user
|
||||||
|
* * `from` - the format that is supplied in the data (the default is ISO8601 -
|
||||||
|
* `YYYY-MM-DD`)
|
||||||
|
* * `locale` - the locale which MomentJS should use - the default is `en`
|
||||||
|
* (English).
|
||||||
|
*
|
||||||
|
* @name datetime
|
||||||
|
* @summary Convert date / time source data into one suitable for display
|
||||||
|
* @author [Allan Jardine](http://datatables.net)
|
||||||
|
* @requires DataTables 1.10+, Moment.js 1.7+
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Convert ISO8601 dates into a simple human readable format
|
||||||
|
* $('#example').DataTable( {
|
||||||
|
* columnDefs: [ {
|
||||||
|
* targets: 1,
|
||||||
|
* render: DataTable.render.moment( 'Do MMM YYYY' )
|
||||||
|
* } ]
|
||||||
|
* } );
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Specify a source format - in this case a unix timestamp
|
||||||
|
* $('#example').DataTable( {
|
||||||
|
* columnDefs: [ {
|
||||||
|
* targets: 2,
|
||||||
|
* render: DataTable.render.moment( 'X', 'Do MMM YY' )
|
||||||
|
* } ]
|
||||||
|
* } );
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Specify a source format and locale
|
||||||
|
* $('#example').DataTable( {
|
||||||
|
* columnDefs: [ {
|
||||||
|
* targets: 2,
|
||||||
|
* render: DataTable.render.moment( 'YYYY/MM/DD', 'Do MMM YY', 'fr' )
|
||||||
|
* } ]
|
||||||
|
* } );
|
||||||
|
*/
|
||||||
|
DataTable.render.moment = function (from, to, locale) {
|
||||||
|
// Argument shifting
|
||||||
|
if (arguments.length === 1) {
|
||||||
|
to = from;
|
||||||
|
from = 'YYYY-MM-DD';
|
||||||
|
}
|
||||||
|
return function (d, type, row) {
|
||||||
|
if (!d) {
|
||||||
|
return type === 'sort' || type === 'type' ? 0 : d;
|
||||||
|
}
|
||||||
|
var m = window.moment(d, from, locale, true);
|
||||||
|
// Order and type get a number value from Moment, everything else
|
||||||
|
// sees the rendered value
|
||||||
|
return m.format(type === 'sort' || type === 'type' ? 'x' : to);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return DateTime;
|
||||||
|
}));
|
1
core/vendor/datatables/inc.json
vendored
1
core/vendor/datatables/inc.json
vendored
@ -1,4 +1,5 @@
|
|||||||
[
|
[
|
||||||
"datatables.min.js",
|
"datatables.min.js",
|
||||||
|
"datatime.js",
|
||||||
"datatables.min.css"
|
"datatables.min.css"
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user