From 0be164c99f82efa08de67bdc0b4f0271b279c7af Mon Sep 17 00:00:00 2001 From: Max Guglielmi Date: Wed, 21 Sep 2016 15:35:45 +1000 Subject: [PATCH] Fixed demos --- dist/tablefilter/style/colsVisibility.css | 2 +- dist/tablefilter/style/filtersVisibility.css | 2 +- dist/tablefilter/style/tablefilter.css | 2 +- .../style/themes/default/default.css | 2 +- .../style/themes/mytheme/mytheme.css | 2 +- .../style/themes/skyblue/skyblue.css | 2 +- dist/tablefilter/tablefilter.js | 184 ++++++++---------- dist/tablefilter/tf-1.js | 8 +- src/extensions/sort/adapterSortabletable.js | 9 +- src/tablefilter.js | 67 ++----- static/templates/columns-visibility.html | 10 +- static/templates/data-types.html | 39 ++-- static/templates/filter-images.html | 8 +- static/templates/theme-roller.html | 6 +- 14 files changed, 139 insertions(+), 204 deletions(-) diff --git a/dist/tablefilter/style/colsVisibility.css b/dist/tablefilter/style/colsVisibility.css index 2ac3ca42..ec9c33a3 100644 --- a/dist/tablefilter/style/colsVisibility.css +++ b/dist/tablefilter/style/colsVisibility.css @@ -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} \ No newline at end of file diff --git a/dist/tablefilter/style/filtersVisibility.css b/dist/tablefilter/style/filtersVisibility.css index 939b012f..fd3b0607 100644 --- a/dist/tablefilter/style/filtersVisibility.css +++ b/dist/tablefilter/style/filtersVisibility.css @@ -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} \ No newline at end of file diff --git a/dist/tablefilter/style/tablefilter.css b/dist/tablefilter/style/tablefilter.css index 5b79997c..232d960c 100644 --- a/dist/tablefilter/style/tablefilter.css +++ b/dist/tablefilter/style/tablefilter.css @@ -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} diff --git a/dist/tablefilter/style/themes/default/default.css b/dist/tablefilter/style/themes/default/default.css index b66d1bda..8c6c62b2 100644 --- a/dist/tablefilter/style/themes/default/default.css +++ b/dist/tablefilter/style/themes/default/default.css @@ -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} \ No newline at end of file diff --git a/dist/tablefilter/style/themes/mytheme/mytheme.css b/dist/tablefilter/style/themes/mytheme/mytheme.css index dcc5979b..522c5e71 100644 --- a/dist/tablefilter/style/themes/mytheme/mytheme.css +++ b/dist/tablefilter/style/themes/mytheme/mytheme.css @@ -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} \ No newline at end of file diff --git a/dist/tablefilter/style/themes/skyblue/skyblue.css b/dist/tablefilter/style/themes/skyblue/skyblue.css index 33278490..c3e0a2e4 100644 --- a/dist/tablefilter/style/themes/skyblue/skyblue.css +++ b/dist/tablefilter/style/themes/skyblue/skyblue.css @@ -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} \ No newline at end of file diff --git a/dist/tablefilter/tablefilter.js b/dist/tablefilter/tablefilter.js index e966f2e4..33327157 100644 --- a/dist/tablefilter/tablefilter.js +++ b/dist/tablefilter/tablefilter.js @@ -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]; diff --git a/dist/tablefilter/tf-1.js b/dist/tablefilter/tf-1.js index 1865a5c6..23e07628 100644 --- a/dist/tablefilter/tf-1.js +++ b/dist/tablefilter/tf-1.js @@ -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'; } } diff --git a/src/extensions/sort/adapterSortabletable.js b/src/extensions/sort/adapterSortabletable.js index dba4972b..eea8145e 100644 --- a/src/extensions/sort/adapterSortabletable.js +++ b/src/extensions/sort/adapterSortabletable.js @@ -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'; } } diff --git a/src/tablefilter.js b/src/tablefilter.js index ce1872c3..2a66dca9 100644 --- a/src/tablefilter.js +++ b/src/tablefilter.js @@ -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]; diff --git a/static/templates/columns-visibility.html b/static/templates/columns-visibility.html index 0ef7b3f1..b2f9c145 100644 --- a/static/templates/columns-visibility.html +++ b/static/templates/columns-visibility.html @@ -27,6 +27,10 @@ -

Below an example of ISO date support (YMD). Use default_date_type - to set a date type for a whole table ('DMY','MDY','YMD').

+

+ Below an example of ISO date support ({yyyy|yy}/{MM}/{dd}). + Use locale to set a locale globally + (defaults to 'en'). +