mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-16 23:55:46 +01:00
Refactored array module
This commit is contained in:
parent
e3b9525091
commit
c849418e2f
11 changed files with 10625 additions and 59 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Arr from '../array';
|
||||
import {has} from '../array';
|
||||
import Str from '../string';
|
||||
import Sort from '../sort';
|
||||
import Event from '../event';
|
||||
|
|
@ -188,7 +188,7 @@ export class CheckList extends Feature {
|
|||
//Vary Peter's patch
|
||||
let cellString = Str.matchCase(cellData, tf.matchCase);
|
||||
// checks if celldata is already in array
|
||||
if (!Arr.has(this.opts, cellString, tf.matchCase)) {
|
||||
if (!has(this.opts, cellString, tf.matchCase)) {
|
||||
this.opts.push(cellData);
|
||||
}
|
||||
let filteredCol = filteredDataCol[j];
|
||||
|
|
@ -196,9 +196,8 @@ export class CheckList extends Feature {
|
|||
if (!filteredCol) {
|
||||
filteredCol = tf.getFilteredDataCol(j);
|
||||
}
|
||||
if (!Arr.has(filteredCol, cellString, tf.matchCase) &&
|
||||
!Arr.has(this.excludedOpts,
|
||||
cellString, tf.matchCase)) {
|
||||
if (!has(filteredCol, cellString, tf.matchCase) &&
|
||||
!has(this.excludedOpts, cellString, tf.matchCase)) {
|
||||
this.excludedOpts.push(cellData);
|
||||
}
|
||||
}
|
||||
|
|
@ -283,9 +282,10 @@ export class CheckList extends Feature {
|
|||
let li = Dom.createCheckItem(
|
||||
tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl);
|
||||
li.className = this.checkListItemCssClass;
|
||||
|
||||
if (tf.linkedFilters && tf.disableExcludedOptions &&
|
||||
Arr.has(this.excludedOpts,
|
||||
Str.matchCase(val, tf.matchCase), tf.matchCase)) {
|
||||
has(this.excludedOpts, Str.matchCase(val, tf.matchCase),
|
||||
tf.matchCase)) {
|
||||
Dom.addClass(li, this.checkListItemDisabledCssClass);
|
||||
li.check.disabled = true;
|
||||
li.disabled = true;
|
||||
|
|
@ -446,7 +446,7 @@ export class CheckList extends Feature {
|
|||
lbl = Dom.tag(li, 'label')[0],
|
||||
chk = Dom.tag(li, 'input')[0],
|
||||
lblTxt = Str.matchCase(Dom.getText(lbl), tf.caseSensitive);
|
||||
if (lblTxt !== '' && Arr.has(values, lblTxt, tf.caseSensitive)) {
|
||||
if (lblTxt !== '' && has(values, lblTxt, tf.caseSensitive)) {
|
||||
chk.checked = true;
|
||||
this.setCheckListValues(chk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Arr from '../array';
|
||||
import {has} from '../array';
|
||||
import Str from '../string';
|
||||
import Sort from '../sort';
|
||||
import Event from '../event';
|
||||
|
|
@ -169,6 +169,7 @@ export class Dropdown extends Feature {
|
|||
// this loop retrieves cell data
|
||||
for (let j = 0; j < nchilds; j++) {
|
||||
// WTF: cyclomatic complexity hell
|
||||
// TODO: simplify hell below
|
||||
if ((colIndex === j &&
|
||||
(!isLinked ||
|
||||
(isLinked && tf.disableExcludedOptions))) ||
|
||||
|
|
@ -186,7 +187,7 @@ export class Dropdown extends Feature {
|
|||
cellString = Str.matchCase(cellData, matchCase);
|
||||
|
||||
// checks if celldata is already in array
|
||||
if (!Arr.has(this.opts, cellString, matchCase)) {
|
||||
if (!has(this.opts, cellString, matchCase)) {
|
||||
this.opts.push(cellData);
|
||||
}
|
||||
|
||||
|
|
@ -195,9 +196,8 @@ export class Dropdown extends Feature {
|
|||
if (!filteredCol) {
|
||||
filteredCol = tf.getFilteredDataCol(j);
|
||||
}
|
||||
if (!Arr.has(filteredCol, cellString, matchCase) &&
|
||||
!Arr.has(
|
||||
excludedOpts, cellString, matchCase)) {
|
||||
if (!has(filteredCol, cellString, matchCase) &&
|
||||
!has(excludedOpts, cellString, matchCase)) {
|
||||
excludedOpts.push(cellData);
|
||||
}
|
||||
}
|
||||
|
|
@ -283,11 +283,8 @@ export class Dropdown extends Feature {
|
|||
let lbl = this.isCustom ? this.optsTxt[y] : val; //option text
|
||||
let isDisabled = false;
|
||||
if (isLinked && tf.disableExcludedOptions &&
|
||||
Arr.has(
|
||||
excludedOpts,
|
||||
Str.matchCase(val, tf.matchCase),
|
||||
tf.matchCase
|
||||
)) {
|
||||
has(excludedOpts, Str.matchCase(val, tf.matchCase),
|
||||
tf.matchCase)) {
|
||||
isDisabled = true;
|
||||
}
|
||||
|
||||
|
|
@ -350,8 +347,7 @@ export class Dropdown extends Feature {
|
|||
option.selected = false;
|
||||
}
|
||||
|
||||
if (option.value !== '' &&
|
||||
Arr.has(values, option.value, true)) {
|
||||
if (option.value !== '' && has(values, option.value, true)) {
|
||||
option.selected = true;
|
||||
}//if
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue