@firestitch/filter
Version:
1,228 lines (1,222 loc) • 188 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/forms'), require('@angular/material'), require('@angular/flex-layout'), require('@firestitch/datepicker'), require('@firestitch/chip'), require('@firestitch/label'), require('@firestitch/autocomplete'), require('@firestitch/autocomplete-chips'), require('@angular/common'), require('@angular/router'), require('@firestitch/scroll'), require('@firestitch/store'), require('tsmodels'), require('rxjs/internal/util/isObservable'), require('date-fns'), require('lodash-es'), require('@angular/cdk/portal'), require('@angular/cdk/overlay'), require('rxjs'), require('rxjs/operators'), require('@firestitch/common'), require('@firestitch/date'), require('@angular/core')) :
typeof define === 'function' && define.amd ? define('@firestitch/filter', ['exports', '@angular/forms', '@angular/material', '@angular/flex-layout', '@firestitch/datepicker', '@firestitch/chip', '@firestitch/label', '@firestitch/autocomplete', '@firestitch/autocomplete-chips', '@angular/common', '@angular/router', '@firestitch/scroll', '@firestitch/store', 'tsmodels', 'rxjs/internal/util/isObservable', 'date-fns', 'lodash-es', '@angular/cdk/portal', '@angular/cdk/overlay', 'rxjs', 'rxjs/operators', '@firestitch/common', '@firestitch/date', '@angular/core'], factory) :
(factory((global.firestitch = global.firestitch || {}, global.firestitch.filter = {}),global.ng.forms,global.ng.material,global.ng['flex-layout'],global.datepicker,global.chip,global.label,global.autocomplete,global.autocompleteChips,global.ng.common,global.ng.router,global.scroll,global.store,global.tsmodels,global.rxjs['internal/util/isObservable'],global.dateFns,global.lodashEs,global.ng.cdk.portal,global.ng.cdk.overlay,global.rxjs,global.rxjs.operators,global.common$1,global.date,global.ng.core));
}(this, (function (exports,forms,material,flexLayout,datepicker,chip,label,autocomplete,autocompleteChips,common,router,scroll,store,tsmodels,isObservable,dateFns,lodashEs,portal,overlay,rxjs,operators,common$1,date,core) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m)
return m.call(o);
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {string} */
var ItemType = {
Text: 'text',
Select: 'select',
Range: 'range',
Date: 'date',
DateTime: 'datetime',
DateRange: 'daterange',
DateTimeRange: 'datetimerange',
AutoComplete: 'autocomplete',
AutoCompleteChips: 'autocompletechips',
Checkbox: 'checkbox',
Chips: 'chips',
Keyword: 'keyword',
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {string} */
var ItemDateMode = {
Calendar: 'calendar',
ScrollMonthYear: 'monthyear',
ScrollMonthDayYear: 'monthdayyear',
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FsFilterConfigItem = /** @class */ (function (_super) {
__extends(FsFilterConfigItem, _super);
function FsFilterConfigItem(_configItem, _config, _route, _persists) {
if (_configItem === void 0) {
_configItem = {};
}
var _this = _super.call(this) || this;
_this._configItem = _configItem;
_this._config = _config;
_this._route = _route;
_this._persists = _persists;
_this.initialLoading = false;
_this.valueChanged = false;
_this._pendingValues = false;
_this._fromJSON(_configItem);
return _this;
}
Object.defineProperty(FsFilterConfigItem.prototype, "hasPendingValues", {
get: /**
* @return {?}
*/ function () {
return this._pendingValues;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "model", {
get: /**
* @return {?}
*/ function () {
return this._model;
},
set: /**
* @param {?} value
* @return {?}
*/ function (value) {
this._setModel(value);
this.checkIfValueChanged();
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "values", {
get: /**
* @return {?}
*/ function () {
return this._values;
},
set: /**
* @param {?} values
* @return {?}
*/ function (values) {
this._values = values;
this.init();
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "value", {
get: /**
* @return {?}
*/ function () {
/** @type {?} */
var opts = {};
/** @type {?} */
var value = lodashEs.clone(this.model) || null;
if (this.isTypeSelect) {
if (this.multiple) {
if (this.isolate) {
if (!Array.isArray(this.model) || !this.model.length) {
value = this.values.map(( /**
* @param {?} item
* @return {?}
*/function (item) {
return lodashEs.isObject(item) ? item.value : null;
}));
}
}
if (this.model && this.model.indexOf('__all') > -1) {
value = null;
}
}
else {
if (this.isolate) {
if (this.model == '__all') {
value = this.values.map(( /**
* @param {?} item
* @return {?}
*/function (item) {
return lodashEs.isObject(item) ? item.value : null;
}));
}
}
else {
if (this.model == '__all') {
value = null;
}
}
}
}
else if (this.isTypeAutocompleteChips || this.isTypeChips) {
if (Array.isArray(this.model) && this.model.length) {
value = this.model;
}
}
else if (this.isTypeCheckbox) {
value = this.model ? this.checked : this.unchecked;
}
else if (this.isTypeRange) {
if (!lodashEs.isObject(this.model) ||
(common$1.isEmpty(this.model.max, { zero: true }) && common$1.isEmpty(this.model.min, { zero: true }))) {
value = null;
}
}
else if (this.isTypeDateRange || this.isTypeDateTimeRange) {
if (!lodashEs.isObject(this.model) ||
(common$1.isEmpty(this.model.from, { zero: true }) && common$1.isEmpty(this.model.to, { zero: true }))) {
value = null;
}
}
// @TODO What is TODO?
if (common$1.isEmpty(value, { zero: true })) {
return null;
}
if (this.isTypeDate || this.isTypeDateTime) {
if (value && dateFns.isValid(value) && dateFns.isDate(value)) {
value = date.simpleFormat(value);
}
}
else if (this.isTypeDateRange || this.isTypeDateTimeRange) {
/** @type {?} */
var from = value.from;
/** @type {?} */
var to = value.to;
value = {};
if (from) {
if (lodashEs.isString(from)) {
from = dateFns.parseISO(from);
}
if (dateFns.isValid(from) && dateFns.isDate(from)) {
value.from = date.simpleFormat(from);
}
}
if (to) {
if (lodashEs.isString(to)) {
to = dateFns.parseISO(to);
}
if (dateFns.isValid(to) && dateFns.isDate(to)) {
value.to = date.simpleFormat(to);
}
}
}
else if (this.isTypeAutocomplete) {
if (common$1.isEmpty(this.model.value, { zero: true })) {
return null;
}
value = this.model.value;
}
if (lodashEs.isObject(this.names) && opts.names !== false) ;
return value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "flattenedParams", {
get: /**
* @return {?}
*/ function () {
/** @type {?} */
var value = this.value;
/** @type {?} */
var name = this.name;
/** @type {?} */
var params = [];
if (this.isTypeRange) {
if (lodashEs.isObject(value)) {
/** @type {?} */
var values = [];
if (!common$1.isEmpty(value.min, { zero: true })) {
params[name + '_min'] = value.min;
values.push(value.min);
}
if (!common$1.isEmpty(value.max, { zero: true })) {
params[name + '_max'] = value.max;
values.push(value.max);
}
// Legacy support
if (values.length) {
params[name] = values.join(',');
}
}
}
else if (this.isTypeDateRange || this.isTypeDateTimeRange) {
if (lodashEs.isObject(value)) {
if (value.from) {
params[name + '_from'] = value.from;
}
if (value.to) {
params[name + '_to'] = value.to;
}
}
}
else if (this.isTypeAutocompleteChips || this.isTypeChips) {
if (Array.isArray(value)) {
params[name] = this.model.map(( /**
* @param {?} item
* @return {?}
*/function (item) {
return lodashEs.isObject(item) ? item.value : null;
})).join(',');
}
}
else if (Array.isArray(value)) {
params[name] = value.join(',');
}
else {
params[name] = value;
}
return params;
},
enumerable: true,
configurable: true
});
/**
* @param {?} data
* @return {?}
*/
FsFilterConfigItem.prototype._fromJSON = /**
* @param {?} data
* @return {?}
*/
function (data) {
_super.prototype._fromJSON.call(this, data);
if (this.name && lodashEs.isObject(this.name)) {
this.names = this.name;
this.name = Object.keys(this.names).join('-');
}
if (this._config.persist) {
/** @type {?} */
var persisted = this._persists[this._config.persist.name].data;
if (persisted[this.name]) {
this.model = persisted[this.name];
}
}
this.init();
};
/**
* @return {?}
*/
FsFilterConfigItem.prototype.initValues = /**
* @return {?}
*/
function () {
if (lodashEs.isFunction(this._configItem.values) &&
!this.isTypeAutocomplete &&
!this.isTypeAutocompleteChips) {
/** @type {?} */
var obj = this._configItem.values();
this.values = obj;
if (isObservable.isObservable(obj)) {
this._pendingValues = true;
}
}
else {
this.values = this._configItem.values;
}
};
/*
* This function seems redundent and the logic should be merged into _setModel()
* Also we have to be careful with setting models that have values because of timing and
* also values need names for human readably lists.
*/
/*
* This function seems redundent and the logic should be merged into _setModel()
* Also we have to be careful with setting models that have values because of timing and
* also values need names for human readably lists.
*/
/**
* @param {?} value
* @return {?}
*/
FsFilterConfigItem.prototype.updateValue = /*
* This function seems redundent and the logic should be merged into _setModel()
* Also we have to be careful with setting models that have values because of timing and
* also values need names for human readably lists.
*/
/**
* @param {?} value
* @return {?}
*/
function (value) {
var _this = this;
var _a;
switch (this.type) {
case ItemType.Select:
{
if (value === '__all' || value === null) {
this.model = value;
return;
}
/** @type {?} */
var valueExists = null;
/** @type {?} */
var isolated = null;
if (this.multiple) {
isolated = this.isolate && Array.isArray(value) && value[0] === this.isolate.value;
valueExists = Array.isArray(this.values)
? value.every(( /**
* @param {?} val
* @return {?}
*/function (val) {
return _this.values.find(( /**
* @param {?} valueItem
* @return {?}
*/function (valueItem) { return valueItem.value === val; }));
}))
|| isolated
: false;
}
else {
valueExists = Array.isArray(this.values)
? this.values.some(( /**
* @param {?} valueItem
* @return {?}
*/function (valueItem) { return valueItem.value === value; }))
: false;
}
if (valueExists) {
this.model = value;
if (this.isolate) {
this.isolate.enabled = isolated;
}
return;
}
}
break;
case ItemType.Range:
case ItemType.DateRange:
case ItemType.DateTimeRange:
{
this.model = lodashEs.isObject(value) ? __assign({}, this.model, value) : {};
}
break;
case ItemType.Chips:
{
this.model = [];
}
break;
case ItemType.Date:
case ItemType.DateTime:
{
this.model = value;
}
break;
case ItemType.AutoCompleteChips:
{
if (Array.isArray(value)) {
(_a = this.model).push.apply(_a, __spread(value));
}
else if (lodashEs.isObject(value)) {
this.model.push(value);
}
else {
this.model = [];
}
}
break;
default: {
this.model = value;
}
}
};
/**
* @param {?=} reload
* @return {?}
*/
FsFilterConfigItem.prototype.loadValues = /**
* @param {?=} reload
* @return {?}
*/
function (reload) {
var _this = this;
if (reload === void 0) {
reload = true;
}
if (reload || (!this.initialLoading && this.hasPendingValues)) {
this.initialLoading = true;
if (lodashEs.isFunction(this._configItem.values) &&
!this.isTypeAutocomplete &&
!this.isTypeAutocompleteChips) {
/** @type {?} */
var obj = this._configItem.values();
if (isObservable.isObservable(obj)) {
// Clear out values so the interfaces go into a loading state
this.values = [];
obj
.pipe(operators.take(1), operators.takeUntil(this._config.destroy$))
.subscribe(( /**
* @param {?} values
* @return {?}
*/function (values) {
_this.values = values;
_this._pendingValues = false;
_this.initialLoading = false;
_this.validateModel();
}));
}
else {
this.values = obj;
this.validateModel();
}
}
}
};
/**
* @param {?} type
* @return {?}
*/
FsFilterConfigItem.prototype.partialClear = /**
* @param {?} type
* @return {?}
*/
function (type) {
if (this.isTypeRange) {
this.particalClearRange(type);
}
else {
this.partialClearDateRange(type);
}
};
/**
* @return {?}
*/
FsFilterConfigItem.prototype.clear = /**
* @return {?}
*/
function () {
this.valueChanged = false;
this.model = undefined;
this.selectedValue = '';
switch (this.type) {
case ItemType.AutoComplete:
{
this.model = null;
this.search = '';
}
break;
case ItemType.AutoCompleteChips:
case ItemType.Chips:
{
this.model = [];
this.search = '';
}
break;
case ItemType.Checkbox:
{
this.model = false;
}
break;
case ItemType.Select:
{
if (this.multiple) {
this.model = [];
}
else {
this.model = Array.isArray(this.values) && this.values.some(( /**
* @param {?} val
* @return {?}
*/function (val) { return val.value === '__all'; }))
? '__all'
: null;
}
if (this.isolate) {
this.isolate.enabled = false;
}
}
break;
case ItemType.Range:
case ItemType.DateRange:
case ItemType.DateTimeRange:
{
this.model = {};
}
break;
case ItemType.Text:
case ItemType.Keyword:
{
this.model = '';
}
break;
case ItemType.Date:
case ItemType.DateTime:
{
this.model = null;
}
break;
}
};
/**
* @return {?}
*/
FsFilterConfigItem.prototype.checkIfValueChanged = /**
* @return {?}
*/
function () {
switch (this.type) {
case ItemType.AutoCompleteChips:
{
this.valueChanged = this.model && this.model.length;
}
break;
case ItemType.Checkbox:
{
this.valueChanged = this.model && this.model !== false;
}
break;
case ItemType.Select:
{
if (this.multiple) {
this.valueChanged = this.model && this.model.length;
}
else {
/** @type {?} */
var hasAllOption = Array.isArray(this.values) && this.values.some(( /**
* @param {?} val
* @return {?}
*/function (val) { return val.value === '__all'; }));
if (hasAllOption && this.model && this.model !== '__all') {
this.valueChanged = true;
}
else {
this.valueChanged = !!this.model;
}
}
}
break;
case ItemType.Range:
{
if (this.model && Object.keys(this.model).length > 0) {
this.valueChanged = true;
}
}
break;
case ItemType.Text:
case ItemType.Keyword:
{
this.valueChanged = this.model && this.model !== '';
}
break;
case ItemType.AutoComplete:
case ItemType.Date:
case ItemType.DateTime:
{
this.valueChanged = !!this.model;
}
break;
default: {
this.valueChanged = false;
}
}
};
/**
* @private
* @param {?} value
* @return {?}
*/
FsFilterConfigItem.prototype._setModel = /**
* @private
* @param {?} value
* @return {?}
*/
function (value) {
if (value) {
if (this.isTypeDateRange || this.isTypeDateTimeRange) {
if (value.from && (!dateFns.isDate(value.from) || !dateFns.isValid(value.from))) {
value.from = dateFns.parse(value.from, 'yyyy-MM-dd\'T\'HH:mm:ssxxxxx', new Date());
}
if (value.to && (!dateFns.isDate(value.to) || !dateFns.isValid(value.to))) {
value.to = dateFns.parse(value.to, 'yyyy-MM-dd\'T\'HH:mm:ssxxxxx', new Date());
}
}
else if (this.isTypeDate || this.isTypeDateTime) {
if (!dateFns.isDate(value) || !dateFns.isValid(value)) {
value = dateFns.parse(value, 'yyyy-MM-dd\'T\'HH:mm:ssxxxxx', new Date());
}
}
else if (this.isTypeCheckbox && this.checked !== undefined) {
value = this.checked;
}
else if (this.isTypeSelect) {
if (this.multiple) {
if (Array.isArray(value)) {
value = value.map(( /**
* @param {?} val
* @return {?}
*/function (val) {
if (isNaN(val)) {
return val;
}
else {
return +val;
}
}));
}
}
else {
if (!isNaN(value)) {
value = +value;
}
}
}
}
this._model = value;
};
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeAutocomplete", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.AutoComplete;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeAutocompleteChips", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.AutoCompleteChips;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeChips", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Chips;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeCheckbox", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Checkbox;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeSelect", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Select;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeDate", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Date;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeDateRange", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.DateRange;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeRange", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Range;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeDateTimeRange", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.DateTimeRange;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeDateTime", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.DateTime;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FsFilterConfigItem.prototype, "isTypeKeyword", {
get: /**
* @return {?}
*/ function () {
return this.type === ItemType.Keyword;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
FsFilterConfigItem.prototype.init = /**
* @return {?}
*/
function () {
switch (this.type) {
case ItemType.Select:
{
this._initSelect();
}
break;
case ItemType.Chips:
{
this._initChips();
}
break;
case ItemType.Range:
{
this._initRange();
}
break;
case ItemType.Date:
{
this._initDate();
}
break;
case ItemType.DateRange:
case ItemType.DateTimeRange:
{
this._initDateRange();
}
break;
case ItemType.Checkbox:
{
this._initCheckbox();
}
break;
}
if (this.model === undefined) {
if (this.isTypeCheckbox) {
this.model = this.checked == this.defaultValue;
}
else {
this.model = this.defaultValue;
}
}
if (this.model === undefined) {
if (this.isTypeCheckbox) {
this.model = false;
}
else if (this.isTypeSelect) {
if (this.multiple) {
if (!Array.isArray(this.defaultValue)) {
this.model = [];
}
}
else {
if (this.defaultValue === undefined) {
this.model = '__all';
}
}
}
else if (this.isTypeAutocompleteChips || this.isTypeChips) {
this.model = [];
}
}
};
/**
* @return {?}
*/
FsFilterConfigItem.prototype.validateModel = /**
* @return {?}
*/
function () {
var _this = this;
if (this.isTypeSelect) {
if (this.multiple) {
this.model = lodashEs.filter(this.model || [], ( /**
* @param {?} item
* @return {?}
*/function (item) {
return _this.values.find(( /**
* @param {?} value
* @return {?}
*/function (value) {
return value.value == item;
}));
}));
}
else {
/** @type {?} */
var item = this.values.find(( /**
* @param {?} value
* @return {?}
*/function (value) {
return value.value == _this.model;
}));
this.model = item ? item.value : '__all';
}
}
};
/**
* @private
* @param {?} values
* @return {?}
*/
FsFilterConfigItem.prototype.modelValueExists = /**
* @private
* @param {?} values
* @return {?}
*/
function (values) {
for (var i = 0; i < values.length; i++) {
if (values[i].value === this.model) {
return true;
}
if (values[i][this.children]) {
/** @type {?} */
var model = this.modelValueExists(values[i][this.children]);
if (model) {
return true;
}
}
}
return false;
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initSelect = /**
* @private
* @return {?}
*/
function () {
if (!Array.isArray(this.values)) {
this.values = [];
}
if (this.isolate) {
for (var index in this.values) {
if (this.values.hasOwnProperty(index)) {
if (!this.values[index]) {
continue;
}
if (this.values[index].value == this.isolate.value) {
this.values.splice(index, 1);
}
}
}
if (Array.isArray(this.model)) {
if (this.model.length == this.values.length) {
this.model = null;
this.isolate.enabled = false;
}
else if (this.model[0] == this.isolate.value) {
this.isolate.enabled = true;
}
}
}
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initChips = /**
* @private
* @return {?}
*/
function () {
var _this = this;
if (!Array.isArray(this.values)) {
this.values = [];
}
if (this.model && Array.isArray(this.model) && this.values.length) {
if (Number.isInteger(this.model[0])) {
this.model = this.model.map(( /**
* @param {?} id
* @return {?}
*/function (id) {
return _this.values.find(( /**
* @param {?} value
* @return {?}
*/function (value) { return value.value === id; }));
}));
}
}
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initDate = /**
* @private
* @return {?}
*/
function () {
if (!this.mode) {
this.mode = ItemDateMode.Calendar;
}
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initCheckbox = /**
* @private
* @return {?}
*/
function () {
this.checked = this.checked ? lodashEs.toString(this.checked) : true;
this.unchecked = this.unchecked ? lodashEs.toString(this.unchecked) : false;
this.defaultValue = this.defaultValue === undefined ? this.unchecked : lodashEs.toString(this.defaultValue);
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initRange = /**
* @private
* @return {?}
*/
function () {
if (!this.label) {
this.label = ['Min', 'Max'];
}
if (this.placeholder) {
this.label = this.placeholder;
}
if (!this.model) {
this.model = {};
}
};
/**
* @private
* @return {?}
*/
FsFilterConfigItem.prototype._initDateRange = /**
* @private
* @return {?}
*/
function () {
if (!this.label) {
this.label = ['Date From', 'Date To'];
}
if (this.placeholder) {
this.label = this.placeholder;
}
if (!this.model) {
this.model = {};
}
};
/**
* @private
* @param {?} type
* @return {?}
*/
FsFilterConfigItem.prototype.particalClearRange = /**
* @private
* @param {?} type
* @return {?}
*/
function (type) {
if (type === 'from') {
delete this.model.min;
this.valueChanged = !!this.model.max;
}
else if (type === 'to') {
delete this.model.max;
this.valueChanged = !!this.model.min;
}
};
/**
* @private
* @param {?} type
* @return {?}
*/
FsFilterConfigItem.prototype.partialClearDateRange = /**
* @private
* @param {?} type
* @return {?}
*/
function (type) {
if (type === 'from') {
delete this.model.from;
this.valueChanged = !!this.model.to;
}
else if (type === 'to') {
delete this.model.to;
this.valueChanged = !!this.model.from;
}
};
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "name", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "type", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "label", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "chipLabel", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "children", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Boolean)
], FsFilterConfigItem.prototype, "multiple", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "groups", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Boolean)
], FsFilterConfigItem.prototype, "wait", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "query", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "values$", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "selectedValue", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "isolate", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "names", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Boolean)
], FsFilterConfigItem.prototype, "primary", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "search", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "unchecked", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "checked", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "alias", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Object)
], FsFilterConfigItem.prototype, "placeholder", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", Function)
], FsFilterConfigItem.prototype, "change", void 0);
__decorate([
tsmodels.Alias(),
__metadata("design:type", String)
], FsFilterConfigItem.prototype, "prefix", void 0);
__decorate