1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-18 05:35:51 +02:00

Continued sort adapter

This commit is contained in:
Max Guglielmi 2016-09-15 23:39:43 +10:00
parent c70aa29523
commit d656ec90b0
5 changed files with 90 additions and 34 deletions

View file

@ -3899,13 +3899,13 @@ return /******/ (function(modules) { // webpackBootstrap
var FORMATTED_NUMBER_EU = exports.FORMATTED_NUMBER_EU = 'formatted-number-eu';
/**
*Date
* Date
* @type {String}
*/
var DATE = exports.DATE = 'date';
/**
*IP address
* IP address
* @type {String}
*/
var IP_ADDRESS = exports.IP_ADDRESS = 'ipaddress';
@ -10203,7 +10203,7 @@ return /******/ (function(modules) { // webpackBootstrap
// let locale = this.datetime.getLocale(this.locale);
// Add formats from column types configuration if any
this._addConfigFormats();
this.addConfigFormats(this.tf.colTypes);
// locale.addFormat('{dd}/{MM}/{yyyy}');
// locale.addFormat('{MM}/{dd}/{yyyy}');
// locale.addFormat('{dd}-{months}-{yyyy|yy}');
@ -10226,16 +10226,19 @@ return /******/ (function(modules) { // webpackBootstrap
return this.datetime.isValid(this.parse(dateStr, localeCode));
};
DateType.prototype.getOptions = function getOptions(colIndex) {
var colType = this.tf.colTypes[colIndex];
DateType.prototype.getOptions = function getOptions(colIndex, types) {
types = types || this.tf.colTypes;
var colType = types[colIndex];
return (0, _types.isObj)(colType) ? colType : {};
};
DateType.prototype._addConfigFormats = function _addConfigFormats() {
DateType.prototype.addConfigFormats = function addConfigFormats() {
var _this = this;
this.tf.colTypes.forEach(function (type, idx) {
var options = _this.getOptions(idx);
var types = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
types.forEach(function (type, idx) {
var options = _this.getOptions(idx, types);
if (options.hasOwnProperty('format')) {
(function () {
var locale = _this.datetime.getLocale(options.locale || _this.locale);

View file

@ -2824,11 +2824,25 @@ webpackJsonp([1],{
sortTypes = this.sortTypes,
_sortTypes = [];
for (var i = 0; i < tf.nbCells; i++) {
for (var i = 0; i < tf.getCellsNb(); i++) {
var colType = void 0;
if (sortTypes[i]) {
colType = sortTypes[i].toLowerCase();
colType = sortTypes[i];
if (isObj(colType)) {
// colType = colType.type;
if (colType.type === _const.DATE) {
// let dateType = tf.feature('dateType');
// let locale=dateType.getOptions(i,sortTypes).locale ||
// tf.locale;
// colType = `${DATE}-${locale}`;
// this.addSortType(colType, (dateStr) => {
// return dateType.parse(dateStr, locale);
// });
colType = this._addDateType(i, sortTypes);
}
}
colType = colType.toLowerCase();
if (colType === _const.NONE) {
colType = 'None';
}
@ -2839,14 +2853,13 @@ webpackJsonp([1],{
// } else if (tf.hasColDateType && tf.colDateType[i] !== null) {
// colType = tf.colDateType[i].toLowerCase() + 'date';
} else if (tf.hasType(i, [_const.DATE])) {
(function () {
var dateType = tf.feature('dateType');
var locale = dateType.getOptions(i).locale || tf.locale;
colType = _const.DATE + '-' + locale;
_this3.addSortType(colType, function (dateStr) {
return dateType.parse(dateStr, locale);
});
})();
// let dateType = tf.feature('dateType');
// let locale = dateType.getOptions(i).locale || tf.locale;
// colType = `${DATE}-${locale}`;
// this.addSortType(colType, (dateStr) => {
// return dateType.parse(dateStr, locale);
// });
colType = this._addDateType(i);
} else {
colType = _const.STRING;
}
@ -2897,6 +2910,18 @@ webpackJsonp([1],{
}
};
AdapterSortableTable.prototype._addDateType = function _addDateType(colIndex, types) {
var tf = this.tf;
var dateType = tf.feature('dateType');
var locale = dateType.getOptions(colIndex, types).locale || tf.locale;
var colType = _const.DATE + '-' + locale;
this.addSortType(colType, function (dateStr) {
return dateType.parse(dateStr, locale);
});
return colType;
};
/**
* Remove extension
*/

View file

@ -102,13 +102,13 @@ export const FORMATTED_NUMBER = 'formatted-number';
export const FORMATTED_NUMBER_EU = 'formatted-number-eu';
/**
*Date
* Date
* @type {String}
*/
export const DATE = 'date';
/**
*IP address
* IP address
* @type {String}
*/
export const IP_ADDRESS = 'ipaddress';

View file

@ -395,11 +395,25 @@ export default class AdapterSortableTable extends Feature {
sortTypes = this.sortTypes,
_sortTypes = [];
for (let i = 0; i < tf.nbCells; i++) {
for (let i = 0; i < tf.getCellsNb(); i++) {
let colType;
if (sortTypes[i]) {
colType = sortTypes[i].toLowerCase();
colType = sortTypes[i];
if (isObj(colType)) {
// colType = colType.type;
if (colType.type === DATE) {
// let dateType = tf.feature('dateType');
// let locale=dateType.getOptions(i,sortTypes).locale ||
// tf.locale;
// colType = `${DATE}-${locale}`;
// this.addSortType(colType, (dateStr) => {
// return dateType.parse(dateStr, locale);
// });
colType = this._addDateType(i, sortTypes);
}
}
colType = colType.toLowerCase();
if (colType === NONE) {
colType = 'None';
}
@ -410,12 +424,13 @@ export default class AdapterSortableTable extends Feature {
// } else if (tf.hasColDateType && tf.colDateType[i] !== null) {
// colType = tf.colDateType[i].toLowerCase() + 'date';
} else if (tf.hasType(i, [DATE])) {
let dateType = tf.feature('dateType');
let locale = dateType.getOptions(i).locale || tf.locale;
colType = `${DATE}-${locale}`;
this.addSortType(colType, (dateStr) => {
return dateType.parse(dateStr, locale);
});
// let dateType = tf.feature('dateType');
// let locale = dateType.getOptions(i).locale || tf.locale;
// colType = `${DATE}-${locale}`;
// this.addSortType(colType, (dateStr) => {
// return dateType.parse(dateStr, locale);
// });
colType = this._addDateType(i);
} else {
colType = STRING;
}
@ -464,6 +479,18 @@ export default class AdapterSortableTable extends Feature {
}
}
_addDateType(colIndex, types) {
let tf = this.tf;
let dateType = tf.feature('dateType');
let locale = dateType.getOptions(colIndex, types).locale || tf.locale;
let colType = `${DATE}-${locale}`;
this.addSortType(colType, (dateStr) => {
return dateType.parse(dateStr, locale);
});
return colType;
}
/**
* Remove extension
*/

View file

@ -22,7 +22,7 @@ export class DateType {
// let locale = this.datetime.getLocale(this.locale);
// Add formats from column types configuration if any
this._addConfigFormats();
this.addConfigFormats(this.tf.colTypes);
// locale.addFormat('{dd}/{MM}/{yyyy}');
// locale.addFormat('{MM}/{dd}/{yyyy}');
// locale.addFormat('{dd}-{months}-{yyyy|yy}');
@ -45,14 +45,15 @@ export class DateType {
return this.datetime.isValid(this.parse(dateStr, localeCode));
}
getOptions(colIndex) {
let colType = this.tf.colTypes[colIndex];
getOptions(colIndex, types) {
types = types || this.tf.colTypes;
let colType = types[colIndex];
return isObj(colType) ? colType : {};
}
_addConfigFormats() {
this.tf.colTypes.forEach((type, idx) => {
let options = this.getOptions(idx);
addConfigFormats(types=[]) {
types.forEach((type, idx) => {
let options = this.getOptions(idx, types);
if (options.hasOwnProperty('format')) {
let locale = this.datetime.getLocale(
options.locale || this.locale