mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-10 02:16:40 +02:00
Added active columns test
This commit is contained in:
parent
36dd10fda8
commit
bbd8997651
3
dist/tablefilter/1-561b1935f281e51b728f.js
vendored
3
dist/tablefilter/1-561b1935f281e51b728f.js
vendored
File diff suppressed because one or more lines are too long
3
dist/tablefilter/1-b6f853f028e3df14c6c9.js
vendored
Normal file
3
dist/tablefilter/1-b6f853f028e3df14c6c9.js
vendored
Normal file
File diff suppressed because one or more lines are too long
9
dist/tablefilter/tablefilter.js
vendored
9
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
|
@ -98,6 +98,7 @@
|
|||
rows_counter: true,
|
||||
// enable_default_theme: true,
|
||||
help_instructions: true,
|
||||
mark_active_columns: true,
|
||||
on_keyup: false,
|
||||
loader: true,
|
||||
themes: [{ name: 'skyblue'}],
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
match_case: false,
|
||||
remember_grid_values: true,
|
||||
btn_reset: true,
|
||||
grid_layout: false,
|
||||
grid_layout: true,
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
|
@ -109,12 +109,10 @@
|
|||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
},
|
||||
}/*,
|
||||
extensions: [{
|
||||
/*** Columns Visibility Manager extension load ***/
|
||||
name: 'colsVisibility',
|
||||
description: 'Columns visibility manager',/*
|
||||
initialize: function(o){o.SetColsVisibility();}*/
|
||||
description: 'Columns visibility manager',
|
||||
// manager: true,
|
||||
tick_to_hide: true,
|
||||
// headers_table: true,
|
||||
|
@ -145,7 +143,7 @@
|
|||
// on_after_col_hidden: function(){ console.log('on_after_col_hidden',arguments); },
|
||||
// on_before_col_displayed: function(){ console.log('on_before_col_displayed',arguments); },
|
||||
// on_after_col_displayed: function(){ console.log('on_after_col_displayed',arguments); }
|
||||
}]
|
||||
}]*/
|
||||
});
|
||||
|
||||
tf.init();
|
||||
|
|
|
@ -34,11 +34,11 @@ export class GridLayout{
|
|||
//default col width
|
||||
this.gridDefaultColWidth = f.grid_default_col_width || '100px';
|
||||
//enables/disables columns resizer
|
||||
this.gridEnableColResizer = f.grid_enable_cols_resizer!==undefined ?
|
||||
f.grid_enable_cols_resizer : false;
|
||||
//defines col resizer script path
|
||||
this.gridColResizerPath = f.grid_cont_col_resizer_path ||
|
||||
this.basePath+'TFExt_ColsResizer/TFExt_ColsResizer.js';
|
||||
// this.gridEnableColResizer = f.grid_enable_cols_resizer!==undefined ?
|
||||
// f.grid_enable_cols_resizer : false;
|
||||
// //defines col resizer script path
|
||||
// this.gridColResizerPath = f.grid_cont_col_resizer_path ||
|
||||
// this.basePath+'TFExt_ColsResizer/TFExt_ColsResizer.js';
|
||||
|
||||
this.gridColElms = [];
|
||||
|
||||
|
|
|
@ -1071,7 +1071,7 @@ export class TableFilter{
|
|||
this.Cpt.colOps = new ColOps(this);
|
||||
this.Cpt.colOps.calc();
|
||||
}
|
||||
if(this.sort /*|| this.gridLayout*/){
|
||||
if(this.sort){
|
||||
this.importSort();
|
||||
}
|
||||
|
||||
|
@ -1308,8 +1308,8 @@ export class TableFilter{
|
|||
return;
|
||||
}
|
||||
let rows = this.tbl.rows,
|
||||
Cpt = this.Cpt,
|
||||
ExtRegistry = this.ExtRegistry;
|
||||
Cpt = this.Cpt/*,
|
||||
ExtRegistry = this.ExtRegistry*/;
|
||||
if(this.paging){
|
||||
Cpt.paging.destroy();
|
||||
}
|
||||
|
@ -1334,9 +1334,10 @@ export class TableFilter{
|
|||
if(this.highlightKeywords){
|
||||
Cpt.highlightKeyword.unhighlightAll();
|
||||
}
|
||||
if(this.sort){
|
||||
ExtRegistry.sort.destroy();
|
||||
}
|
||||
// if(this.sort){
|
||||
// console.log('sort.destroy',this.ExtRegistry, ExtRegistry.sort);
|
||||
// ExtRegistry.sort.destroy();
|
||||
// }
|
||||
if(this.loader){
|
||||
Cpt.loader.destroy();
|
||||
}
|
||||
|
@ -1723,8 +1724,8 @@ export class TableFilter{
|
|||
// search args re-init
|
||||
this.searchArgs = this.getFiltersValue();
|
||||
|
||||
let num_cell_data, nbFormat;
|
||||
let re_le = new RegExp(this.leOperator),
|
||||
var num_cell_data, nbFormat;
|
||||
var re_le = new RegExp(this.leOperator),
|
||||
re_ge = new RegExp(this.geOperator),
|
||||
re_l = new RegExp(this.lwOperator),
|
||||
re_g = new RegExp(this.grOperator),
|
||||
|
@ -1743,10 +1744,10 @@ export class TableFilter{
|
|||
function highlight(str, ok, cell){
|
||||
/*jshint validthis:true */
|
||||
if(this.highlightKeywords && ok){
|
||||
str = Str.replace(re_lk,'');
|
||||
str = Str.replace(re_eq,'');
|
||||
str = Str.replace(re_st,'');
|
||||
str = Str.replace(re_en,'');
|
||||
str = str.replace(re_lk, '');
|
||||
str = str.replace(re_eq, '');
|
||||
str = str.replace(re_st, '');
|
||||
str = str.replace(re_en, '');
|
||||
let w = str;
|
||||
if(re_le.test(str) || re_ge.test(str) || re_l.test(str) ||
|
||||
re_g.test(str) || re_d.test(str)){
|
||||
|
@ -1780,12 +1781,12 @@ export class TableFilter{
|
|||
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);
|
||||
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);
|
||||
|
||||
let dte1, dte2;
|
||||
//dates
|
||||
|
@ -2247,7 +2248,7 @@ export class TableFilter{
|
|||
for(let i=0; i<this.fltIds.length; i++){
|
||||
let fltType = this['col'+i];
|
||||
if(fltType === Str.lower(type)){
|
||||
let a = (bool) ? i : this.fltIds[i];
|
||||
let a = bool ? i : this.fltIds[i];
|
||||
arr.push(a);
|
||||
}
|
||||
}
|
||||
|
|
79
test/test-active-columns.html
Normal file
79
test/test-active-columns.html
Normal file
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>TableFilter active columns tests</title>
|
||||
<link rel="stylesheet" href="libs/qunit/qunit.css">
|
||||
<script src="libs/qunit/qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<table id="demo">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>From</th>
|
||||
<th>Destination</th>
|
||||
<th>Road Distance (km)</th>
|
||||
<th>By Air (hrs)</th>
|
||||
<th>By Rail (hrs)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Adelaide</td>
|
||||
<td>1412</td>
|
||||
<td>1.4</td>
|
||||
<td>25.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Brisbane</td>
|
||||
<td>982</td>
|
||||
<td>1.5</td>
|
||||
<td>16</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Canberra</td>
|
||||
<td>286</td>
|
||||
<td>.6</td>
|
||||
<td>4.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Melbourne</td>
|
||||
<td>872</td>
|
||||
<td>1.1</td>
|
||||
<td>10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Perth</td>
|
||||
<td>2781</td>
|
||||
<td>3.1</td>
|
||||
<td>38</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Alice Springs</td>
|
||||
<td>1533</td>
|
||||
<td>2</td>
|
||||
<td>20.25</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Brisbane</td>
|
||||
<td>2045</td>
|
||||
<td>2.15</td>
|
||||
<td>40</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script src="../dist/tablefilter/tablefilter.js"></script>
|
||||
<script src="test-active-columns.js"></script>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
83
test/test-active-columns.js
Normal file
83
test/test-active-columns.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
|
||||
(function(win, TableFilter){
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
mark_active_columns: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
module('Sanity checks');
|
||||
test('Active columns', function() {
|
||||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
});
|
||||
|
||||
test('Active columns', function() {
|
||||
tf.setFilterValue(1, 'Bri');
|
||||
tf.setFilterValue(3, '>2');
|
||||
tf.filter();
|
||||
var header1 = tf.getHeaderElement(1);
|
||||
var header3 = tf.getHeaderElement(3);
|
||||
deepEqual(
|
||||
header1.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
deepEqual(
|
||||
header3.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
});
|
||||
|
||||
test('Active columns with paging', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
mark_active_columns: true,
|
||||
paging: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
tf.setFilterValue(1, 'Bri');
|
||||
tf.setFilterValue(3, '>2');
|
||||
tf.filter();
|
||||
var header1 = tf.getHeaderElement(1);
|
||||
var header3 = tf.getHeaderElement(3);
|
||||
deepEqual(
|
||||
header1.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
deepEqual(
|
||||
header3.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
});
|
||||
|
||||
test('Grid layout active columns', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
mark_active_columns: true,
|
||||
grid_layout: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
tf.setFilterValue(1, 'Bri');
|
||||
tf.setFilterValue(3, '>2');
|
||||
tf.filter();
|
||||
var header1 = tf.getHeaderElement(1);
|
||||
var header3 = tf.getHeaderElement(3);
|
||||
deepEqual(
|
||||
header1.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
deepEqual(
|
||||
header3.className.indexOf('activeHeader') != -1,
|
||||
true,
|
||||
'Active filter indicator');
|
||||
|
||||
tf.destroy();
|
||||
});
|
||||
|
||||
})(window, TableFilter);
|
Loading…
Reference in a new issue