1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-20 23:36:39 +02:00

Fixed demos

This commit is contained in:
Max Guglielmi 2016-09-21 15:35:45 +10:00
parent 8fa502b2c4
commit 0be164c99f
14 changed files with 139 additions and 204 deletions

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.3.0 by Max Guglielmi
* build date: 2016-09-20T13:30:11.327Z
* build date: 2016-09-21T03:26:15.158Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

View file

@ -962,13 +962,12 @@ return /******/ (function(modules) { // webpackBootstrap
/*** data types ***/
this.locale = f.locale || 'en';
/**
* Define default date type (DMY)
* Define default locale, default to 'en' as per Sugar Date module:
* https://sugarjs.com/docs/#/DateLocales
* @type {String}
*/
this.defaultDateType = f.default_date_type || 'ISO8601';
this.locale = f.locale || 'en';
/**
* Define thousands separator ',' or '.', defaults to ','
@ -982,21 +981,6 @@ return /******/ (function(modules) { // webpackBootstrap
*/
this.decimalSeparator = f.decimal_separator || '.';
/**
* Determine whether table has columns with date types
* @type {Boolean}
* @private
*/
// this.hasColDateType = isArray(f.col_date_type);
/**
* Define date format on a column basis, possible values 'DMY', 'MDY',
* 'YMD', 'DDMMMYYYY', ie:
* col_date_type : [null, 'DMY', 'MDY', 'YMD', null, 'DDMMMYYYY']
* @type {Array}
*/
// this.colDateType = this.hasColDateType ? f.col_date_type : null;
/**
* Determine whether table has columns data types
* @type {Boolean}
@ -1006,10 +990,16 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* Define data types on a column basis, possible values 'string',
* 'number', 'formatted-number', 'formatted-number-eu', 'DMY', 'MDY',
* 'YMD', 'DDMMMYYYY', 'ipaddress' ie:
* col_types : ['formatted-number', 'DMY', 'MDY', 'YMD', null,
* 'DDMMMYYYY']
* 'number', 'formatted-number', 'date', 'ipaddress' ie:
* col_types : [
* 'string', 'date', 'number',
* { type: 'formatted-number', decimal: ',', thousands: '.' },
* { type: 'date', locale: 'en-gb' },
* { type: 'date', format: ['{dd}-{months}-{yyyy|yy}'] }
* ]
*
* Refer to https://sugarjs.com/docs/#/DateParsing for exhaustive
* information on date parsing formats supported by Sugar Date
* @type {Array}
*/
this.colTypes = this.hasColTypes ? f.col_types : [];
@ -2009,102 +1999,83 @@ return /******/ (function(modules) { // webpackBootstrap
hasNM = re_nm === sA,
hasRE = re_re.test(sA);
//Search arg dates tests
// let isLDate = hasLO && isValidDate(sA.replace(re_l, ''), dtType);
// let isLEDate=hasLE && isValidDate(sA.replace(re_le, ''), dtType);
// let isGDate = hasGR && isValidDate(sA.replace(re_g, ''), dtType);
// 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);
// Check for dates
if (this.hasType(colIdx, [_const.DATE])) {
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;
//dates
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;
// Search arg dates tests
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);
// Search arg dates tests
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 = parseDate(cellData, locale);
// lower date
if (isLDate) {
dte2 = parseDate(sA.replace(re_l, ''), locale);
// dte2 = formatDate(sA.replace(re_l, ''), dtType);
occurence = dte1 < dte2;
dte1 = parseDate(cellData, locale);
// lower date
if (isLDate) {
dte2 = parseDate(sA.replace(re_l, ''), locale);
occurence = dte1 < dte2;
}
// lower equal date
else if (isLEDate) {
dte2 = parseDate(sA.replace(re_le, ''), locale);
occurence = dte1 <= dte2;
}
// lower equal date
else if (isLEDate) {
dte2 = parseDate(sA.replace(re_le, ''), locale);
// dte2 = formatDate(sA.replace(re_le, ''), dtType);
occurence = dte1 <= dte2;
// greater equal date
else if (isGEDate) {
dte2 = parseDate(sA.replace(re_ge, ''), locale);
occurence = dte1 >= dte2;
}
// greater equal date
else if (isGEDate) {
dte2 = parseDate(sA.replace(re_ge, ''), locale);
// dte2 = formatDate(sA.replace(re_ge, ''), dtType);
occurence = dte1 >= dte2;
// greater date
else if (isGDate) {
dte2 = parseDate(sA.replace(re_g, ''), locale);
occurence = dte1 > dte2;
}
// greater date
else if (isGDate) {
dte2 = parseDate(sA.replace(re_g, ''), locale);
// dte2 = formatDate(sA.replace(re_g, ''), dtType);
occurence = dte1 > dte2;
// different date
else if (isDFDate) {
dte2 = parseDate(sA.replace(re_d, ''), locale);
occurence = dte1.toString() !== dte2.toString();
}
// different date
else if (isDFDate) {
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 = parseDate(sA.replace(re_eq, ''), locale);
occurence = dte1.toString() === dte2.toString();
}
// equal date
else if (isEQDate) {
dte2 = parseDate(sA.replace(re_eq, ''), locale);
// dte2 = formatDate(sA.replace(re_eq, ''), dtType);
occurence = dte1.toString() === dte2.toString();
}
// searched keyword with * operator doesn't have to be a date
else if (re_lk.test(sA)) {
// like date
occurence = (0, _string.contains)(sA.replace(re_lk, ''), cellData, false, this.caseSensitive);
} else if (isValidDate(sA)
/*isValidDate(sA, dtType)*/) {
// dte2 = formatDate(sA, dtType);
dte2 = parseDate(sA, locale);
occurence = dte1.toString() === dte2.toString();
// searched keyword with * operator doesn't have to be a date
else if (re_lk.test(sA)) {
// like date
occurence = (0, _string.contains)(sA.replace(re_lk, ''), cellData, false, this.caseSensitive);
} else if (isValidDate(sA)
/*isValidDate(sA, dtType)*/) {
// dte2 = formatDate(sA, dtType);
dte2 = parseDate(sA, locale);
occurence = dte1.toString() === dte2.toString();
}
//empty
else if (hasEM) {
occurence = (0, _string.isEmpty)(cellData);
}
//non-empty
else if (hasNM) {
occurence = !(0, _string.isEmpty)(cellData);
} else {
occurence = (0, _string.contains)(sA, cellData, this.isExactMatch(colIdx), this.caseSensitive);
}
//empty
else if (hasEM) {
occurence = (0, _string.isEmpty)(cellData);
}
//non-empty
else if (hasNM) {
occurence = !(0, _string.isEmpty)(cellData);
} else {
occurence = (0, _string.contains)(sA, cellData, this.isExactMatch(colIdx), this.caseSensitive);
}
} else {
} else {
if (this.hasType(colIdx, [_const.FORMATTED_NUMBER])) {
var colType = this.colTypes[colIdx];
if (colType.hasOwnProperty('decimal')) {
decimal = colType.decimal;
}
// numData = Number(cellData) ||parseNb(cellData, decimal);
}
// else {
// numData = Number(cellData) ||
// parseNb(cellData, tf.decimalSeparator);
// }
// Convert to number anyways to auto-resolve type in case not
// defined by configuration
numData = Number(cellData) || (0, _number.parse)(cellData, decimal);
// first checks if there is any operator (<,>,<=,>=,!,*,=,{,},
@ -2331,9 +2302,6 @@ return /******/ (function(modules) { // webpackBootstrap
continue;
}
var cellData = this.getCellData(cell[j]);
// let decimal = this.hasType(colIndex,
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU]) ?
// this.colTypes[colIndex] : undefined;
var decimal = this.decimalSeparator;
if (this.hasType(colIndex, [_const.FORMATTED_NUMBER])) {
var colType = this.colTypes[colIndex];

View file

@ -2834,7 +2834,7 @@ webpackJsonp([1],{
sortTypes = this.sortTypes,
_sortTypes = [];
for (var i = 0; i < tf.getCellsNb(); i++) {
for (var i = 0; i < tf.nbCells; i++) {
var colType = void 0;
if (sortTypes[i]) {
colType = sortTypes[i];
@ -2847,8 +2847,10 @@ webpackJsonp([1],{
}
} else {
colType = colType.toLowerCase();
// TODO: normalise 'none' vs 'None'
if (colType === _const.NONE) {
if (colType === _const.DATE) {
colType = this._addDateType(i, sortTypes);
} else if (colType === _const.NONE) {
// TODO: normalise 'none' vs 'None'
colType = 'None';
}
}

View file

@ -399,7 +399,7 @@ export default class AdapterSortableTable extends Feature {
sortTypes = this.sortTypes,
_sortTypes = [];
for (let i = 0; i < tf.getCellsNb(); i++) {
for (let i = 0; i < tf.nbCells; i++) {
let colType;
if (sortTypes[i]) {
colType = sortTypes[i];
@ -413,8 +413,11 @@ export default class AdapterSortableTable extends Feature {
}
} else {
colType = colType.toLowerCase();
// TODO: normalise 'none' vs 'None'
if (colType === NONE) {
if (colType === DATE) {
colType = this._addDateType(i, sortTypes);
}
else if (colType === NONE) {
// TODO: normalise 'none' vs 'None'
colType = 'None';
}
}

View file

@ -840,14 +840,12 @@ export class TableFilter {
/*** data types ***/
this.locale = f.locale || 'en';
/**
* Define default date type (DMY)
* Define default locale, default to 'en' as per Sugar Date module:
* https://sugarjs.com/docs/#/DateLocales
* @type {String}
*/
this.defaultDateType = f.default_date_type || 'ISO8601';
this.locale = f.locale || 'en';
/**
* Define thousands separator ',' or '.', defaults to ','
@ -861,21 +859,6 @@ export class TableFilter {
*/
this.decimalSeparator = f.decimal_separator || '.';
/**
* Determine whether table has columns with date types
* @type {Boolean}
* @private
*/
// this.hasColDateType = isArray(f.col_date_type);
/**
* Define date format on a column basis, possible values 'DMY', 'MDY',
* 'YMD', 'DDMMMYYYY', ie:
* col_date_type : [null, 'DMY', 'MDY', 'YMD', null, 'DDMMMYYYY']
* @type {Array}
*/
// this.colDateType = this.hasColDateType ? f.col_date_type : null;
/**
* Determine whether table has columns data types
* @type {Boolean}
@ -885,10 +868,16 @@ export class TableFilter {
/**
* Define data types on a column basis, possible values 'string',
* 'number', 'formatted-number', 'formatted-number-eu', 'DMY', 'MDY',
* 'YMD', 'DDMMMYYYY', 'ipaddress' ie:
* col_types : ['formatted-number', 'DMY', 'MDY', 'YMD', null,
* 'DDMMMYYYY']
* 'number', 'formatted-number', 'date', 'ipaddress' ie:
* col_types : [
* 'string', 'date', 'number',
* { type: 'formatted-number', decimal: ',', thousands: '.' },
* { type: 'date', locale: 'en-gb' },
* { type: 'date', format: ['{dd}-{months}-{yyyy|yy}'] }
* ]
*
* Refer to https://sugarjs.com/docs/#/DateParsing for exhaustive
* information on date parsing formats supported by Sugar Date
* @type {Array}
*/
this.colTypes = this.hasColTypes ? f.col_types : [];
@ -1811,17 +1800,8 @@ export class TableFilter {
hasNM = (re_nm === sA),
hasRE = re_re.test(sA);
//Search arg dates tests
// let isLDate = hasLO && isValidDate(sA.replace(re_l, ''), dtType);
// let isLEDate=hasLE && isValidDate(sA.replace(re_le, ''), dtType);
// let isGDate = hasGR && isValidDate(sA.replace(re_g, ''), dtType);
// 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);
//dates
if (this.hasType(colIdx, [DATE]) /*&& isValidDate(cellData)*/
/*isValidDate(cellData, dtType)*/) {
// Check for dates
if (this.hasType(colIdx, [DATE])) {
let dte1, dte2;
let dateType = this.Mod.dateType;
let isValidDate = dateType.isValid.bind(dateType);
@ -1842,42 +1822,35 @@ export class TableFilter {
let isEQDate = hasEQ &&
isValidDate(sA.replace(re_eq, ''), locale);
// dte1 = formatDate(cellData, dtType);
dte1 = parseDate(cellData, locale);
// lower date
if (isLDate) {
dte2 = parseDate(sA.replace(re_l, ''), locale);
// dte2 = formatDate(sA.replace(re_l, ''), dtType);
occurence = dte1 < dte2;
}
// lower equal date
else if (isLEDate) {
dte2 = parseDate(sA.replace(re_le, ''), locale);
// dte2 = formatDate(sA.replace(re_le, ''), dtType);
occurence = dte1 <= dte2;
}
// greater equal date
else if (isGEDate) {
dte2 = parseDate(sA.replace(re_ge, ''), locale);
// dte2 = formatDate(sA.replace(re_ge, ''), dtType);
occurence = dte1 >= dte2;
}
// greater date
else if (isGDate) {
dte2 = parseDate(sA.replace(re_g, ''), locale);
// dte2 = formatDate(sA.replace(re_g, ''), dtType);
occurence = dte1 > dte2;
}
// different date
else if (isDFDate) {
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 = parseDate(sA.replace(re_eq, ''), locale);
// dte2 = formatDate(sA.replace(re_eq, ''), dtType);
occurence = dte1.toString() === dte2.toString();
}
// searched keyword with * operator doesn't have to be a date
@ -1910,12 +1883,9 @@ export class TableFilter {
if (colType.hasOwnProperty('decimal')) {
decimal = colType.decimal;
}
// numData = Number(cellData) ||parseNb(cellData, decimal);
}
// else {
// numData = Number(cellData) ||
// parseNb(cellData, tf.decimalSeparator);
// }
// Convert to number anyways to auto-resolve type in case not
// defined by configuration
numData = Number(cellData) || parseNb(cellData, decimal);
// first checks if there is any operator (<,>,<=,>=,!,*,=,{,},
@ -2162,9 +2132,6 @@ export class TableFilter {
continue;
}
let cellData = this.getCellData(cell[j]);
// let decimal = this.hasType(colIndex,
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU]) ?
// this.colTypes[colIndex] : undefined;
let decimal = this.decimalSeparator;
if (this.hasType(colIndex, [FORMATTED_NUMBER])) {
let colType = this.colTypes[colIndex];

View file

@ -27,6 +27,10 @@
<script data-config>
var tfConfig = {
base_path: '../dist/tablefilter/',
col_types: [
'number', 'string', 'string',
'formatted-number', 'formatted-number', 'string'
],
paging: true,
state: {
types: ['cookie'],
@ -49,11 +53,7 @@ var tfConfig = {
text: 'Columns: ',
enable_tick_all: true
}, {
name: 'sort',
types: [
'number', 'string', 'string',
'formatted-number', 'none', 'string'
]
name: 'sort'
}
]
};

View file

@ -8,15 +8,17 @@
<h1>{NAME} v{VERSION}</h1>
<h2>Data types demo</h2>
<p>This example features 3 date types and 2 numeric formatting for the currency
columns:</p>
<p>
This example shows how to define column types with the
<code>col_types</code> option and specifically numeric formats with:
</p>
<ul>
<li>"." thousands separator and "," decimal separator for &euro;</li>
<li>"," thousands separator and "." decimal separator for US$</li>
<li>"." thousands separator and "," decimal separator for &euro; column</li>
<li>"," thousands separator and "." decimal separator for US$ column</li>
</ul>
<p>
Use the <code>col_types</code> property to set numeric formats
('formatted-number', 'formatted-number-eu' or 'ipaddress') and date types.
along with date types with <code>locale</code> and <code>format</code> specified on
a column basis.
</p>
<!-- @import partials/pre.html -->
@ -75,15 +77,13 @@ var tfConfig = {
loader: true,
status_bar: true,
col_types: [
'string', 'string', 'string',
{
type: 'formatted-number', decimal: ',', thousands: '.'
},
'formatted-number', 'string',
{
type: 'date', locale: 'fr'/*,
format: ['{dd}/{MM}/{yyyy}', '{dd}-{MM}-{yyyy|yy}']*/
},
'string',
'string',
'string',
{ type: 'formatted-number', decimal: ',', thousands: '.' },
'formatted-number', // defaults to '.' for decimal and ',' for thousands
'string',
{ type: 'date', locale: 'fr', },
{ type: 'date', locale: 'en', format: '{dd}-{MM}-{yyyy|yy}' },
{ type: 'date', locale: 'en', format: ['{dd}-{months}-{yyyy|yy}'] },
'ipaddress'
@ -117,8 +117,11 @@ tf.init();
</script>
<p>Below an example of ISO date support (YMD). Use <code>default_date_type</code>
to set a date type for a whole table ('DMY','MDY','YMD').</p>
<p>
Below an example of ISO date support ({yyyy|yy}/{MM}/{dd}).
Use <code>locale</code> to set a locale globally
(defaults to 'en').
</p>
<!-- @import partials/dummy-table.html -->
<script data-config>
@ -131,7 +134,7 @@ var tf2Config = {
btn_reset: true,
loader: true,
status_bar: true,
locale: 'en-us',
locale: 'en-US',
col_types: [
'string', 'number', 'string',
'number', 'string', 'date'

View file

@ -23,12 +23,8 @@ var tfConfig = {
filters_row_index: 2,
headers_row_index: 1,
col_types: [
null, null, null,
'number', null, null, null
],
col_date_type: [
null, null, null,
null, null, null, 'mdy'
'string', 'string', 'string',
'number', 'string', 'string', 'date'
],
rows_counter: true,
rows_counter_text: 'Books: ',

View file

@ -32,11 +32,7 @@ var tfConfig = {
sort: true,
col_types: [
'string', 'string', 'number',
'string', 'string', 'string'
],
col_date_type: [
null, null, null,
null, null, 'mdy'
'string', 'string', 'date'
],
rows_counter: true,
rows_counter_text: 'Books: ',