mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-20 23:36:39 +02:00
Continued date type
This commit is contained in:
parent
a3c4f2158b
commit
c70aa29523
91
dist/tablefilter/tablefilter.js
vendored
91
dist/tablefilter/tablefilter.js
vendored
|
@ -1990,8 +1990,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
function hasArg(sA, cellData, colIdx) {
|
||||
sA = (0, _string.matchCase)(sA, this.caseSensitive);
|
||||
|
||||
var occurence = void 0;
|
||||
var dateType = this.Mod.dateType;
|
||||
var occurence = false;
|
||||
// let dtType = this.hasColDateType ?
|
||||
// this.colDateType[colIdx] : this.defaultDateType;
|
||||
// let dtType = this.hasType(colIdx, [DATE]) ?
|
||||
|
@ -2020,54 +2019,59 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
// let isGEDate=hasGE && isValidDate(sA.replace(re_ge, ''), dtType);
|
||||
// let isDFDate=hasDF && isValidDate(sA.replace(re_d, ''), dtType);
|
||||
// let isEQDate=hasEQ && isValidDate(sA.replace(re_eq, ''), dtType);
|
||||
var isLDate = hasLO && dateType.isValid(sA.replace(re_l, ''));
|
||||
var isLEDate = hasLE && dateType.isValid(sA.replace(re_le, ''));
|
||||
var isGDate = hasGR && dateType.isValid(sA.replace(re_g, ''));
|
||||
var isGEDate = hasGE && dateType.isValid(sA.replace(re_ge, ''));
|
||||
var isDFDate = hasDF && dateType.isValid(sA.replace(re_d, ''));
|
||||
var isEQDate = hasEQ && dateType.isValid(sA.replace(re_eq, ''));
|
||||
|
||||
var dte1 = void 0,
|
||||
dte2 = void 0;
|
||||
//dates
|
||||
if (this.hasType(colIdx, [_const.DATE]) && dateType.isValid(cellData)
|
||||
if (this.hasType(colIdx, [_const.DATE]) /*&& isValidDate(cellData)*/
|
||||
/*isValidDate(cellData, dtType)*/) {
|
||||
var dte1 = void 0,
|
||||
dte2 = void 0;
|
||||
var dateType = this.Mod.dateType;
|
||||
var isValidDate = dateType.isValid.bind(dateType);
|
||||
var parseDate = dateType.parse.bind(dateType);
|
||||
var locale = dateType.getOptions(colIdx).locale || this.locale;
|
||||
|
||||
var isLDate = hasLO && isValidDate(sA.replace(re_l, ''), locale);
|
||||
var isLEDate = hasLE && isValidDate(sA.replace(re_le, ''), locale);
|
||||
var isGDate = hasGR && isValidDate(sA.replace(re_g, ''), locale);
|
||||
var isGEDate = hasGE && isValidDate(sA.replace(re_ge, ''), locale);
|
||||
var isDFDate = hasDF && isValidDate(sA.replace(re_d, ''), locale);
|
||||
var isEQDate = hasEQ && isValidDate(sA.replace(re_eq, ''), locale);
|
||||
|
||||
// dte1 = formatDate(cellData, dtType);
|
||||
dte1 = dateType.parse(cellData, locale);
|
||||
dte1 = parseDate(cellData, locale);
|
||||
// lower date
|
||||
if (isLDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_l, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_l, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_l, ''), dtType);
|
||||
occurence = dte1 < dte2;
|
||||
}
|
||||
// lower equal date
|
||||
else if (isLEDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_le, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_le, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_le, ''), dtType);
|
||||
occurence = dte1 <= dte2;
|
||||
}
|
||||
// greater equal date
|
||||
else if (isGEDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_ge, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_ge, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_ge, ''), dtType);
|
||||
occurence = dte1 >= dte2;
|
||||
}
|
||||
// greater date
|
||||
else if (isGDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_g, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_g, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_g, ''), dtType);
|
||||
occurence = dte1 > dte2;
|
||||
}
|
||||
// different date
|
||||
else if (isDFDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_d, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_d, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_d, ''), dtType);
|
||||
occurence = dte1.toString() !== dte2.toString();
|
||||
}
|
||||
// equal date
|
||||
else if (isEQDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_eq, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_eq, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_eq, ''), dtType);
|
||||
occurence = dte1.toString() === dte2.toString();
|
||||
}
|
||||
|
@ -2075,10 +2079,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
else if (re_lk.test(sA)) {
|
||||
// like date
|
||||
occurence = (0, _string.contains)(sA.replace(re_lk, ''), cellData, false, this.caseSensitive);
|
||||
} else if (dateType.isValid(sA)
|
||||
} else if (isValidDate(sA)
|
||||
/*isValidDate(sA, dtType)*/) {
|
||||
// dte2 = formatDate(sA, dtType);
|
||||
dte2 = dateType.parse(sA, locale);
|
||||
dte2 = parseDate(sA, locale);
|
||||
occurence = dte1.toString() === dte2.toString();
|
||||
}
|
||||
//empty
|
||||
|
@ -10184,32 +10188,42 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
this.tf = tf;
|
||||
this.locale = tf.locale;
|
||||
this.suDate = _sugarDate.Date;
|
||||
this.datetime = _sugarDate.Date;
|
||||
this.emitter = tf.emitter;
|
||||
|
||||
// Global locale
|
||||
this.suDate.setLocale(this.locale);
|
||||
}
|
||||
|
||||
DateType.prototype.init = function init() {
|
||||
// let locale = this.suDate.getLocale(this.locale);
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add formats from column types configuration
|
||||
// Global locale
|
||||
this.datetime.setLocale(this.locale);
|
||||
|
||||
// let locale = this.datetime.getLocale(this.locale);
|
||||
|
||||
// Add formats from column types configuration if any
|
||||
this._addConfigFormats();
|
||||
// locale.addFormat('{dd}/{MM}/{yyyy}');
|
||||
// locale.addFormat('{MM}/{dd}/{yyyy}');
|
||||
// locale.addFormat('{dd}-{months}-{yyyy|yy}');
|
||||
// locale.addFormat('{dd}-{MM}-{yyyy|yy}');
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
this.emitter.emit('date-type-initialized', this.tf, this);
|
||||
};
|
||||
|
||||
DateType.prototype.parse = function parse(dateStr, localeCode) {
|
||||
console.log('parse', localeCode);
|
||||
return this.suDate.create(dateStr, localeCode);
|
||||
// console.log('parse', dateStr, localeCode,
|
||||
// this.datetime.create(dateStr, localeCode));
|
||||
return this.datetime.create(dateStr, localeCode);
|
||||
};
|
||||
|
||||
DateType.prototype.isValid = function isValid(dateStr, localeCode) {
|
||||
console.log(dateStr, localeCode, this.parse(dateStr, localeCode), this.suDate.isValid(this.parse(dateStr, localeCode)));
|
||||
return this.suDate.isValid(this.parse(dateStr, localeCode));
|
||||
// console.log(dateStr, localeCode, this.parse(dateStr, localeCode),
|
||||
// this.datetime.isValid(this.parse(dateStr, localeCode)));
|
||||
return this.datetime.isValid(this.parse(dateStr, localeCode));
|
||||
};
|
||||
|
||||
DateType.prototype.getOptions = function getOptions(colIndex) {
|
||||
|
@ -10223,13 +10237,24 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.tf.colTypes.forEach(function (type, idx) {
|
||||
var options = _this.getOptions(idx);
|
||||
if (options.hasOwnProperty('format')) {
|
||||
var locale = _this.suDate.getLocale(options.locale || _this.locale);
|
||||
console.log(options.format);
|
||||
locale.addFormat(options.format);
|
||||
(function () {
|
||||
var locale = _this.datetime.getLocale(options.locale || _this.locale);
|
||||
if ((0, _types.isArray)(options.format)) {
|
||||
options.format.forEach(function (format) {
|
||||
locale.addFormat(format);
|
||||
});
|
||||
} else {
|
||||
locale.addFormat(options.format);
|
||||
}
|
||||
})();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
DateType.prototype.destroy = function destroy() {
|
||||
this.initialized = false;
|
||||
};
|
||||
|
||||
return DateType;
|
||||
}();
|
||||
|
||||
|
|
59
dist/tablefilter/tf-1.js
vendored
59
dist/tablefilter/tf-1.js
vendored
|
@ -2416,8 +2416,6 @@ webpackJsonp([1],{
|
|||
|
||||
var _event = __webpack_require__(1);
|
||||
|
||||
var _date = __webpack_require__(435);
|
||||
|
||||
var _number = __webpack_require__(6);
|
||||
|
||||
var _const = __webpack_require__(7);
|
||||
|
@ -2427,6 +2425,8 @@ webpackJsonp([1],{
|
|||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
// import {formatDate} from '../../date';
|
||||
|
||||
|
||||
/**
|
||||
* SortableTable Adapter module
|
||||
|
@ -2836,10 +2836,19 @@ webpackJsonp([1],{
|
|||
// resolve column types
|
||||
if (tf.hasType(i, [_const.NUMBER, _const.FORMATTED_NUMBER, _const.FORMATTED_NUMBER_EU, _const.IP_ADDRESS])) {
|
||||
colType = tf.colTypes[i].toLowerCase();
|
||||
} else if (tf.hasColDateType && tf.colDateType[i] !== null) {
|
||||
colType = tf.colDateType[i].toLowerCase() + 'date';
|
||||
// } 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);
|
||||
});
|
||||
})();
|
||||
} else {
|
||||
colType = 'String';
|
||||
colType = _const.STRING;
|
||||
}
|
||||
}
|
||||
_sortTypes.push(colType);
|
||||
|
@ -2850,14 +2859,14 @@ webpackJsonp([1],{
|
|||
//Custom sort types
|
||||
this.addSortType(_const.NUMBER, Number);
|
||||
this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);
|
||||
this.addSortType(_const.DATE, SortableTable.toDate);
|
||||
// this.addSortType(DATE, SortableTable.toDate);
|
||||
this.addSortType(_const.STRING);
|
||||
this.addSortType(_const.FORMATTED_NUMBER, usNumberConverter);
|
||||
this.addSortType(_const.FORMATTED_NUMBER_EU, euNumberConverter);
|
||||
this.addSortType('dmydate', dmyDateConverter);
|
||||
this.addSortType('ymddate', ymdDateConverter);
|
||||
this.addSortType('mdydate', mdyDateConverter);
|
||||
this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
// this.addSortType('dmydate', dmyDateConverter);
|
||||
// this.addSortType('ymddate', ymdDateConverter);
|
||||
// this.addSortType('mdydate', mdyDateConverter);
|
||||
// this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
this.addSortType(_const.IP_ADDRESS, ipAddress, sortIP);
|
||||
|
||||
this.stt = new SortableTable(tf.tbl, _sortTypes);
|
||||
|
@ -2932,21 +2941,21 @@ webpackJsonp([1],{
|
|||
function euNumberConverter(s) {
|
||||
return (0, _number.unformat)(s, _const.FORMATTED_NUMBER_EU);
|
||||
}
|
||||
function dateConverter(s, format) {
|
||||
return (0, _date.formatDate)(s, format);
|
||||
}
|
||||
function dmyDateConverter(s) {
|
||||
return dateConverter(s, 'DMY');
|
||||
}
|
||||
function mdyDateConverter(s) {
|
||||
return dateConverter(s, 'MDY');
|
||||
}
|
||||
function ymdDateConverter(s) {
|
||||
return dateConverter(s, 'YMD');
|
||||
}
|
||||
function ddmmmyyyyDateConverter(s) {
|
||||
return dateConverter(s, 'DDMMMYYYY');
|
||||
}
|
||||
// function dateConverter(s, format) {
|
||||
// return formatDate(s, format);
|
||||
// }
|
||||
// function dmyDateConverter(s) {
|
||||
// return dateConverter(s, 'DMY');
|
||||
// }
|
||||
// function mdyDateConverter(s) {
|
||||
// return dateConverter(s, 'MDY');
|
||||
// }
|
||||
// function ymdDateConverter(s) {
|
||||
// return dateConverter(s, 'YMD');
|
||||
// }
|
||||
// function ddmmmyyyyDateConverter(s) {
|
||||
// return dateConverter(s, 'DDMMMYYYY');
|
||||
// }
|
||||
|
||||
function ipAddress(value) {
|
||||
var vals = value.split('.');
|
||||
|
|
|
@ -2,7 +2,7 @@ import {Feature} from '../../feature';
|
|||
import {isArray, isFn, isUndef} from '../../types';
|
||||
import {createElm, elm, getText, tag} from '../../dom';
|
||||
import {addEvt} from '../../event';
|
||||
import {formatDate} from '../../date';
|
||||
// import {formatDate} from '../../date';
|
||||
import {unformat as unformatNb} from '../../number';
|
||||
import {
|
||||
NONE, CELL_TAG, HEADER_TAG, STRING, NUMBER, DATE, FORMATTED_NUMBER,
|
||||
|
@ -407,10 +407,17 @@ export default class AdapterSortableTable extends Feature {
|
|||
if (tf.hasType(i, [NUMBER, FORMATTED_NUMBER,
|
||||
FORMATTED_NUMBER_EU, IP_ADDRESS])) {
|
||||
colType = tf.colTypes[i].toLowerCase();
|
||||
} else if (tf.hasColDateType && tf.colDateType[i] !== null) {
|
||||
colType = tf.colDateType[i].toLowerCase() + 'date';
|
||||
// } 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);
|
||||
});
|
||||
} else {
|
||||
colType = 'String';
|
||||
colType = STRING;
|
||||
}
|
||||
}
|
||||
_sortTypes.push(colType);
|
||||
|
@ -421,14 +428,14 @@ export default class AdapterSortableTable extends Feature {
|
|||
//Custom sort types
|
||||
this.addSortType(NUMBER, Number);
|
||||
this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);
|
||||
this.addSortType(DATE, SortableTable.toDate);
|
||||
// this.addSortType(DATE, SortableTable.toDate);
|
||||
this.addSortType(STRING);
|
||||
this.addSortType(FORMATTED_NUMBER, usNumberConverter);
|
||||
this.addSortType(FORMATTED_NUMBER_EU, euNumberConverter);
|
||||
this.addSortType('dmydate', dmyDateConverter);
|
||||
this.addSortType('ymddate', ymdDateConverter);
|
||||
this.addSortType('mdydate', mdyDateConverter);
|
||||
this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
// this.addSortType('dmydate', dmyDateConverter);
|
||||
// this.addSortType('ymddate', ymdDateConverter);
|
||||
// this.addSortType('mdydate', mdyDateConverter);
|
||||
// this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
this.addSortType(IP_ADDRESS, ipAddress, sortIP);
|
||||
|
||||
this.stt = new SortableTable(tf.tbl, _sortTypes);
|
||||
|
@ -492,21 +499,21 @@ function usNumberConverter(s) {
|
|||
function euNumberConverter(s) {
|
||||
return unformatNb(s, FORMATTED_NUMBER_EU);
|
||||
}
|
||||
function dateConverter(s, format) {
|
||||
return formatDate(s, format);
|
||||
}
|
||||
function dmyDateConverter(s) {
|
||||
return dateConverter(s, 'DMY');
|
||||
}
|
||||
function mdyDateConverter(s) {
|
||||
return dateConverter(s, 'MDY');
|
||||
}
|
||||
function ymdDateConverter(s) {
|
||||
return dateConverter(s, 'YMD');
|
||||
}
|
||||
function ddmmmyyyyDateConverter(s) {
|
||||
return dateConverter(s, 'DDMMMYYYY');
|
||||
}
|
||||
// function dateConverter(s, format) {
|
||||
// return formatDate(s, format);
|
||||
// }
|
||||
// function dmyDateConverter(s) {
|
||||
// return dateConverter(s, 'DMY');
|
||||
// }
|
||||
// function mdyDateConverter(s) {
|
||||
// return dateConverter(s, 'MDY');
|
||||
// }
|
||||
// function ymdDateConverter(s) {
|
||||
// return dateConverter(s, 'YMD');
|
||||
// }
|
||||
// function ddmmmyyyyDateConverter(s) {
|
||||
// return dateConverter(s, 'DDMMMYYYY');
|
||||
// }
|
||||
|
||||
function ipAddress(value) {
|
||||
let vals = value.split('.');
|
||||
|
|
|
@ -1,38 +1,48 @@
|
|||
import {Date as SuDate} from 'sugar-date';
|
||||
import {Date as SugarDate} from 'sugar-date';
|
||||
import 'sugar-date/locales';
|
||||
import {isObj} from '../types';
|
||||
import {isObj, isArray} from '../types';
|
||||
|
||||
export class DateType {
|
||||
|
||||
constructor(tf) {
|
||||
this.tf = tf;
|
||||
this.locale = tf.locale;
|
||||
this.suDate = SuDate;
|
||||
this.datetime = SugarDate;
|
||||
this.emitter = tf.emitter;
|
||||
|
||||
// Global locale
|
||||
this.suDate.setLocale(this.locale);
|
||||
}
|
||||
|
||||
init() {
|
||||
// let locale = this.suDate.getLocale(this.locale);
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add formats from column types configuration
|
||||
// Global locale
|
||||
this.datetime.setLocale(this.locale);
|
||||
|
||||
// let locale = this.datetime.getLocale(this.locale);
|
||||
|
||||
// Add formats from column types configuration if any
|
||||
this._addConfigFormats();
|
||||
// locale.addFormat('{dd}/{MM}/{yyyy}');
|
||||
// locale.addFormat('{MM}/{dd}/{yyyy}');
|
||||
// locale.addFormat('{dd}-{months}-{yyyy|yy}');
|
||||
// locale.addFormat('{dd}-{MM}-{yyyy|yy}');
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
this.emitter.emit('date-type-initialized', this.tf, this);
|
||||
}
|
||||
|
||||
parse(dateStr, localeCode) {console.log('parse', localeCode);
|
||||
return this.suDate.create(dateStr, localeCode);
|
||||
parse(dateStr, localeCode) {
|
||||
// console.log('parse', dateStr, localeCode,
|
||||
// this.datetime.create(dateStr, localeCode));
|
||||
return this.datetime.create(dateStr, localeCode);
|
||||
}
|
||||
|
||||
isValid(dateStr, localeCode) {
|
||||
console.log(dateStr, localeCode, this.parse(dateStr, localeCode),
|
||||
this.suDate.isValid(this.parse(dateStr, localeCode)));
|
||||
return this.suDate.isValid(this.parse(dateStr, localeCode));
|
||||
// console.log(dateStr, localeCode, this.parse(dateStr, localeCode),
|
||||
// this.datetime.isValid(this.parse(dateStr, localeCode)));
|
||||
return this.datetime.isValid(this.parse(dateStr, localeCode));
|
||||
}
|
||||
|
||||
getOptions(colIndex) {
|
||||
|
@ -44,12 +54,21 @@ export class DateType {
|
|||
this.tf.colTypes.forEach((type, idx) => {
|
||||
let options = this.getOptions(idx);
|
||||
if (options.hasOwnProperty('format')) {
|
||||
let locale = this.suDate.getLocale(
|
||||
let locale = this.datetime.getLocale(
|
||||
options.locale || this.locale
|
||||
);
|
||||
console.log(options.format);
|
||||
locale.addFormat(options.format);
|
||||
if (isArray(options.format)) {
|
||||
options.format.forEach((format) => {
|
||||
locale.addFormat(format);
|
||||
});
|
||||
} else {
|
||||
locale.addFormat(options.format);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.initialized = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1793,8 +1793,7 @@ export class TableFilter {
|
|||
function hasArg(sA, cellData, colIdx) {
|
||||
sA = matchCase(sA, this.caseSensitive);
|
||||
|
||||
let occurence;
|
||||
let dateType = this.Mod.dateType;
|
||||
let occurence = false;
|
||||
// let dtType = this.hasColDateType ?
|
||||
// this.colDateType[colIdx] : this.defaultDateType;
|
||||
// let dtType = this.hasType(colIdx, [DATE]) ?
|
||||
|
@ -1822,53 +1821,64 @@ export class TableFilter {
|
|||
// let isGEDate=hasGE && isValidDate(sA.replace(re_ge, ''), dtType);
|
||||
// let isDFDate=hasDF && isValidDate(sA.replace(re_d, ''), dtType);
|
||||
// let isEQDate=hasEQ && isValidDate(sA.replace(re_eq, ''), dtType);
|
||||
let isLDate = hasLO && dateType.isValid(sA.replace(re_l, ''));
|
||||
let isLEDate = hasLE && dateType.isValid(sA.replace(re_le, ''));
|
||||
let isGDate = hasGR && dateType.isValid(sA.replace(re_g, ''));
|
||||
let isGEDate = hasGE && dateType.isValid(sA.replace(re_ge, ''));
|
||||
let isDFDate = hasDF && dateType.isValid(sA.replace(re_d, ''));
|
||||
let isEQDate = hasEQ && dateType.isValid(sA.replace(re_eq, ''));
|
||||
|
||||
let dte1, dte2;
|
||||
//dates
|
||||
if (this.hasType(colIdx, [DATE]) && dateType.isValid(cellData)
|
||||
if (this.hasType(colIdx, [DATE]) /*&& isValidDate(cellData)*/
|
||||
/*isValidDate(cellData, dtType)*/) {
|
||||
let dte1, dte2;
|
||||
let dateType = this.Mod.dateType;
|
||||
let isValidDate = dateType.isValid.bind(dateType);
|
||||
let parseDate = dateType.parse.bind(dateType);
|
||||
let locale = dateType.getOptions(colIdx).locale || this.locale;
|
||||
|
||||
let isLDate = hasLO &&
|
||||
isValidDate(sA.replace(re_l, ''), locale);
|
||||
let isLEDate = hasLE &&
|
||||
isValidDate(sA.replace(re_le, ''), locale);
|
||||
let isGDate = hasGR &&
|
||||
isValidDate(sA.replace(re_g, ''), locale);
|
||||
let isGEDate = hasGE &&
|
||||
isValidDate(sA.replace(re_ge, ''), locale);
|
||||
let isDFDate = hasDF &&
|
||||
isValidDate(sA.replace(re_d, ''), locale);
|
||||
let isEQDate = hasEQ &&
|
||||
isValidDate(sA.replace(re_eq, ''), locale);
|
||||
|
||||
// dte1 = formatDate(cellData, dtType);
|
||||
dte1 = dateType.parse(cellData, locale);
|
||||
dte1 = parseDate(cellData, locale);
|
||||
// lower date
|
||||
if (isLDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_l, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_l, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_l, ''), dtType);
|
||||
occurence = dte1 < dte2;
|
||||
}
|
||||
// lower equal date
|
||||
else if (isLEDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_le, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_le, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_le, ''), dtType);
|
||||
occurence = dte1 <= dte2;
|
||||
}
|
||||
// greater equal date
|
||||
else if (isGEDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_ge, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_ge, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_ge, ''), dtType);
|
||||
occurence = dte1 >= dte2;
|
||||
}
|
||||
// greater date
|
||||
else if (isGDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_g, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_g, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_g, ''), dtType);
|
||||
occurence = dte1 > dte2;
|
||||
}
|
||||
// different date
|
||||
else if (isDFDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_d, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_d, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_d, ''), dtType);
|
||||
occurence = dte1.toString() !== dte2.toString();
|
||||
}
|
||||
// equal date
|
||||
else if (isEQDate) {
|
||||
dte2 = dateType.parse(sA.replace(re_eq, ''), locale);
|
||||
dte2 = parseDate(sA.replace(re_eq, ''), locale);
|
||||
// dte2 = formatDate(sA.replace(re_eq, ''), dtType);
|
||||
occurence = dte1.toString() === dte2.toString();
|
||||
}
|
||||
|
@ -1877,10 +1887,10 @@ export class TableFilter {
|
|||
occurence = contains(sA.replace(re_lk, ''), cellData,
|
||||
false, this.caseSensitive);
|
||||
}
|
||||
else if (dateType.isValid(sA)
|
||||
else if (isValidDate(sA)
|
||||
/*isValidDate(sA, dtType)*/) {
|
||||
// dte2 = formatDate(sA, dtType);
|
||||
dte2 = dateType.parse(sA, locale);
|
||||
dte2 = parseDate(sA, locale);
|
||||
occurence = dte1.toString() === dte2.toString();
|
||||
}
|
||||
//empty
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
</ul>
|
||||
<p>
|
||||
Use the <code>col_types</code> property to set numeric formats
|
||||
('formatted-number', 'formatted-number-eu' or 'ipaddress') and <code>col_date_type</code> to set date
|
||||
types.
|
||||
('formatted-number', 'formatted-number-eu' or 'ipaddress') and date types.
|
||||
</p>
|
||||
|
||||
<!-- @import partials/pre.html -->
|
||||
|
@ -76,19 +75,16 @@ var tfConfig = {
|
|||
loader: true,
|
||||
status_bar: true,
|
||||
col_types: [
|
||||
null, null, null,
|
||||
'formatted-number-eu', 'formatted-number', null,
|
||||
{ type: 'date', locale: 'fr'/*, format: '{dd}/{MM}/{yyyy}'*/},
|
||||
{ type: 'date', locale: 'en'/*, format: '{MM}/{dd}/{yyyy}'*/},
|
||||
'string', 'string', 'string',
|
||||
'formatted-number-eu', 'formatted-number', 'string',
|
||||
{
|
||||
type: 'date', locale: 'fr'/*,
|
||||
format: ['{dd}/{MM}/{yyyy}', '{dd}-{MM}-{yyyy|yy}']*/
|
||||
},
|
||||
{ type: 'date', locale: 'en'/*, format: '{dd}-{MM}-{yyyy|yy}'*/ },
|
||||
'date',
|
||||
'ipaddress'
|
||||
],
|
||||
// col_date_type: [
|
||||
// null, null, null,
|
||||
// null, null, null,
|
||||
// 'dmy', 'mdy', 'ddmmmyyyy',
|
||||
// null
|
||||
// ],
|
||||
rows_always_visible: [totRowIndex],
|
||||
on_filters_loaded: function(o){
|
||||
o.setFilterValue(3, '>1.000');
|
||||
|
@ -132,7 +128,11 @@ var tf2Config = {
|
|||
btn_reset: true,
|
||||
loader: true,
|
||||
status_bar: true,
|
||||
default_date_type: 'YMD',
|
||||
locale: 'en-us',
|
||||
col_types: [
|
||||
'string', 'number', 'string',
|
||||
'number', 'string', 'date'
|
||||
],
|
||||
on_filters_loaded: function(o){
|
||||
o.setFilterValue(5, '>95-05-18');
|
||||
o.filter();
|
||||
|
|
Loading…
Reference in a new issue