mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-10 02:16:40 +02:00
Turned colOps feature into an extension
This commit is contained in:
parent
c4ec282b15
commit
c174e13382
664
dist/tablefilter/tablefilter.js
vendored
664
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -113,7 +113,7 @@
|
|||
remember_grid_values: true,
|
||||
col_widths: ['150px','150px','150px','200px','150px'],
|
||||
btn_reset: true,
|
||||
grid_layout: true,
|
||||
grid_layout: false,
|
||||
rows_always_visible: [totRowIndex],
|
||||
custom_options: {
|
||||
cols: [3],
|
||||
|
@ -121,15 +121,15 @@
|
|||
values: [['>0 && <=0.5', '>0.5 && <=1', '>1 && <=2', '>2']],
|
||||
sorts: [false]
|
||||
},
|
||||
col_operation: {
|
||||
id: ["sum1", "sum2"],
|
||||
col: [2, 3],
|
||||
operation: ["sum", "mean"],
|
||||
write_method: ["innerhtml", 'innerhtml'],
|
||||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
},
|
||||
// col_operation: {
|
||||
// id: ["sum1", "sum2"],
|
||||
// col: [2, 3],
|
||||
// operation: ["sum", "mean"],
|
||||
// write_method: ["innerhtml", 'innerhtml'],
|
||||
// exclude_row: [totRowIndex],
|
||||
// decimal_precision: [0, 2],
|
||||
// tot_row_index: [totRowIndex, totRowIndex]
|
||||
// },
|
||||
// selectable: true,
|
||||
// editable: true,
|
||||
// ezEditTable_config: {
|
||||
|
@ -141,16 +141,23 @@
|
|||
{
|
||||
name: 'sort',
|
||||
types: ['string', 'string', 'number', 'number', 'number']
|
||||
// sort_config: {
|
||||
// sort_types: ['string','string','number','number','number']
|
||||
// }
|
||||
},{
|
||||
name: 'advancedGrid',
|
||||
vendor_path: '../libs/ezEditTable/',
|
||||
selectable: true,
|
||||
editable: true,
|
||||
default_selection: 'both',
|
||||
// loadStylesheet: true,
|
||||
auto_save: false
|
||||
},{
|
||||
name: 'colOps',
|
||||
id: ["sum1", "sum2"],
|
||||
col: [2, 3],
|
||||
operation: ["sum", "mean"],
|
||||
write_method: ["innerhtml", 'innerhtml'],
|
||||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
},{
|
||||
name: 'filtersVisibility',
|
||||
// enable_icon: true,
|
||||
|
|
|
@ -136,7 +136,8 @@ export default class AdapterEzEditTable {
|
|||
nextRowIndex,
|
||||
//pgup/pgdown keys
|
||||
d = (keyCode === 34 || keyCode === 33 ?
|
||||
(tf.Cpt.paging.pagingLength || et.nbRowsPerPage) : 1);
|
||||
(tf.feature('paging').pagingLength ||
|
||||
et.nbRowsPerPage) : 1);
|
||||
|
||||
//If next row is not valid, next valid filtered row needs to be
|
||||
//calculated
|
||||
|
@ -204,8 +205,8 @@ export default class AdapterEzEditTable {
|
|||
var row = et.defaultSelection !== 'row' ?
|
||||
selectedElm.parentNode : selectedElm;
|
||||
if(tf.paging){
|
||||
if(tf.Cpt.paging.nbPages > 1){
|
||||
var paging = tf.Cpt.paging;
|
||||
if(tf.feature('paging').nbPages > 1){
|
||||
var paging = tf.feature('paging');
|
||||
//page length is re-assigned in case it has changed
|
||||
et.nbRowsPerPage = paging.pagingLength;
|
||||
var validIndexes = tf.validRowsIndex,
|
||||
|
@ -237,8 +238,8 @@ export default class AdapterEzEditTable {
|
|||
|
||||
//Selected row needs to be visible when paging is activated
|
||||
if(tf.paging){
|
||||
tf.Cpt.paging.onAfterChangePage = function(paging){
|
||||
var advGrid = paging.tf.ExtRegistry.advancedGrid;
|
||||
tf.feature('paging').onAfterChangePage = function(paging){
|
||||
var advGrid = paging.tf.getExtension('advancedGrid');
|
||||
var et = advGrid._ezEditTable;
|
||||
var slc = et.Selection;
|
||||
var row = slc.GetActiveRow();
|
||||
|
@ -296,17 +297,17 @@ export default class AdapterEzEditTable {
|
|||
cfg.on_added_dom_row = function(){
|
||||
tf.nbFilterableRows++;
|
||||
if(!tf.paging){
|
||||
tf.Cpt.rowsCounter.refresh();
|
||||
tf.feature('rowsCounter').refresh();
|
||||
} else {
|
||||
tf.nbRows++;
|
||||
tf.nbVisibleRows++;
|
||||
tf.nbFilterableRows++;
|
||||
tf.paging=false;
|
||||
tf.Cpt.paging.destroy();
|
||||
tf.Cpt.paging.addPaging();
|
||||
tf.feature('paging').destroy();
|
||||
tf.feature('paging').addPaging();
|
||||
}
|
||||
if(tf.alternateBgs){
|
||||
tf.Cpt.alternateRows.init();
|
||||
tf.feature('alternateRows').init();
|
||||
}
|
||||
if(fnE){
|
||||
fnE.call(null, arguments[0], arguments[1], arguments[2]);
|
||||
|
@ -317,17 +318,17 @@ export default class AdapterEzEditTable {
|
|||
cfg.actions['delete'].on_after_submit = function(){
|
||||
tf.nbFilterableRows--;
|
||||
if(!tf.paging){
|
||||
tf.Cpt.rowsCounter.refresh();
|
||||
tf.feature('rowsCounter').refresh();
|
||||
} else {
|
||||
tf.nbRows--;
|
||||
tf.nbVisibleRows--;
|
||||
tf.nbFilterableRows--;
|
||||
tf.paging=false;
|
||||
tf.Cpt.paging.destroy();
|
||||
tf.Cpt.paging.addPaging(false);
|
||||
tf.feature('paging').destroy();
|
||||
tf.feature('paging').addPaging(false);
|
||||
}
|
||||
if(tf.alternateBgs){
|
||||
tf.Cpt.alternateRows.init();
|
||||
tf.feature('alternateRows').init();
|
||||
}
|
||||
if(fnF){
|
||||
fnF.call(null, arguments[0], arguments[1]);
|
||||
|
|
|
@ -1,30 +1,33 @@
|
|||
import Dom from '../dom';
|
||||
import Str from '../string';
|
||||
import Types from '../types';
|
||||
import Dom from '../../dom';
|
||||
import Str from '../../string';
|
||||
import Types from '../../types';
|
||||
|
||||
export class ColOps{
|
||||
export default class ColOps{
|
||||
|
||||
/**
|
||||
* Column calculations
|
||||
* @param {Object} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
var f = tf.config();
|
||||
this.colOperation = f.col_operation;
|
||||
constructor(tf, opts) {
|
||||
|
||||
//calls function before col operation
|
||||
this.onBeforeOperation = Types.isFn(f.on_before_operation) ?
|
||||
f.on_before_operation : null;
|
||||
this.onBeforeOperation = Types.isFn(opts.on_before_operation) ?
|
||||
opts.on_before_operation : null;
|
||||
//calls function after col operation
|
||||
this.onAfterOperation = Types.isFn(f.on_after_operation) ?
|
||||
f.on_after_operation : null;
|
||||
this.onAfterOperation = Types.isFn(opts.on_after_operation) ?
|
||||
opts.on_after_operation : null;
|
||||
|
||||
this.opts = opts;
|
||||
this.tf = tf;
|
||||
}
|
||||
|
||||
init(){
|
||||
this.calc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates columns' values
|
||||
* Configuration options are stored in 'colOperation' property
|
||||
* Configuration options are stored in 'opts' property
|
||||
* - 'id' contains ids of elements showing result (array)
|
||||
* - 'col' contains the columns' indexes (array)
|
||||
* - 'operation' contains operation type (array, values: 'sum', 'mean',
|
||||
|
@ -39,23 +42,24 @@ export class ColOps{
|
|||
* (2) added calculations for the median, lower and upper quartile.
|
||||
*/
|
||||
calc() {
|
||||
if(!this.tf.isFirstLoad && !this.tf.hasGrid()){
|
||||
var tf = this.tf;
|
||||
if(!tf.isFirstLoad && !tf.hasGrid()){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.onBeforeOperation){
|
||||
this.onBeforeOperation.call(null, this.tf);
|
||||
this.onBeforeOperation.call(null, tf);
|
||||
}
|
||||
|
||||
var colOperation = this.colOperation,
|
||||
labelId = colOperation.id,
|
||||
colIndex = colOperation.col,
|
||||
operation = colOperation.operation,
|
||||
outputType = colOperation.write_method,
|
||||
totRowIndex = colOperation.tot_row_index,
|
||||
excludeRow = colOperation.exclude_row,
|
||||
decimalPrecision = colOperation.decimal_precision !== undefined ?
|
||||
colOperation.decimal_precision : 2;
|
||||
var opts = this.opts,
|
||||
labelId = opts.id,
|
||||
colIndex = opts.col,
|
||||
operation = opts.operation,
|
||||
outputType = opts.write_method,
|
||||
totRowIndex = opts.tot_row_index,
|
||||
excludeRow = opts.exclude_row,
|
||||
decimalPrecision = Types.isUndef(opts.decimal_precision) ?
|
||||
2 : opts.decimal_precision;
|
||||
|
||||
//nuovella: determine unique list of columns to operate on
|
||||
var ucolIndex = [],
|
||||
|
@ -80,7 +84,7 @@ export class ColOps{
|
|||
if(Str.lower(typeof labelId)=='object' &&
|
||||
Str.lower(typeof colIndex)=='object' &&
|
||||
Str.lower(typeof operation)=='object'){
|
||||
var row = this.tf.tbl.rows,
|
||||
var rows = tf.tbl.rows,
|
||||
colvalues = [];
|
||||
|
||||
for(var ucol=0; ucol<=ucolMax; ucol++){
|
||||
|
@ -88,7 +92,7 @@ export class ColOps{
|
|||
//use ucolIndex because we only want to pass through this loop
|
||||
//once for each column get the values in this unique column
|
||||
colvalues.push(
|
||||
this.tf.getColValues(ucolIndex[ucol], true, excludeRow));
|
||||
tf.getColValues(ucolIndex[ucol], true, excludeRow));
|
||||
|
||||
//next: calculate all operations for this column
|
||||
var result,
|
||||
|
@ -294,7 +298,7 @@ export class ColOps{
|
|||
|
||||
// row(s) with result are always visible
|
||||
var totRow = totRowIndex && totRowIndex[ucol] ?
|
||||
row[totRowIndex[ucol]] : null;
|
||||
rows[totRowIndex[ucol]] : null;
|
||||
if(totRow){
|
||||
totRow.style.display = '';
|
||||
}
|
||||
|
@ -302,8 +306,10 @@ export class ColOps{
|
|||
}//if typeof
|
||||
|
||||
if(this.onAfterOperation){
|
||||
this.onAfterOperation.call(null, this.tf);
|
||||
this.onAfterOperation.call(null, tf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
destroy(){}
|
||||
|
||||
}
|
|
@ -113,7 +113,7 @@ export default class ColsVisibility{
|
|||
|
||||
//Grid layout compatibility
|
||||
if(tf.gridLayout){
|
||||
this.headersTbl = tf.Cpt.gridLayout.headTbl; //headers table
|
||||
this.headersTbl = tf.feature('gridLayout').headTbl; //headers table
|
||||
this.headersIndex = 0; //headers index
|
||||
this.onAfterColDisplayed = function(){};
|
||||
this.onAfterColHidden = function(){};
|
||||
|
@ -374,7 +374,7 @@ export default class ColsVisibility{
|
|||
//This event is fired just after a column is displayed for
|
||||
//grid_layout compatibility
|
||||
if(tf.gridLayout){
|
||||
gridLayout = tf.Cpt.gridLayout;
|
||||
gridLayout = tf.feature('gridLayout');
|
||||
headTbl = gridLayout.headTbl;
|
||||
gridColElms = gridLayout.gridColElms;
|
||||
if(Helpers.isIE()){
|
||||
|
@ -403,7 +403,7 @@ export default class ColsVisibility{
|
|||
//This event is fired just after a column is displayed for
|
||||
//grid_layout compatibility
|
||||
if(tf.gridLayout){
|
||||
gridLayout = tf.Cpt.gridLayout;
|
||||
gridLayout = tf.feature('gridLayout');
|
||||
headTbl = gridLayout.headTbl;
|
||||
gridColElms = gridLayout.gridColElms;
|
||||
gridColElms[colIndex].style.display = '';
|
||||
|
|
|
@ -139,7 +139,7 @@ export default class FiltersVisibility{
|
|||
*/
|
||||
toggle(){
|
||||
let tf = this.tf;
|
||||
let tbl = tf.gridLayout? tf.Cpt.gridLayout.headTbl : tf.tbl;
|
||||
let tbl = tf.gridLayout? tf.feature('gridLayout').headTbl : tf.tbl;
|
||||
let fltRow = tbl.rows[this.filtersRowIndex];
|
||||
let fltRowDisplay = fltRow.style.display;
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ export default class AdapterSortableTable{
|
|||
if(tf.paging){
|
||||
adpt.isPaged = true;
|
||||
tf.paging = false;
|
||||
tf.Cpt.paging.destroy();
|
||||
tf.feature('paging').destroy();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,7 @@ export default class AdapterSortableTable{
|
|||
if(Types.isUndef(removeOnly)){
|
||||
removeOnly = false;
|
||||
}
|
||||
let altRows = tf.Cpt.alternateRows,
|
||||
let altRows = tf.feature('alternateRows'),
|
||||
oddCls = altRows.oddCss,
|
||||
evenCls = altRows.evenCss;
|
||||
Dom.removeClass(row, oddCls);
|
||||
|
@ -142,7 +142,7 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
//sort behaviour for paging
|
||||
if(adpt.isPaged){
|
||||
let paginator = tf.Cpt.paging,
|
||||
let paginator = tf.feature('paging'),
|
||||
config = tf.config();
|
||||
if(paginator.hasResultsPerPage){
|
||||
let slc = paginator.resultsPerPageSlc;
|
||||
|
@ -216,7 +216,7 @@ export default class AdapterSortableTable{
|
|||
let stt = this;
|
||||
if (!stt.tHead){
|
||||
if(tf.gridLayout){
|
||||
stt.tHead = tf.Cpt.gridLayout.headTbl.tHead;
|
||||
stt.tHead = tf.feature('gridLayout').headTbl.tHead;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ export class CheckList{
|
|||
var tf = this.tf;
|
||||
var chkCt = this.addTChecks(colIndex, ul);
|
||||
var fltArr = []; //remember grid values
|
||||
var store = tf.Cpt.store;
|
||||
var store = tf.feature('store');
|
||||
var tmpVal = store ?
|
||||
store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null;
|
||||
if(tmpVal && Str.trim(tmpVal).length > 0){
|
||||
|
|
|
@ -91,7 +91,8 @@ export class Dropdown{
|
|||
/*** remember grid values ***/
|
||||
var fltsValues = [], fltArr = [];
|
||||
if(tf.rememberGridValues){
|
||||
fltsValues = tf.Cpt.store.getFilterValues(tf.fltsValuesCookie);
|
||||
fltsValues =
|
||||
tf.feature('store').getFilterValues(tf.fltsValuesCookie);
|
||||
if(fltsValues && !Str.isEmpty(fltsValues.toString())){
|
||||
if(this.isCustom){
|
||||
fltArr.push(fltsValues[colIndex]);
|
||||
|
|
|
@ -43,8 +43,8 @@ export class Help{
|
|||
this.helpInstrBtnEl = null;
|
||||
//help content div
|
||||
this.helpInstrContEl = null;
|
||||
this.helpInstrDefaultHtml = '<div class="helpFooter"><h4>HTML Table ' +
|
||||
'Filter Generator v. '+ tf.version +'</h4>' +
|
||||
this.helpInstrDefaultHtml = '<div class="helpFooter"><h4>TableFilter ' +
|
||||
'v. '+ tf.version +'</h4>' +
|
||||
'<a href="http://tablefilter.free.fr" target="_blank">' +
|
||||
'http://tablefilter.free.fr</a><br/>' +
|
||||
'<span>©2009-'+ tf.year +' Max Guglielmi.</span>' +
|
||||
|
|
|
@ -83,7 +83,8 @@ export class Loader{
|
|||
}
|
||||
var tf = this.tf,
|
||||
targetEl = !this.loaderTgtId ?
|
||||
(tf.gridLayout ? tf.Cpt.gridLayout.tblCont : tf.tbl.parentNode):
|
||||
(tf.gridLayout ?
|
||||
tf.feature('gridLayout').tblCont : tf.tbl.parentNode):
|
||||
Dom.id(this.loaderTgtId);
|
||||
targetEl.removeChild(this.loaderDiv);
|
||||
this.loaderDiv = null;
|
||||
|
|
|
@ -424,6 +424,7 @@ export class Paging{
|
|||
*/
|
||||
groupByPage(validRows){
|
||||
var tf = this.tf;
|
||||
var alternateRows = tf.feature('alternateRows');
|
||||
var rows = tf.tbl.rows;
|
||||
var paging_end_row = parseInt(this.startPagingRow, 10) +
|
||||
parseInt(this.pagingLength, 10);
|
||||
|
@ -436,18 +437,19 @@ export class Paging{
|
|||
//this loop shows valid rows of current page
|
||||
for(var h=0; h<tf.validRowsIndex.length; h++){
|
||||
var r = rows[tf.validRowsIndex[h]];
|
||||
|
||||
if(h>=this.startPagingRow && h<paging_end_row){
|
||||
if(r.getAttribute('validRow')==='true' ||
|
||||
!r.getAttribute('validRow')){
|
||||
r.style.display = '';
|
||||
}
|
||||
if(tf.alternateBgs && tf.Cpt.alternateRows){
|
||||
tf.Cpt.alternateRows.setRowBg(tf.validRowsIndex[h], h);
|
||||
if(tf.alternateBgs && alternateRows){
|
||||
alternateRows.setRowBg(tf.validRowsIndex[h], h);
|
||||
}
|
||||
} else {
|
||||
r.style.display = 'none';
|
||||
if(tf.alternateBgs && tf.Cpt.alternateRows){
|
||||
tf.Cpt.alternateRows.removeRowBg(tf.validRowsIndex[h]);
|
||||
if(tf.alternateBgs && alternateRows){
|
||||
alternateRows.removeRowBg(tf.validRowsIndex[h]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -626,7 +628,7 @@ export class Paging{
|
|||
}
|
||||
|
||||
if(tf.rememberPageNb){
|
||||
tf.Cpt.store.savePageNb(tf.pgNbCookie);
|
||||
tf.feature('store').savePageNb(tf.pgNbCookie);
|
||||
}
|
||||
this.startPagingRow = (this.pageSelectorType===tf.fltTypeSlc) ?
|
||||
this.pagingSlc.value : (index*this.pagingLength);
|
||||
|
@ -668,7 +670,7 @@ export class Paging{
|
|||
this.pagingSlc.options[slcIndex].selected = true;
|
||||
}
|
||||
if(tf.rememberPageLen){
|
||||
tf.Cpt.store.savePageLength(tf.pgLenCookie);
|
||||
tf.feature('store').savePageLength(tf.pgLenCookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -678,7 +680,7 @@ export class Paging{
|
|||
*/
|
||||
_resetPage(name){
|
||||
var tf = this.tf;
|
||||
var pgnb = tf.Cpt.store.getPageNb(name);
|
||||
var pgnb = tf.feature('store').getPageNb(name);
|
||||
if(pgnb!==''){
|
||||
this.changePage((pgnb-1));
|
||||
}
|
||||
|
@ -692,7 +694,7 @@ export class Paging{
|
|||
if(!tf.paging){
|
||||
return;
|
||||
}
|
||||
var pglenIndex = tf.Cpt.store.getPageLength(name);
|
||||
var pglenIndex = tf.feature('store').getPageLength(name);
|
||||
|
||||
if(pglenIndex!==''){
|
||||
this.resultsPerPageSlc.options[pglenIndex].selected = true;
|
||||
|
|
|
@ -103,7 +103,7 @@ export class RowsCounter{
|
|||
(tf.hasVisibleRows ? tf.visibleRows.length : 0);
|
||||
}
|
||||
} else {
|
||||
var paging = tf.Cpt.paging;
|
||||
var paging = tf.feature('paging');
|
||||
if(paging){
|
||||
//paging start row
|
||||
var paging_start_row = parseInt(paging.startPagingRow, 10) +
|
||||
|
|
|
@ -62,7 +62,7 @@ export class Store{
|
|||
savePageNb(name){
|
||||
Cookie.write(
|
||||
name,
|
||||
this.tf.Cpt.paging.currentPageNb,
|
||||
this.tf.feature('paging').currentPageNb,
|
||||
this.duration
|
||||
);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ export class Store{
|
|||
savePageLength(name){
|
||||
Cookie.write(
|
||||
name,
|
||||
this.tf.Cpt.paging.resultsPerPageSlc.selectedIndex,
|
||||
this.tf.feature('paging').resultsPerPageSlc.selectedIndex,
|
||||
this.duration
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
/* ------------------------------------------------------------------------
|
||||
- HTML Table Filter Generator v0.0.1
|
||||
- By Max Guglielmi (tablefilter.free.fr)
|
||||
- Licensed under the MIT License
|
||||
---------------------------------------------------------------------------
|
||||
- Special credit to:
|
||||
Cedric Wartel, cnx.claude@free.fr, Florent Hirchy, Váry Péter,
|
||||
Anthony Maes, Nuovella Williams, Fuggerbit, Venkata Seshagiri Rao
|
||||
Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution
|
||||
and/or inspiration
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
import Event from './event';
|
||||
import Dom from './dom';
|
||||
import Str from './string';
|
||||
|
@ -33,7 +21,6 @@ import {Paging} from './modules/paging';
|
|||
import {ClearButton} from './modules/clearButton';
|
||||
import {Help} from './modules/help';
|
||||
import {AlternateRows} from './modules/alternateRows';
|
||||
import {ColOps} from './modules/colOps';
|
||||
|
||||
var global = window,
|
||||
isValidDate = DateHelper.isValid,
|
||||
|
@ -189,8 +176,6 @@ export class TableFilter{
|
|||
//defines widths of columns
|
||||
this.hasColWidths = Types.isArray(f.col_widths);
|
||||
this.colWidths = this.hasColWidths ? f.col_widths : null;
|
||||
//tbody height if fixed headers enabled
|
||||
this.tBodyH = !isNaN(f.tbody_height) ? f.tbody_height : 200;
|
||||
//defines css class for filters
|
||||
this.fltCssClass = f.flt_css_class || 'flt';
|
||||
//defines css class for multiple selects filters
|
||||
|
@ -222,9 +207,6 @@ export class TableFilter{
|
|||
this.activeFlt = null;
|
||||
//id of active filter
|
||||
this.activeFilterId = null;
|
||||
//enables/disbles column operation(sum,mean)
|
||||
this.hasColOperation = Boolean(f.col_operation);
|
||||
this.colOperation = null;
|
||||
//enables always visible rows
|
||||
this.hasVisibleRows = Boolean(f.rows_always_visible);
|
||||
//array containing always visible rows
|
||||
|
@ -472,28 +454,26 @@ export class TableFilter{
|
|||
this.themesPath = f.themes_path || this.stylePath + 'themes/';
|
||||
|
||||
// Features registry
|
||||
this.Cpt = {
|
||||
loader: null,
|
||||
alternateRows: null,
|
||||
colOps: null,
|
||||
rowsCounter: null,
|
||||
gridLayout: null,
|
||||
store: null,
|
||||
highlightKeywords: null,
|
||||
paging: null,
|
||||
checkList: null,
|
||||
dropdown: null,
|
||||
popupFilter: null,
|
||||
clearButton: null,
|
||||
help: null,
|
||||
statusBar: null
|
||||
this.Mod = {
|
||||
// loader: null,
|
||||
// alternateRows: null,
|
||||
// rowsCounter: null,
|
||||
// gridLayout: null,
|
||||
// store: null,
|
||||
// highlightKeywords: null,
|
||||
// paging: null,
|
||||
// checkList: null,
|
||||
// dropdown: null,
|
||||
// popupFilter: null,
|
||||
// clearButton: null,
|
||||
// help: null,
|
||||
// statusBar: null
|
||||
};
|
||||
|
||||
// Extensions registry
|
||||
this.ExtRegistry = {};
|
||||
|
||||
/*** TF events ***/
|
||||
// let o = this;
|
||||
this.Evt = {
|
||||
name: {
|
||||
filter: 'Filter',
|
||||
|
@ -615,7 +595,7 @@ export class TableFilter{
|
|||
// select is populated when element has focus
|
||||
if(this.fillSlcOnDemand && elm.getAttribute('filled') === '0'){
|
||||
let ct = elm.getAttribute('ct');
|
||||
this.Cpt.dropdown._build(ct);
|
||||
this.Mod.dropdown._build(ct);
|
||||
}
|
||||
if(this.popUpFilters){
|
||||
Event.cancel(_ev);
|
||||
|
@ -644,9 +624,9 @@ export class TableFilter{
|
|||
let elm = Event.target(_ev);
|
||||
if(this.fillSlcOnDemand && elm.getAttribute('filled') === '0'){
|
||||
let ct = elm.getAttribute('ct');
|
||||
this.Cpt.checkList._build(ct);
|
||||
this.Cpt.checkList.checkListDiv[ct].onclick = null;
|
||||
this.Cpt.checkList.checkListDiv[ct].title = '';
|
||||
this.Mod.checkList._build(ct);
|
||||
this.Mod.checkList.checkListDiv[ct].onclick = null;
|
||||
this.Mod.checkList.checkListDiv[ct].title = '';
|
||||
}
|
||||
},
|
||||
/*====================================================
|
||||
|
@ -679,6 +659,8 @@ export class TableFilter{
|
|||
this.gridLayout)){
|
||||
this.headersRow = 0;
|
||||
}
|
||||
|
||||
let Mod = this.Mod;
|
||||
let n = this.singleSearchFlt ? 1 : this.nbCells,
|
||||
inpclass;
|
||||
|
||||
|
@ -694,29 +676,29 @@ export class TableFilter{
|
|||
|
||||
if(this.rememberGridValues || this.rememberPageNb ||
|
||||
this.rememberPageLen){
|
||||
this.Cpt.store = new Store(this);
|
||||
Mod.store = new Store(this);
|
||||
}
|
||||
|
||||
if(this.gridLayout){
|
||||
this.Cpt.gridLayout = new GridLayout(this);
|
||||
this.Cpt.gridLayout.init();
|
||||
Mod.gridLayout = new GridLayout(this);
|
||||
Mod.gridLayout.init();
|
||||
}
|
||||
|
||||
if(this.loader){
|
||||
if(!this.Cpt.loader){
|
||||
this.Cpt.loader = new Loader(this);
|
||||
if(!Mod.loader){
|
||||
Mod.loader = new Loader(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.highlightKeywords){
|
||||
this.Cpt.highlightKeyword = new HighlightKeyword(this);
|
||||
Mod.highlightKeyword = new HighlightKeyword(this);
|
||||
}
|
||||
|
||||
if(this.popUpFilters){
|
||||
if(!this.Cpt.popupFilter){
|
||||
this.Cpt.popupFilter = new PopupFilter(this);
|
||||
if(!Mod.popupFilter){
|
||||
Mod.popupFilter = new PopupFilter(this);
|
||||
}
|
||||
this.Cpt.popupFilter.init();
|
||||
Mod.popupFilter.init();
|
||||
}
|
||||
|
||||
//filters grid is not generated
|
||||
|
@ -763,7 +745,7 @@ export class TableFilter{
|
|||
for(let i=0; i<n; i++){// this loop adds filters
|
||||
|
||||
if(this.popUpFilters){
|
||||
this.Cpt.popupFilter.build(i);
|
||||
Mod.popupFilter.build(i);
|
||||
}
|
||||
|
||||
let fltcell = Dom.create(this.fltCellTag),
|
||||
|
@ -789,10 +771,10 @@ export class TableFilter{
|
|||
|
||||
//drop-down filters
|
||||
if(col===this.fltTypeSlc || col===this.fltTypeMulti){
|
||||
if(!this.Cpt.dropdown){
|
||||
this.Cpt.dropdown = new Dropdown(this);
|
||||
if(!Mod.dropdown){
|
||||
Mod.dropdown = new Dropdown(this);
|
||||
}
|
||||
let dropdown = this.Cpt.dropdown;
|
||||
let dropdown = Mod.dropdown;
|
||||
|
||||
let slc = Dom.create(this.fltTypeSlc,
|
||||
['id', this.prfxFlt+i+'_'+this.id],
|
||||
|
@ -837,8 +819,8 @@ export class TableFilter{
|
|||
// checklist
|
||||
else if(col===this.fltTypeCheckList){
|
||||
let checkList;
|
||||
this.Cpt.checkList = new CheckList(this);
|
||||
checkList = this.Cpt.checkList;
|
||||
Mod.checkList = new CheckList(this);
|
||||
checkList = Mod.checkList;
|
||||
|
||||
let divCont = Dom.create('div',
|
||||
['id', checkList.prfxCheckListDiv+i+'_'+this.id],
|
||||
|
@ -901,7 +883,7 @@ export class TableFilter{
|
|||
Event.add(inp, 'blur', this.Evt.onInpBlur.bind(this));
|
||||
|
||||
if(this.rememberGridValues){
|
||||
let flts_values = this.Cpt.store.getFilterValues(
|
||||
let flts_values = this.Mod.store.getFilterValues(
|
||||
this.fltsValuesCookie);
|
||||
if(flts_values[i]!=' '){
|
||||
this.setFilterValue(i, flts_values[i], false);
|
||||
|
@ -935,41 +917,34 @@ export class TableFilter{
|
|||
|
||||
/* Filter behaviours */
|
||||
if(this.rowsCounter){
|
||||
this.Cpt.rowsCounter = new RowsCounter(this);
|
||||
this.Cpt.rowsCounter.init();
|
||||
Mod.rowsCounter = new RowsCounter(this);
|
||||
Mod.rowsCounter.init();
|
||||
}
|
||||
if(this.statusBar){
|
||||
this.Cpt.statusBar = new StatusBar(this);
|
||||
this.Cpt.statusBar.init();
|
||||
Mod.statusBar = new StatusBar(this);
|
||||
Mod.statusBar.init();
|
||||
}
|
||||
if(this.paging || (this.Cpt.paging && this.Cpt.paging.isPagingRemoved)){
|
||||
this.Cpt.paging = new Paging(this);
|
||||
this.Cpt.paging.init();
|
||||
if(this.paging || (Mod.paging && Mod.paging.isPagingRemoved)){
|
||||
Mod.paging = new Paging(this);
|
||||
Mod.paging.init();
|
||||
}
|
||||
if(this.btnReset){
|
||||
this.Cpt.clearButton = new ClearButton(this);
|
||||
this.Cpt.clearButton.init();
|
||||
Mod.clearButton = new ClearButton(this);
|
||||
Mod.clearButton.init();
|
||||
}
|
||||
if(this.helpInstructions){
|
||||
if(!this.Cpt.help){
|
||||
this.Cpt.help = new Help(this);
|
||||
if(!Mod.help){
|
||||
Mod.help = new Help(this);
|
||||
}
|
||||
this.Cpt.help.init();
|
||||
Mod.help.init();
|
||||
}
|
||||
if(this.hasColWidths && !this.gridLayout){
|
||||
this.setColWidths();
|
||||
}
|
||||
if(this.alternateBgs){
|
||||
this.Cpt.alternateRows = new AlternateRows(this);
|
||||
this.Cpt.alternateRows.init();
|
||||
Mod.alternateRows = new AlternateRows(this);
|
||||
Mod.alternateRows.init();
|
||||
}
|
||||
if(this.hasColOperation){
|
||||
this.Cpt.colOps = new ColOps(this);
|
||||
this.Cpt.colOps.calc();
|
||||
}
|
||||
// if(this.sort){
|
||||
// this.importSort();
|
||||
// }
|
||||
|
||||
this.isFirstLoad = false;
|
||||
this._hasGrid = true;
|
||||
|
@ -985,7 +960,7 @@ export class TableFilter{
|
|||
}
|
||||
|
||||
if(this.loader){
|
||||
this.Cpt.loader.show('none');
|
||||
Mod.loader.show('none');
|
||||
}
|
||||
|
||||
/* Loads extensions */
|
||||
|
@ -996,7 +971,6 @@ export class TableFilter{
|
|||
if(this.onFiltersLoaded){
|
||||
this.onFiltersLoaded.call(null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1010,7 +984,7 @@ export class TableFilter{
|
|||
let slcExternal = cfg.slcExternal;
|
||||
let slcId = cfg.slcId;
|
||||
let pgIndex = cfg.pgIndex;
|
||||
let cpt = this.Cpt;
|
||||
let cpt = this.Mod;
|
||||
|
||||
function efx(){
|
||||
/*jshint validthis:true */
|
||||
|
@ -1057,9 +1031,6 @@ export class TableFilter{
|
|||
case ev.loadthemes:
|
||||
this._loadThemes();
|
||||
break;
|
||||
// default: //to be used by extensions events when needed
|
||||
// this['_'+evt].call(null, o, s);
|
||||
// break;
|
||||
}
|
||||
if(this.statusBar){
|
||||
cpt.statusBar.message('');
|
||||
|
@ -1082,6 +1053,15 @@ export class TableFilter{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a feature instance for a given name
|
||||
* @param {String} name Name of the feature
|
||||
* @return {Object}
|
||||
*/
|
||||
feature(name){
|
||||
return this.Mod[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise all the extensions defined in the configuration object
|
||||
*/
|
||||
|
@ -1123,6 +1103,24 @@ export class TableFilter{
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an extension instance
|
||||
* @param {String} name Name of the extension
|
||||
* @return {Object} Extension instance
|
||||
*/
|
||||
getExtension(name){
|
||||
return this.ExtRegistry[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check passed extension name exists
|
||||
* @param {String} name Name of the extension
|
||||
* @return {Boolean}
|
||||
*/
|
||||
hasExtension(name){
|
||||
return !Types.isUndef(this.ExtRegistry[name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all the extensions defined in the configuration object
|
||||
*/
|
||||
|
@ -1201,7 +1199,7 @@ export class TableFilter{
|
|||
return;
|
||||
}
|
||||
let rows = this.tbl.rows,
|
||||
Cpt = this.Cpt;
|
||||
Mod = this.Mod;
|
||||
|
||||
if(this.isExternalFlt && !this.popUpFilters){
|
||||
this.removeExternalFlts();
|
||||
|
@ -1210,7 +1208,7 @@ export class TableFilter{
|
|||
this.removeToolbar();
|
||||
}
|
||||
if(this.highlightKeywords){
|
||||
Cpt.highlightKeyword.unhighlightAll();
|
||||
Mod.highlightKeyword.unhighlightAll();
|
||||
}
|
||||
if(this.markActiveColumns){
|
||||
this.clearActiveColumns();
|
||||
|
@ -1222,24 +1220,14 @@ export class TableFilter{
|
|||
//this loop shows all rows and removes validRow attribute
|
||||
for(let j=this.refRow; j<this.nbRows; j++){
|
||||
rows[j].style.display = '';
|
||||
// try{
|
||||
if(rows[j].hasAttribute('validRow')){
|
||||
rows[j].removeAttribute('validRow');
|
||||
}
|
||||
// } catch(e) {
|
||||
// //ie<=6 doesn't support hasAttribute method
|
||||
// let row = rows[j];
|
||||
// let attribs = row.attributes;
|
||||
// for(let x=0, len=attribs.length; x<len; x++){
|
||||
// if(Str.lower(attribs.nodeName)==='validrow'){
|
||||
// row.removeAttribute('validRow');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if(rows[j].hasAttribute('validRow')){
|
||||
rows[j].removeAttribute('validRow');
|
||||
}
|
||||
|
||||
//removes alternating colors
|
||||
if(this.alternateBgs){
|
||||
Cpt.alternateRows.removeRowBg(j);
|
||||
Mod.alternateRows.removeRowBg(j);
|
||||
}
|
||||
|
||||
}//for j
|
||||
|
@ -1249,9 +1237,9 @@ export class TableFilter{
|
|||
this.tbl.deleteRow(this.filtersRowIndex);
|
||||
}
|
||||
|
||||
// Destroy extensions
|
||||
Object.keys(Cpt).forEach(function(key) {
|
||||
var feature = Cpt[key];
|
||||
// Destroy module
|
||||
Object.keys(Mod).forEach(function(key) {
|
||||
var feature = Mod[key];
|
||||
if(feature && Types.isFn(feature.destroy)){
|
||||
feature.destroy();
|
||||
}
|
||||
|
@ -1282,7 +1270,7 @@ export class TableFilter{
|
|||
}
|
||||
//grid-layout
|
||||
else if(this.gridLayout){
|
||||
let gridLayout = this.Cpt.gridLayout;
|
||||
let gridLayout = this.Mod.gridLayout;
|
||||
gridLayout.tblMainCont.appendChild(infdiv);
|
||||
infdiv.className = gridLayout.gridInfDivCssClass;
|
||||
}
|
||||
|
@ -1317,10 +1305,10 @@ export class TableFilter{
|
|||
// Enable help instructions by default if topbar is generated and not
|
||||
// explicitely set to false
|
||||
if(Types.isUndef(this.helpInstructions)){
|
||||
if(!this.Cpt.help){
|
||||
this.Cpt.help = new Help(this);
|
||||
if(!this.Mod.help){
|
||||
this.Mod.help = new Help(this);
|
||||
}
|
||||
this.Cpt.help.init();
|
||||
this.Mod.help.init();
|
||||
this.helpInstructions = true;
|
||||
}
|
||||
}
|
||||
|
@ -1453,11 +1441,11 @@ export class TableFilter{
|
|||
if(this.rememberGridValues && this.fillSlcOnDemand){
|
||||
this._resetGridValues(this.fltsValuesCookie);
|
||||
}
|
||||
if(this.rememberPageLen && this.Cpt.paging){
|
||||
this.Cpt.paging.resetPageLength(this.pgLenCookie);
|
||||
if(this.rememberPageLen && this.Mod.paging){
|
||||
this.Mod.paging.resetPageLength(this.pgLenCookie);
|
||||
}
|
||||
if(this.rememberPageNb && this.Cpt.paging){
|
||||
this.Cpt.paging.resetPage(this.pgNbCookie);
|
||||
if(this.rememberPageNb && this.Mod.paging){
|
||||
this.Mod.paging.resetPage(this.pgNbCookie);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1470,7 +1458,7 @@ export class TableFilter{
|
|||
if(!this.fillSlcOnDemand){
|
||||
return;
|
||||
}
|
||||
let fltsValues = this.Cpt.store.getFilterValues(name),
|
||||
let fltsValues = this.Mod.store.getFilterValues(name),
|
||||
slcFltsIndex = this.getFiltersByType(this.fltTypeSlc, true),
|
||||
multiFltsIndex = this.getFiltersByType(this.fltTypeMulti, true);
|
||||
|
||||
|
@ -1514,7 +1502,7 @@ export class TableFilter{
|
|||
}// if multiFltsIndex
|
||||
}
|
||||
else if(fltType===this.fltTypeCheckList){
|
||||
let checkList = this.Cpt.checkList;
|
||||
let checkList = this.Mod.checkList;
|
||||
let divChk = checkList.checkListDiv[i];
|
||||
divChk.title = divChk.innerHTML;
|
||||
divChk.innerHTML = '';
|
||||
|
@ -1547,7 +1535,7 @@ export class TableFilter{
|
|||
}//end for
|
||||
|
||||
if(!this.hasStoredValues && this.paging){
|
||||
this.Cpt.paging.setPagingInfo();
|
||||
this.Mod.paging.setPagingInfo();
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
@ -1571,7 +1559,7 @@ export class TableFilter{
|
|||
}
|
||||
|
||||
let row = this.tbl.rows,
|
||||
Cpt = this.Cpt,
|
||||
Mod = this.Mod,
|
||||
// f = this.cfg,
|
||||
hiddenrows = 0;
|
||||
|
||||
|
@ -1579,11 +1567,11 @@ export class TableFilter{
|
|||
|
||||
// removes keyword highlighting
|
||||
if(this.highlightKeywords){
|
||||
Cpt.highlightKeyword.unhighlightAll();
|
||||
Mod.highlightKeyword.unhighlightAll();
|
||||
}
|
||||
//removes popup filters active icons
|
||||
if(this.popUpFilters){
|
||||
Cpt.popupFilter.buildIcons();
|
||||
Mod.popupFilter.buildIcons();
|
||||
}
|
||||
//removes active column header class
|
||||
if(this.markActiveColumns){
|
||||
|
@ -1622,8 +1610,8 @@ export class TableFilter{
|
|||
w = Dom.getText(cell);
|
||||
}
|
||||
if(w !== ''){
|
||||
Cpt.highlightKeyword.highlight(
|
||||
cell, w, Cpt.highlightKeyword.highlightCssClass);
|
||||
Mod.highlightKeyword.highlight(
|
||||
cell, w, Mod.highlightKeyword.highlightCssClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1877,7 +1865,7 @@ export class TableFilter{
|
|||
singleFltRowValid = true;
|
||||
}
|
||||
if(this.popUpFilters){
|
||||
Cpt.popupFilter.buildIcon(j, true);
|
||||
Mod.popupFilter.buildIcon(j, true);
|
||||
}
|
||||
if(this.markActiveColumns){
|
||||
if(k === this.refRow){
|
||||
|
@ -1911,7 +1899,7 @@ export class TableFilter{
|
|||
this.validateRow(k, true);
|
||||
this.validRowsIndex.push(k);
|
||||
if(this.alternateBgs){
|
||||
Cpt.alternateRows.setRowBg(k, this.validRowsIndex.length);
|
||||
Mod.alternateRows.setRowBg(k, this.validRowsIndex.length);
|
||||
}
|
||||
if(this.onRowValidated){
|
||||
this.onRowValidated.call(null, this, k);
|
||||
|
@ -1924,7 +1912,7 @@ export class TableFilter{
|
|||
this.isStartBgAlternate = false;
|
||||
|
||||
if(this.rememberGridValues){
|
||||
Cpt.store.saveFilterValues(this.fltsValuesCookie);
|
||||
Mod.store.saveFilterValues(this.fltsValuesCookie);
|
||||
}
|
||||
//applies filter props after filtering process
|
||||
if(!this.paging){
|
||||
|
@ -1932,7 +1920,7 @@ export class TableFilter{
|
|||
} else {
|
||||
this.startPagingRow = 0;
|
||||
this.currentPageNb = 1;
|
||||
Cpt.paging.setPagingInfo(this.validRowsIndex);
|
||||
Mod.paging.setPagingInfo(this.validRowsIndex);
|
||||
}
|
||||
//invokes onafter callback
|
||||
if(this.onAfterFilter){
|
||||
|
@ -1954,16 +1942,17 @@ export class TableFilter{
|
|||
}
|
||||
}
|
||||
|
||||
let Cpt = this.Cpt;
|
||||
let Mod = this.Mod;
|
||||
|
||||
//shows rows always visible
|
||||
if(this.visibleRows){
|
||||
this.enforceVisibility();
|
||||
}
|
||||
//makes operation on a col
|
||||
if(this.hasColOperation){
|
||||
Cpt.colOps.calc();
|
||||
//columns operations
|
||||
if(this.hasExtension('colOps')){
|
||||
this.getExtension('colOps').calc();
|
||||
}
|
||||
|
||||
//re-populates drop-down filters
|
||||
if(this.linkedFilters){
|
||||
this.linkFilters();
|
||||
|
@ -1972,11 +1961,11 @@ export class TableFilter{
|
|||
this.nbVisibleRows - this.visibleRows.length : this.nbVisibleRows;
|
||||
//refreshes rows counter
|
||||
if(this.rowsCounter){
|
||||
Cpt.rowsCounter.refresh(nr);
|
||||
Mod.rowsCounter.refresh(nr);
|
||||
}
|
||||
|
||||
if(this.popUpFilters){
|
||||
Cpt.popupFilter.closeAll();
|
||||
Mod.popupFilter.closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2220,7 +2209,7 @@ export class TableFilter{
|
|||
filteredData = [];
|
||||
if(includeHeaders){
|
||||
let table = this.gridLayout ?
|
||||
this.Cpt.gridLayout.headTbl : this.tbl,
|
||||
this.Mod.gridLayout.headTbl : this.tbl,
|
||||
r = table.rows[this.headersRow],
|
||||
rowData = [r.rowIndex, []];
|
||||
for(let j=0; j<this.nbCells; j++){
|
||||
|
@ -2383,11 +2372,11 @@ export class TableFilter{
|
|||
Dom.getText(lbl), this.caseSensitive);
|
||||
if(lblTxt !== '' && Arr.has(sarg, lblTxt, true)){
|
||||
chk.checked = true;
|
||||
this.Cpt.checkList.setCheckListValues(chk);
|
||||
this.Mod.checkList.setCheckListValues(chk);
|
||||
}
|
||||
else{
|
||||
chk.checked = false;
|
||||
this.Cpt.checkList.setCheckListValues(chk);
|
||||
this.Mod.checkList.setCheckListValues(chk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2557,7 +2546,7 @@ export class TableFilter{
|
|||
slcSelectedValue === this.displayAllText ){
|
||||
|
||||
if(Arr.has(slcA3, slcIndex[i])){
|
||||
this.Cpt.checkList.checkListDiv[slcIndex[i]].innerHTML = '';
|
||||
this.Mod.checkList.checkListDiv[slcIndex[i]].innerHTML = '';
|
||||
} else {
|
||||
curSlc.innerHTML = '';
|
||||
}
|
||||
|
@ -2571,9 +2560,9 @@ export class TableFilter{
|
|||
}
|
||||
|
||||
if(Arr.has(slcA3, slcIndex[i])){
|
||||
this.Cpt.checkList._build(slcIndex[i]);
|
||||
this.Mod.checkList._build(slcIndex[i]);
|
||||
} else {
|
||||
this.Cpt.dropdown._build(slcIndex[i], true);
|
||||
this.Mod.dropdown._build(slcIndex[i], true);
|
||||
}
|
||||
|
||||
this.setFilterValue(slcIndex[i],slcSelectedValue);
|
||||
|
@ -2589,7 +2578,7 @@ export class TableFilter{
|
|||
return;
|
||||
}
|
||||
|
||||
let Cpt = this.Cpt;
|
||||
let Mod = this.Mod;
|
||||
let tbl = this.tbl;
|
||||
let rows = tbl.rows;
|
||||
let filtersRowIndex = this.filtersRowIndex;
|
||||
|
@ -2618,10 +2607,10 @@ export class TableFilter{
|
|||
colFltType !== this.fltTypeInp){
|
||||
if(colFltType === this.fltTypeSlc ||
|
||||
colFltType === this.fltTypeMulti){
|
||||
Cpt.dropdown.build(ct);
|
||||
Mod.dropdown.build(ct);
|
||||
}
|
||||
if(colFltType === this.fltTypeCheckList){
|
||||
Cpt.checkList.build(ct);
|
||||
Mod.checkList.build(ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2630,18 +2619,11 @@ export class TableFilter{
|
|||
this.nbFilterableRows = this.getRowsNb();
|
||||
this.nbVisibleRows = this.nbFilterableRows;
|
||||
this.nbRows = rows.length;
|
||||
// if(this.isSortEnabled){
|
||||
// this.sort = true;
|
||||
// }
|
||||
|
||||
// if(filtersRow.innerHTML === ''){
|
||||
// refreshFilters(this);
|
||||
// } else {
|
||||
if(this.popUpFilters){
|
||||
this.headersRow++;
|
||||
Cpt.popupFilter.buildAll();
|
||||
Mod.popupFilter.buildAll();
|
||||
}
|
||||
// }
|
||||
|
||||
/*** ie bug work-around, filters need to be re-generated since row
|
||||
is empty; insertBefore method doesn't seem to work properly
|
||||
|
@ -2653,7 +2635,7 @@ export class TableFilter{
|
|||
// o.isFirstLoad = true;
|
||||
// if(o.popUpFilters){
|
||||
// // o.RemovePopupFilters();
|
||||
// o.Cpt.popupFilter.destroy();
|
||||
// o.Mod.popupFilter.destroy();
|
||||
// }
|
||||
// o.init();
|
||||
// }
|
||||
|
@ -2859,7 +2841,7 @@ export class TableFilter{
|
|||
* @return {Object}
|
||||
*/
|
||||
getHeaderElement(colIndex){
|
||||
let table = this.gridLayout ? this.Cpt.gridLayout.headTbl : this.tbl;
|
||||
let table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl;
|
||||
let tHead = Dom.tag(table, 'thead');
|
||||
let headersRow = this.headersRow;
|
||||
let header;
|
||||
|
@ -2906,20 +2888,19 @@ export class TableFilter{
|
|||
}
|
||||
|
||||
TableFilter.Cookie = Cookie;
|
||||
TableFilter.Store = Store;
|
||||
TableFilter.GridLayout = GridLayout;
|
||||
TableFilter.Loader = Loader;
|
||||
TableFilter.HighlightKeyword = HighlightKeyword;
|
||||
TableFilter.PopupFilter = PopupFilter;
|
||||
TableFilter.Dropdown = Dropdown;
|
||||
TableFilter.CheckList = CheckList;
|
||||
TableFilter.RowsCounter = RowsCounter;
|
||||
TableFilter.StatusBar = StatusBar;
|
||||
// TableFilter.Store = Store;
|
||||
// TableFilter.GridLayout = GridLayout;
|
||||
// TableFilter.Loader = Loader;
|
||||
// TableFilter.HighlightKeyword = HighlightKeyword;
|
||||
// TableFilter.PopupFilter = PopupFilter;
|
||||
// TableFilter.Dropdown = Dropdown;
|
||||
// TableFilter.CheckList = CheckList;
|
||||
// TableFilter.RowsCounter = RowsCounter;
|
||||
// TableFilter.StatusBar = StatusBar;
|
||||
TableFilter.Paging = Paging;
|
||||
TableFilter.ClearButton = ClearButton;
|
||||
TableFilter.Help = Help;
|
||||
TableFilter.AlternateRows = AlternateRows;
|
||||
TableFilter.ColOps = ColOps;
|
||||
// TableFilter.ClearButton = ClearButton;
|
||||
// TableFilter.Help = Help;
|
||||
// TableFilter.AlternateRows = AlternateRows;
|
||||
|
||||
//Firefox does not support outerHTML property
|
||||
// function setOuterHtml(){
|
||||
|
|
|
@ -7,5 +7,9 @@ tf.init();
|
|||
|
||||
module('Sanity checks');
|
||||
test('AlternateRows component', function() {
|
||||
deepEqual(typeof tf.Cpt.alternateRows, 'object', 'AlternateRows instanciated');
|
||||
deepEqual(
|
||||
typeof tf.feature('alternateRows'),
|
||||
'object',
|
||||
'AlternateRows instanciated'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var checkList = tf.Cpt.checkList;
|
||||
var checkList = tf.feature('checkList');
|
||||
module('Sanity checks');
|
||||
test('CheckList component', function() {
|
||||
deepEqual(typeof checkList, 'object', 'CheckList instanciated');
|
||||
|
|
|
@ -5,7 +5,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var clearButton = tf.Cpt.clearButton;
|
||||
var clearButton = tf.feature('clearButton');
|
||||
module('Sanity checks');
|
||||
test('Clear button component', function() {
|
||||
deepEqual(typeof clearButton, 'object', 'ClearButton instanciated');
|
||||
|
@ -22,17 +22,17 @@ test('ClearButton UI elements', function() {
|
|||
module('Destroy and re-init');
|
||||
test('Remove UI', function() {
|
||||
clearButton.destroy();
|
||||
var btnResetEl = tf.Cpt.clearButton.btnResetEl;
|
||||
var btnResetEl = tf.feature('clearButton').btnResetEl;
|
||||
deepEqual(btnResetEl, null, 'Clear button is removed');
|
||||
});
|
||||
|
||||
test('Re-set UI', function() {
|
||||
tf.enableIcons = false;
|
||||
tf.Cpt.clearButton.btnResetHtml = null;
|
||||
tf.Cpt.clearButton.btnResetText = 'Clear';
|
||||
tf.Cpt.clearButton.init();
|
||||
tf.feature('clearButton').btnResetHtml = null;
|
||||
tf.feature('clearButton').btnResetText = 'Clear';
|
||||
tf.feature('clearButton').init();
|
||||
|
||||
var btnResetEl = tf.Cpt.clearButton.btnResetEl;
|
||||
var btnResetEl = tf.feature('clearButton').btnResetEl;
|
||||
deepEqual(btnResetEl.nodeName, 'A', 'Clear button tag changed');
|
||||
deepEqual(btnResetEl.innerText, 'Clear', 'Clear button text');
|
||||
});
|
||||
|
|
|
@ -6,7 +6,8 @@ var totRowIndex = table.getElementsByTagName('tr').length;
|
|||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
rows_always_visible: [totRowIndex],
|
||||
col_operation: {
|
||||
extensions: [{
|
||||
name: 'colOps',
|
||||
id: ['sum1', 'sum2'],
|
||||
col: [2, 3],
|
||||
operation: ['sum', 'mean'],
|
||||
|
@ -14,13 +15,56 @@ var tf = new TableFilter('demo', {
|
|||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
}
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
module('Sanity checks');
|
||||
test('Column Operations component', function() {
|
||||
deepEqual(typeof tf.Cpt.colOps, 'object', 'ColOps instanciated');
|
||||
test('Column operations', function() {
|
||||
var colOps = tf.getExtension('colOps');
|
||||
deepEqual(typeof colOps, 'object', 'ColOps instanciated');
|
||||
equal(id('sum1').innerHTML, 9911, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.69, 'Mean result');
|
||||
});
|
||||
|
||||
module('Behaviour checks');
|
||||
test('Column operations after filtering', function() {
|
||||
tf.setFilterValue(0, 'syd');
|
||||
tf.filter();
|
||||
equal(id('sum1').innerHTML, 3552, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.15, 'Mean result');
|
||||
tf.clearFilters();
|
||||
});
|
||||
|
||||
module('Behaviour checks with grid layout');
|
||||
test('Column operations', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
totRowIndex = totRowIndex-2;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
grid_layout: true,
|
||||
rows_always_visible: [totRowIndex],
|
||||
extensions: [{
|
||||
name: 'colOps',
|
||||
id: ['sum1', 'sum2'],
|
||||
col: [2, 3],
|
||||
operation: ['sum', 'mean'],
|
||||
write_method: ['innerhtml', 'innerhtml'],
|
||||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
equal(id('sum1').innerHTML, 9911, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.69, 'Mean result');
|
||||
|
||||
tf.setFilterValue(2, '>1000');
|
||||
tf.filter();
|
||||
equal(id('sum1').innerHTML, 7771, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 2.16, 'Mean result');
|
||||
|
||||
tf.destroy();
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
sort: false
|
||||
});
|
||||
tf.init();
|
||||
var cols = tf.Cpt.gridLayout.headTbl.getElementsByTagName('col');
|
||||
var cols = tf.feature('gridLayout').headTbl.getElementsByTagName('col');
|
||||
deepEqual(cols[0].style.width, '150px', 'Expected column width');
|
||||
deepEqual(cols[4].style.width, '200px', 'Expected column width');
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var dropdown = tf.Cpt.dropdown;
|
||||
var dropdown = tf.feature('dropdown');
|
||||
module('Sanity checks');
|
||||
test('Drop-down component', function() {
|
||||
deepEqual(typeof dropdown, 'object', 'DropDown instanciated');
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
module('Sanity checks');
|
||||
test('Filters visibility extension', function() {
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
notEqual(ext, null, 'Extension instanciated');
|
||||
deepEqual(ext.initialized, true, 'Extension initialized');
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
module('Check UI');
|
||||
test('UI elements', function() {
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
var cont = ext.contEl;
|
||||
var btn = ext.btnEl;
|
||||
deepEqual(cont.nodeName, 'SPAN', 'Container element');
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
module('Check behaviours');
|
||||
test('Toggle filters', function() {
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
ext.toggle();
|
||||
var filtersRow = tf.tbl.rows[tf.getFiltersRowIndex()];
|
||||
deepEqual(filtersRow.style.display, 'none', 'Filters hidden');
|
||||
|
@ -43,7 +43,7 @@
|
|||
});
|
||||
|
||||
test('Remove extension', function() {
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
ext.destroy();
|
||||
deepEqual(ext.contEl, null, 'Container element removed');
|
||||
deepEqual(ext.btnEl, null, 'Button element removed');
|
||||
|
@ -60,7 +60,7 @@
|
|||
}]
|
||||
});
|
||||
tf.init();
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
deepEqual(ext.contEl.nodeName, 'SPAN', 'Container element');
|
||||
deepEqual(ext.btnEl.nodeName, 'A', 'Button element');
|
||||
deepEqual(ext.btnEl.innerHTML, 'Toggle filters', 'Expected text');
|
||||
|
@ -78,7 +78,7 @@
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
var btn = ext.btnEl;
|
||||
deepEqual(
|
||||
extTargetElement.firstChild.nodeName, 'SPAN', 'Container element');
|
||||
|
@ -98,8 +98,8 @@
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var ext = tf.ExtRegistry.filtersVisibility;
|
||||
var gridLayout = tf.Cpt.gridLayout;
|
||||
var ext = tf.getExtension('filtersVisibility');
|
||||
var gridLayout = tf.feature('gridLayout');
|
||||
var filtersRow = gridLayout.headTbl.rows[tf.getFiltersRowIndex()];
|
||||
var cont = ext.contEl;
|
||||
var btn = ext.btnEl;
|
||||
|
|
|
@ -6,7 +6,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var gridLayout = tf.Cpt.gridLayout;
|
||||
var gridLayout = tf.feature('gridLayout');
|
||||
module('Sanity checks');
|
||||
test('GridLayout component', function() {
|
||||
deepEqual(typeof gridLayout, 'object', 'GridLayout instanciated');
|
||||
|
|
|
@ -5,7 +5,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var help = tf.Cpt.help;
|
||||
var help = tf.feature('help');
|
||||
module('Sanity checks');
|
||||
test('Clear button component', function() {
|
||||
deepEqual(typeof help, 'object', 'Help instanciated');
|
||||
|
@ -30,10 +30,11 @@ test('Remove UI', function() {
|
|||
});
|
||||
|
||||
test('Re-set UI', function() {
|
||||
tf.Cpt.help.destroy();
|
||||
tf.Cpt.help.helpInstrBtnText = '→Help←';
|
||||
tf.Cpt.help.helpInstrText = 'Hello world!';
|
||||
tf.Cpt.help.init();
|
||||
var help = tf.feature('help');
|
||||
help.destroy();
|
||||
help.helpInstrBtnText = '→Help←';
|
||||
help.helpInstrText = 'Hello world!';
|
||||
help.init();
|
||||
|
||||
var container = help.helpInstrContEl,
|
||||
helpBtn = help.helpInstrBtnEl;
|
||||
|
|
|
@ -5,7 +5,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var highlightKeyword = tf.Cpt.highlightKeyword;
|
||||
var highlightKeyword = tf.feature('highlightKeyword');
|
||||
module('Sanity checks');
|
||||
test('HighlightKeyword component', function() {
|
||||
deepEqual(typeof highlightKeyword, 'object', 'Instanciated');
|
||||
|
|
|
@ -7,7 +7,7 @@ tf.init();
|
|||
|
||||
module('Sanity checks');
|
||||
test('Loader component', function() {
|
||||
var loader = tf.Cpt.loader;
|
||||
var loader = tf.feature('loader');
|
||||
notEqual(loader, null, 'Loader instanciated');
|
||||
notEqual(
|
||||
document.getElementById(loader.prfxLoader+tf.id),
|
||||
|
|
|
@ -9,7 +9,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var paging = tf.Cpt.paging;
|
||||
var paging = tf.feature('paging');
|
||||
module('Sanity checks');
|
||||
test('Paging component', function() {
|
||||
notEqual(paging, null, 'Paging instanciated');
|
||||
|
|
|
@ -9,7 +9,7 @@ var tf = new TableFilter('demo', {
|
|||
});
|
||||
tf.init();
|
||||
|
||||
var popupFilter = tf.Cpt.popupFilter;
|
||||
var popupFilter = tf.feature('popupFilter');
|
||||
module('Sanity checks');
|
||||
test('Pop-up filter component', function() {
|
||||
notEqual(popupFilter, null, 'PopupFilter instanciated');
|
||||
|
@ -20,8 +20,8 @@ module('UI elements');
|
|||
test('Pop-up filter UI elements', function() {
|
||||
var flt1 = id(tf.fltIds[3]);
|
||||
var flt2 = id(tf.fltIds[2]);
|
||||
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||
var fltIcn2 = tf.Cpt.popupFilter.popUpFltImgs[2];
|
||||
var fltIcn1 = tf.feature('popupFilter').popUpFltImgs[3];
|
||||
var fltIcn2 = tf.feature('popupFilter').popUpFltImgs[2];
|
||||
notEqual(flt1, null, 'Filter element exists');
|
||||
notEqual(flt2, null, 'Filter element exists');
|
||||
deepEqual(flt2.hasAttribute('multiple'), true, 'Multiple select exists');
|
||||
|
@ -31,14 +31,14 @@ test('Pop-up filter UI elements', function() {
|
|||
|
||||
test('TableFilter removed', function() {
|
||||
tf.destroy();
|
||||
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||
var fltIcn1 = tf.feature('popupFilter').popUpFltImgs[3];
|
||||
deepEqual(fltIcn1, undefined, 'Filter icon is removed');
|
||||
deepEqual(id(tf.fltIds[3]), null, 'Filter is removed');
|
||||
});
|
||||
|
||||
test('TableFilter re-initialised', function() {
|
||||
tf.init();
|
||||
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||
var fltIcn1 = tf.feature('popupFilter').popUpFltImgs[3];
|
||||
deepEqual(fltIcn1.nodeName, 'IMG', 'Filter icon exists');
|
||||
deepEqual(id(tf.fltIds[3]).nodeName, 'SELECT', 'Filter exists');
|
||||
});
|
||||
|
|
|
@ -7,18 +7,18 @@ tf.init();
|
|||
|
||||
module('Sanity checks');
|
||||
test('RowsCounter component', function() {
|
||||
notEqual(tf.Cpt.rowsCounter, null, 'RowsCounter instanciated');
|
||||
notEqual(tf.feature('rowsCounter'), null, 'RowsCounter instanciated');
|
||||
});
|
||||
|
||||
test('RowsCounter component with paging', function() {
|
||||
tf.Cpt.paging = new TableFilter.Paging(tf);
|
||||
var paging = tf.Cpt.paging;
|
||||
tf.Mod.paging = new TableFilter.Paging(tf);
|
||||
var paging = tf.Mod.paging;
|
||||
paging.addPaging();
|
||||
equal(tf.Cpt.rowsCounter.rowsCounterSpan.innerHTML, '1-7 / 7', 'Counter value with paging');
|
||||
equal(tf.feature('rowsCounter').rowsCounterSpan.innerHTML, '1-7 / 7', 'Counter value with paging');
|
||||
paging.destroy();
|
||||
});
|
||||
|
||||
test('RowsCounter component without paging', function() {
|
||||
tf.Cpt.rowsCounter.refresh();
|
||||
equal(tf.Cpt.rowsCounter.rowsCounterSpan.innerHTML, 7, 'Counter value');
|
||||
tf.feature('rowsCounter').refresh();
|
||||
equal(tf.feature('rowsCounter').rowsCounterSpan.innerHTML, 7, 'Counter value');
|
||||
});
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
var StatusBar = TableFilter.StatusBar;
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
status_bar: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var statusBar = tf.Cpt.statusBar;
|
||||
var statusBar = tf.feature('statusBar');
|
||||
module('Sanity checks');
|
||||
test('Status bar component', function() {
|
||||
deepEqual(statusBar instanceof StatusBar, true, 'StatusBar type');
|
||||
deepEqual(typeof statusBar, 'object', 'StatusBar instantiated');
|
||||
notEqual(statusBar.statusBarDiv, null, 'statusBarDiv property');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
var Store = TableFilter.Store;
|
||||
var Cookie = TableFilter.Cookie;
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
|
@ -21,29 +20,30 @@ tf._clearFilters();
|
|||
|
||||
module('Sanity checks');
|
||||
test('Store module', function() {
|
||||
deepEqual(tf.Cpt.store instanceof Store, true, 'Store type');
|
||||
notEqual(tf.Cpt.store, null, 'Store instanciated');
|
||||
deepEqual(tf.Cpt.store.duration, 100000, 'Store duration');
|
||||
var store = tf.feature('store');
|
||||
deepEqual(typeof store, 'object', 'Store type');
|
||||
notEqual(store, null, 'Store instanciated');
|
||||
deepEqual(store.duration, 100000, 'Store duration');
|
||||
});
|
||||
|
||||
module('Check page number persistence');
|
||||
test('Page number value', function() {
|
||||
tf._clearFilters();
|
||||
tf._filter();
|
||||
tf.Cpt.paging._changePage(1);
|
||||
tf.feature('paging')._changePage(1);
|
||||
var cookieName = tf.pgNbCookie;
|
||||
deepEqual(tf.Cpt.store.getPageNb(cookieName), '2', 'Page number value');
|
||||
deepEqual(tf.feature('store').getPageNb(cookieName), '2', 'Page number value');
|
||||
tf._clearFilters();
|
||||
tf._filter();
|
||||
});
|
||||
|
||||
module('Check page length persistence');
|
||||
test('Page length value', function() {
|
||||
var paging = tf.Cpt.paging;
|
||||
var paging = tf.feature('paging');
|
||||
paging.resultsPerPageSlc.options[2].selected = true;
|
||||
paging._changeResultsPerPage();
|
||||
var cookieName = tf.pgLenCookie;
|
||||
deepEqual(tf.Cpt.store.getPageLength(cookieName), '2', 'Page length value');
|
||||
deepEqual(tf.feature('store').getPageLength(cookieName), '2', 'Page length value');
|
||||
tf._clearFilters();
|
||||
tf._filter();
|
||||
});
|
||||
|
@ -54,8 +54,8 @@ test('Filters value', function() {
|
|||
tf.setFilterValue(3, '1.5');
|
||||
tf._filter();
|
||||
var cookieName = tf.fltsValuesCookie;
|
||||
deepEqual(tf.Cpt.store.getFilterValues(cookieName)[0], 'Sydney', 'Filter 0 value');
|
||||
deepEqual(tf.Cpt.store.getFilterValues(cookieName)[3], '1.5', 'Filter 3 value');
|
||||
deepEqual(tf.feature('store').getFilterValues(cookieName)[0], 'Sydney', 'Filter 0 value');
|
||||
deepEqual(tf.feature('store').getFilterValues(cookieName)[3], '1.5', 'Filter 3 value');
|
||||
tf._clearFilters();
|
||||
tf._filter();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue