mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-17 16:10:04 +01:00
refactor feature istantiation helpers
This commit is contained in:
parent
528d587a80
commit
df0221d5e7
30 changed files with 480 additions and 421 deletions
167
src/const.js
167
src/const.js
|
|
@ -1,18 +1,18 @@
|
|||
import {DateType} from './modules/dateType';
|
||||
import {Help} from './modules/help';
|
||||
import {State} from './modules/state';
|
||||
import {GridLayout} from './modules/gridLayout';
|
||||
import {Loader} from './modules/loader';
|
||||
import {HighlightKeyword} from './modules/highlightKeywords';
|
||||
import {PopupFilter} from './modules/popupFilter';
|
||||
import {MarkActiveColumns} from './modules/markActiveColumns';
|
||||
import {RowsCounter} from './modules/rowsCounter';
|
||||
import {StatusBar} from './modules/statusBar';
|
||||
import {ClearButton} from './modules/clearButton';
|
||||
import {AlternateRows} from './modules/alternateRows';
|
||||
import {NoResults} from './modules/noResults';
|
||||
import {Paging} from './modules/paging';
|
||||
import {Toolbar} from './modules/toolbar';
|
||||
// import {DateType} from './modules/dateType';
|
||||
// import {Help} from './modules/help';
|
||||
// import {State} from './modules/state';
|
||||
// import {GridLayout} from './modules/gridLayout';
|
||||
// import {Loader} from './modules/loader';
|
||||
// import {HighlightKeyword} from './modules/highlightKeywords';
|
||||
// import {PopupFilter} from './modules/popupFilter';
|
||||
// import {MarkActiveColumns} from './modules/markActiveColumns';
|
||||
// import {RowsCounter} from './modules/rowsCounter';
|
||||
// import {StatusBar} from './modules/statusBar';
|
||||
// import {ClearButton} from './modules/clearButton';
|
||||
// import {AlternateRows} from './modules/alternateRows';
|
||||
// import {NoResults} from './modules/noResults';
|
||||
// import {Paging} from './modules/paging';
|
||||
// import {Toolbar} from './modules/toolbar';
|
||||
|
||||
/**
|
||||
* Filter types
|
||||
|
|
@ -135,72 +135,73 @@ export const AUTO_FILTER_DELAY = 750;
|
|||
|
||||
/**
|
||||
* TableFilter features definitions
|
||||
* @type {Object}
|
||||
* @type {Array}
|
||||
*/
|
||||
export const FEATURES = {
|
||||
dateType: {
|
||||
class: DateType,
|
||||
name: 'dateType'
|
||||
},
|
||||
help: {
|
||||
class: Help,
|
||||
name: 'help',
|
||||
enforce: true
|
||||
},
|
||||
state: {
|
||||
class: State,
|
||||
name: 'state'
|
||||
},
|
||||
markActiveColumns: {
|
||||
class: MarkActiveColumns,
|
||||
name: 'markActiveColumns'
|
||||
},
|
||||
gridLayout: {
|
||||
class: GridLayout,
|
||||
name: 'gridLayout'
|
||||
},
|
||||
loader: {
|
||||
class: Loader,
|
||||
name: 'loader'
|
||||
},
|
||||
highlightKeyword: {
|
||||
class: HighlightKeyword,
|
||||
name: 'highlightKeyword',
|
||||
property: 'highlightKeywords'
|
||||
},
|
||||
popupFilter: {
|
||||
class: PopupFilter,
|
||||
name: 'popupFilter',
|
||||
property: 'popupFilters'
|
||||
},
|
||||
rowsCounter: {
|
||||
class: RowsCounter,
|
||||
name: 'rowsCounter'
|
||||
},
|
||||
statusBar: {
|
||||
class: StatusBar,
|
||||
name: 'statusBar'
|
||||
},
|
||||
clearButton: {
|
||||
class: ClearButton,
|
||||
name: 'clearButton',
|
||||
property: 'btnReset'
|
||||
},
|
||||
alternateRows: {
|
||||
class: AlternateRows,
|
||||
name: 'alternateRows'
|
||||
},
|
||||
noResults: {
|
||||
class: NoResults,
|
||||
name: 'noResults'
|
||||
},
|
||||
paging: {
|
||||
class: Paging,
|
||||
name: 'paging'
|
||||
},
|
||||
toolbar: {
|
||||
class: Toolbar,
|
||||
name: 'toolbar',
|
||||
enforce: true
|
||||
}
|
||||
};
|
||||
export const FEATURES = [];
|
||||
// export const FEATURES = {
|
||||
// dateType: {
|
||||
// class: DateType,
|
||||
// name: 'dateType'
|
||||
// },
|
||||
// help: {
|
||||
// class: Help,
|
||||
// name: 'help',
|
||||
// enforce: true
|
||||
// },
|
||||
// state: {
|
||||
// class: State,
|
||||
// name: 'state'
|
||||
// },
|
||||
// markActiveColumns: {
|
||||
// class: MarkActiveColumns,
|
||||
// name: 'markActiveColumns'
|
||||
// },
|
||||
// gridLayout: {
|
||||
// class: GridLayout,
|
||||
// name: 'gridLayout'
|
||||
// },
|
||||
// loader: {
|
||||
// class: Loader,
|
||||
// name: 'loader'
|
||||
// },
|
||||
// highlightKeyword: {
|
||||
// class: HighlightKeyword,
|
||||
// name: 'highlightKeyword',
|
||||
// property: 'highlightKeywords'
|
||||
// },
|
||||
// popupFilter: {
|
||||
// class: PopupFilter,
|
||||
// name: 'popupFilter',
|
||||
// property: 'popupFilters'
|
||||
// },
|
||||
// rowsCounter: {
|
||||
// class: RowsCounter,
|
||||
// name: 'rowsCounter'
|
||||
// },
|
||||
// statusBar: {
|
||||
// class: StatusBar,
|
||||
// name: 'statusBar'
|
||||
// },
|
||||
// clearButton: {
|
||||
// class: ClearButton,
|
||||
// name: 'clearButton',
|
||||
// property: 'btnReset'
|
||||
// },
|
||||
// alternateRows: {
|
||||
// class: AlternateRows,
|
||||
// name: 'alternateRows'
|
||||
// },
|
||||
// noResults: {
|
||||
// class: NoResults,
|
||||
// name: 'noResults'
|
||||
// },
|
||||
// paging: {
|
||||
// class: Paging,
|
||||
// name: 'paging'
|
||||
// },
|
||||
// toolbar: {
|
||||
// class: Toolbar,
|
||||
// name: 'toolbar',
|
||||
// enforce: true
|
||||
// }
|
||||
// };
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export default class AdapterEzEditTable extends Feature {
|
|||
* @param {Object} cfg Configuration options for ezEditTable library
|
||||
*/
|
||||
constructor(tf, cfg) {
|
||||
super(tf, cfg.name);
|
||||
super(tf, AdapterEzEditTable);
|
||||
|
||||
/**
|
||||
* Module description
|
||||
|
|
@ -505,3 +505,5 @@ export default class AdapterEzEditTable extends Feature {
|
|||
this.initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
AdapterEzEditTable.meta = {altName: 'advancedGrid'};
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export default class ColOps extends Feature {
|
|||
* @param {Object} opts Configuration object
|
||||
*/
|
||||
constructor(tf, opts) {
|
||||
super(tf, opts.name);
|
||||
super(tf, ColOps);
|
||||
|
||||
/**
|
||||
* Callback fired before columns operations start
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export default class ColsVisibility extends Feature {
|
|||
* @param {Object} Configuration object
|
||||
*/
|
||||
constructor(tf, f) {
|
||||
super(tf, f.name);
|
||||
super(tf, ColsVisibility);
|
||||
|
||||
// Configuration object
|
||||
let cfg = this.config;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export default class FiltersVisibility extends Feature {
|
|||
* @param {Object} Configuration object
|
||||
*/
|
||||
constructor(tf, f) {
|
||||
super(tf, f.name);
|
||||
super(tf, FiltersVisibility);
|
||||
|
||||
/**
|
||||
* Module name
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export default class AdapterSortableTable extends Feature {
|
|||
* @param {Object} opts Configuration object
|
||||
*/
|
||||
constructor(tf, opts) {
|
||||
super(tf, opts.name);
|
||||
super(tf, AdapterSortableTable);
|
||||
|
||||
/**
|
||||
* Module name
|
||||
|
|
@ -508,6 +508,8 @@ export default class AdapterSortableTable extends Feature {
|
|||
|
||||
}
|
||||
|
||||
AdapterSortableTable.meta = {altName: 'sort'};
|
||||
|
||||
//Converters
|
||||
function ipAddress(value) {
|
||||
let vals = value.split('.');
|
||||
|
|
|
|||
|
|
@ -9,28 +9,28 @@ export class Feature extends Register {
|
|||
/**
|
||||
* Creates an instance of Feature
|
||||
* @param {Object} tf TableFilter instance
|
||||
* @param {String} feature Feature name known by TableFilter
|
||||
* @param {Class} feature Feature class for TableFilter registration
|
||||
*/
|
||||
constructor(tf, feature, cls) {
|
||||
constructor(tf, cls) {
|
||||
super(tf, cls);
|
||||
|
||||
/**
|
||||
* TableFilter instance
|
||||
* @type {TableFilter}
|
||||
*/
|
||||
this.tf = tf;
|
||||
//this.tf = tf;
|
||||
|
||||
/**
|
||||
* Feature name
|
||||
* @type {String}
|
||||
*/
|
||||
this.feature = feature;
|
||||
// this.feature = feature;
|
||||
|
||||
/**
|
||||
* TableFilter feature setting
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.enabled = tf[feature];
|
||||
this.enabled = tf[this.feature];
|
||||
|
||||
/**
|
||||
* TableFilter configuration
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ export class AlternateRows extends Feature {
|
|||
* @param {Object} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'alternateRows');
|
||||
super(tf, AlternateRows);
|
||||
|
||||
let config = this.config;
|
||||
|
||||
/**
|
||||
* Css class for even rows (default: 'even')
|
||||
* @type {String}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class BaseDropdown extends Feature {
|
|||
* @param {TableFilter} tf
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'baseDropdown');
|
||||
super(tf, BaseDropdown);
|
||||
|
||||
let f = this.config;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ export class BaseDropdown extends Feature {
|
|||
f.filter_options_sorter :
|
||||
null;
|
||||
|
||||
// TODO: move here all properties shared by Dropdown CheckList
|
||||
// TODO: move here all properties shared by Dropdown and CheckList
|
||||
|
||||
/**
|
||||
* Has custom options
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export class CheckList extends BaseDropdown {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'checkList');
|
||||
super(tf, CheckList);
|
||||
|
||||
let f = this.config;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class ClearButton extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'btnReset');
|
||||
super(tf, ClearButton);
|
||||
|
||||
let f = this.config.btn_reset || {};
|
||||
|
||||
|
|
@ -139,4 +139,4 @@ export class ClearButton extends Feature {
|
|||
}
|
||||
|
||||
// TODO: remove as soon as feature name is fixed
|
||||
ClearButton.altName = 'btnReset';
|
||||
ClearButton.meta = {altName: 'btnReset'};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class DateType extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'dateType');
|
||||
super(tf, DateType);
|
||||
|
||||
/**
|
||||
* Global locale
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class Dropdown extends BaseDropdown {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'dropdown');
|
||||
super(tf, Dropdown);
|
||||
|
||||
// Configuration object
|
||||
let f = this.config;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class GridLayout extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'gridLayout');
|
||||
super(tf, GridLayout);
|
||||
|
||||
let f = this.config.grid_layout || {};
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ export class Hash {
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts a URL hash into a state JSON object
|
||||
* Converts a URL hash into a JSON object
|
||||
*
|
||||
* @param {String} hash URL hash fragment
|
||||
* @returns {Object} JSON object
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class Help extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'help');
|
||||
super(tf, Help);
|
||||
|
||||
let f = this.config.help_instructions || {};
|
||||
|
||||
|
|
@ -240,4 +240,4 @@ export class Help extends Feature {
|
|||
}
|
||||
|
||||
// TODO: remove as soon as feature name is fixed
|
||||
Help.alwaysInstantiate = true;
|
||||
Help.meta = {alwaysInstantiate: true};
|
||||
|
|
|
|||
|
|
@ -174,4 +174,4 @@ export class HighlightKeyword {
|
|||
}
|
||||
|
||||
// TODO: remove as soon as feature name is fixed
|
||||
HighlightKeyword.altName = 'highlightKeywords';
|
||||
HighlightKeyword.meta = {altName: 'highlightKeywords'};
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export class Loader extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'loader');
|
||||
super(tf, Loader);
|
||||
|
||||
let f = this.config.loader || {};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export class MarkActiveColumns extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'markActiveColumns');
|
||||
super(tf, MarkActiveColumns);
|
||||
|
||||
let config = this.config.mark_active_columns || {};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class NoResults extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'noResults');
|
||||
super(tf, NoResults);
|
||||
|
||||
//configuration object
|
||||
let f = this.config.no_results_message || {};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class Paging extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'paging');
|
||||
super(tf, Paging);
|
||||
|
||||
// Configuration object
|
||||
let f = this.config.paging || {};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class PopupFilter extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'popupFilters');
|
||||
super(tf, PopupFilter);
|
||||
|
||||
// Configuration object
|
||||
let f = this.config.popup_filters || {};
|
||||
|
|
@ -458,4 +458,4 @@ export class PopupFilter extends Feature {
|
|||
}
|
||||
|
||||
// TODO: remove as soon as feature name is fixed
|
||||
PopupFilter.altName = 'popupFilters';
|
||||
PopupFilter.meta = {altName: 'popupFilters'};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class RowsCounter extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'rowsCounter', RowsCounter);
|
||||
super(tf, RowsCounter);
|
||||
|
||||
// TableFilter configuration
|
||||
let f = this.config.rows_counter || {};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class State extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'state');
|
||||
super(tf, State);
|
||||
|
||||
let cfg = this.config.state || {};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class StatusBar extends Feature {
|
|||
* @param {TableFilter} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'statusBar');
|
||||
super(tf, StatusBar);
|
||||
|
||||
// Configuration object
|
||||
let f = this.config.status_bar || {};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export class Toolbar extends Feature {
|
|||
* @memberof Toolbar
|
||||
*/
|
||||
constructor(tf) {
|
||||
super(tf, 'toolbar');
|
||||
super(tf, Toolbar);
|
||||
|
||||
// Configuration object
|
||||
let f = this.config.toolbar || {};
|
||||
|
|
@ -221,4 +221,4 @@ export class Toolbar extends Feature {
|
|||
}
|
||||
|
||||
// TODO: remove as soon as feature name is fixed
|
||||
Toolbar.alwaysInstantiate = true;
|
||||
Toolbar.meta = {alwaysInstantiate: true};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {defaultsStr} from './settings';
|
||||
import {toCamelCase} from './string';
|
||||
|
||||
export const FeaturesRegistry = {};
|
||||
import {FEATURES} from './const';
|
||||
|
||||
export class Register {
|
||||
constructor(tf, cls = {}) {
|
||||
console.log(tf, cls);
|
||||
cls.meta = cls.meta || {};
|
||||
|
||||
/**
|
||||
* TableFilter instance
|
||||
* @type {TableFilter}
|
||||
|
|
@ -13,24 +13,15 @@ export class Register {
|
|||
this.tf = tf;
|
||||
|
||||
/**
|
||||
* Feature name, retrieved from alternate class name
|
||||
* if found defined or from camelised class name
|
||||
* Feature name, retrieved from alternate class name if found or from
|
||||
* camelised class name as per TableFilter convention
|
||||
* @type {String}
|
||||
*/
|
||||
this.feature = defaultsStr(cls.altName, toCamelCase(cls.name));
|
||||
this.feature = defaultsStr(cls.meta.altName, toCamelCase(cls.name));
|
||||
|
||||
this.tf._mod_[this.feature] = cls;
|
||||
cls.meta.name = this.feature;
|
||||
|
||||
FEATURES[this.feature] = cls;
|
||||
|
||||
// this.instantiate(cls, this.feature);
|
||||
}
|
||||
|
||||
// instantiate(cls, name) {
|
||||
// let Cls = cls;
|
||||
// console.log(Boolean(this.tf[name]),
|
||||
// Boolean(Cls.alwaysInstantiate));
|
||||
// if (!this.tf.hasConfig || Boolean(this.tf[name])
|
||||
// || Boolean(cls.alwaysInstantiate)) {
|
||||
// this.tf.Mod[name] = this.tf.Mod[name] || new Cls(tf);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -17,6 +17,21 @@ import {root} from './root';
|
|||
import {Emitter} from './emitter';
|
||||
import {Dropdown} from './modules/dropdown';
|
||||
import {CheckList} from './modules/checkList';
|
||||
import {DateType} from './modules/dateType';
|
||||
import {Help} from './modules/help';
|
||||
import {State} from './modules/state';
|
||||
import {GridLayout} from './modules/gridLayout';
|
||||
import {Loader} from './modules/loader';
|
||||
import {HighlightKeyword} from './modules/highlightKeywords';
|
||||
import {PopupFilter} from './modules/popupFilter';
|
||||
import {MarkActiveColumns} from './modules/markActiveColumns';
|
||||
import {RowsCounter} from './modules/rowsCounter';
|
||||
import {StatusBar} from './modules/statusBar';
|
||||
import {ClearButton} from './modules/clearButton';
|
||||
import {AlternateRows} from './modules/alternateRows';
|
||||
import {NoResults} from './modules/noResults';
|
||||
import {Paging} from './modules/paging';
|
||||
import {Toolbar} from './modules/toolbar';
|
||||
|
||||
import {
|
||||
INPUT, SELECT, MULTIPLE, CHECKLIST, NONE,
|
||||
|
|
@ -24,7 +39,6 @@ import {
|
|||
CELL_TAG, AUTO_FILTER_DELAY, NUMBER, DATE, FORMATTED_NUMBER,
|
||||
FEATURES
|
||||
} from './const';
|
||||
import { RowsCounter } from './modules/rowsCounter';
|
||||
|
||||
let doc = root.document;
|
||||
|
||||
|
|
@ -920,7 +934,6 @@ export class TableFilter {
|
|||
* @private
|
||||
*/
|
||||
this.Mod = {};
|
||||
this._mod_ = {};
|
||||
|
||||
/**
|
||||
* Extensions registry
|
||||
|
|
@ -930,9 +943,10 @@ export class TableFilter {
|
|||
|
||||
// conditionally instantiate required features
|
||||
this.instantiateFeatures(
|
||||
Object.keys(FEATURES).map((item) => FEATURES[item])
|
||||
// //Object.keys(FEATURES).map((item) => FEATURES[item])
|
||||
// //FEATURES
|
||||
[Toolbar]
|
||||
);
|
||||
// console.log(this.Mod, this._mod_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -952,20 +966,28 @@ export class TableFilter {
|
|||
//loads theme
|
||||
this.loadThemes();
|
||||
|
||||
const { dateType, help, state, markActiveColumns, gridLayout, loader,
|
||||
highlightKeyword, popupFilter, rowsCounter, statusBar, clearButton,
|
||||
alternateRows, noResults, paging, toolbar } = FEATURES;
|
||||
console.log(this.Mod, this._mod_);
|
||||
// const { dateType, help, state, markActiveColumns, gridLayout, loader,
|
||||
// highlightKeyword, popupFilter, rowsCounter, statusBar, clearButton,
|
||||
// alternateRows, noResults, paging, toolbar } = FEATURES;
|
||||
|
||||
//explicitly initialise features in given order
|
||||
this.initFeatures([
|
||||
dateType,
|
||||
help,
|
||||
state,
|
||||
markActiveColumns,
|
||||
gridLayout,
|
||||
loader,
|
||||
highlightKeyword,
|
||||
popupFilter
|
||||
// dateType,
|
||||
// help,
|
||||
// state,
|
||||
// markActiveColumns,
|
||||
// gridLayout,
|
||||
// loader,
|
||||
// highlightKeyword,
|
||||
// popupFilter
|
||||
DateType,
|
||||
Help,
|
||||
State,
|
||||
MarkActiveColumns,
|
||||
GridLayout,
|
||||
Loader,
|
||||
HighlightKeyword,
|
||||
PopupFilter
|
||||
]);
|
||||
|
||||
//filters grid is not generated
|
||||
|
|
@ -1038,13 +1060,20 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
this.initFeatures([
|
||||
rowsCounter,
|
||||
statusBar,
|
||||
clearButton,
|
||||
alternateRows,
|
||||
noResults,
|
||||
paging,
|
||||
toolbar
|
||||
// rowsCounter,
|
||||
// statusBar,
|
||||
// clearButton,
|
||||
// alternateRows,
|
||||
// noResults,
|
||||
// paging,
|
||||
// toolbar
|
||||
RowsCounter,
|
||||
StatusBar,
|
||||
ClearButton,
|
||||
AlternateRows,
|
||||
NoResults,
|
||||
Paging,
|
||||
Toolbar
|
||||
]);
|
||||
|
||||
this.setColWidths();
|
||||
|
|
@ -1253,47 +1282,61 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Istantiate the collection of features required by the
|
||||
* configuration and add them to the features registry. A feature is
|
||||
* described by a `class` and `name` fields and and optional `property`
|
||||
* field:
|
||||
* {
|
||||
* class: AClass,
|
||||
* name: 'aClass'
|
||||
* }
|
||||
* Conditionally istantiate each feature class in passed collection if
|
||||
* required by configuration and add it to the features registry. A feature
|
||||
* class meta information contains a `name` field and optional `altName` and
|
||||
* `alwaysInstantiate` fields
|
||||
* @param {Array} [features=[]]
|
||||
* @private
|
||||
*/
|
||||
instantiateFeatures(features = []) {
|
||||
features.forEach((feature) => {
|
||||
// TODO: remove the property field.
|
||||
// Due to naming convention inconsistencies, a `property`
|
||||
// field is added to allow a conditional instanciation based
|
||||
// on that property on TableFilter, if supplied.
|
||||
feature.property = feature.property || feature.name;
|
||||
if (!this.hasConfig || this[feature.property] === true ||
|
||||
feature.enforce === true) {
|
||||
let {class: Cls, name} = feature;
|
||||
// features.forEach((feature) => {
|
||||
// // TODO: remove the property field.
|
||||
// // Due to naming convention inconsistencies, a `property`
|
||||
// // field is added to allow a conditional instanciation based
|
||||
// // on that property on TableFilter, if supplied.
|
||||
// feature.property = feature.property || feature.name;
|
||||
// if (!this.hasConfig || this[feature.property] === true ||
|
||||
// feature.enforce === true) {
|
||||
// let {class: Cls, name} = feature;
|
||||
|
||||
this.Mod[name] = this.Mod[name] || new Cls(this);
|
||||
// this.Mod[name] = this.Mod[name] || new Cls(this);
|
||||
// }
|
||||
// });
|
||||
features.forEach(featureCls => {
|
||||
let Cls = featureCls;
|
||||
let inst = new Cls(this);
|
||||
|
||||
let {meta} = Cls;
|
||||
let {name} = meta;
|
||||
|
||||
if (!this.hasConfig || this[name] === true
|
||||
|| Boolean(meta.alwaysInstantiate)) {
|
||||
this.Mod[name] = this.Mod[name] || inst;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the passed features collection. A feature is described by a
|
||||
* `class` and `name` fields and and optional `property` field:
|
||||
* {
|
||||
* class: AClass,
|
||||
* name: 'aClass'
|
||||
* }
|
||||
* Initialise each feature class in passed collection.
|
||||
* @param {Array} [features=[]]
|
||||
* @private
|
||||
*/
|
||||
initFeatures(features = []) {
|
||||
features.forEach((feature) => {
|
||||
let {property, name} = feature;
|
||||
if (this[property] === true && this.Mod[name]) {
|
||||
// features.forEach((feature) => {
|
||||
// let {property, name} = feature;
|
||||
// if (this[property] === true && this.Mod[name]) {
|
||||
// this.Mod[name].init();
|
||||
// }
|
||||
// });
|
||||
// this.instantiateFeatures(features);
|
||||
|
||||
features.forEach(featureCls => {
|
||||
this.instantiateFeatures([featureCls]);
|
||||
|
||||
let {name} = featureCls.meta;
|
||||
|
||||
if (this[name] === true && this.Mod[name]) {
|
||||
this.Mod[name].init();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue