/*! * filename: ej2-querybuilder.min.js * version : 19.1.63 * Copyright Syncfusion Inc. 2001 - 2020. All rights reserved. * Use of this code is subject to the terms of our license. * A copy of the current license can be obtained at any time by e-mailing * licensing@syncfusion.com. Any infringement will be prosecuted under * applicable laws. */ this.ej=this.ej||{},this.ej.querybuilder=function(e,t,l,i,r,n,o,s,a){"use strict";var u=function(){var e=function(t,l){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)t.hasOwnProperty(l)&&(e[l]=t[l])})(t,l)};return function(t,l){function i(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(i.prototype=l.prototype,new i)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,i=arguments.length;l=0;s--)(r=e[s])&&(o=(n<3?r(o):n>3?r(t,l,o):r(t,l))||o);return n>3&&o&&Object.defineProperty(t,l,o),o},c=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"values",void 0),p([t.Property(null)],l.prototype,"operators",void 0),p([t.Property()],l.prototype,"ruleTemplate",void 0),p([t.Property(null)],l.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],l.prototype,"validation",void 0),p([t.Property(null)],l.prototype,"format",void 0),p([t.Property(null)],l.prototype,"step",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(null)],l.prototype,"category",void 0),p([t.Property(null)],l.prototype,"columns",void 0),l}(t.ChildProperty),h=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"condition",void 0),p([t.Collection([],l)],l.prototype,"rules",void 0),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"operator",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(!1)],l.prototype,"not",void 0),l}(t.ChildProperty),m=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"numericTextBoxModel",void 0),p([t.Property(null)],l.prototype,"multiSelectModel",void 0),p([t.Property(null)],l.prototype,"datePickerModel",void 0),p([t.Property(null)],l.prototype,"textBoxModel",void 0),p([t.Property(null)],l.prototype,"radioButtonModel",void 0),l}(t.ChildProperty),f=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(!0)],l.prototype,"ruleDelete",void 0),p([t.Property(!0)],l.prototype,"groupInsert",void 0),p([t.Property(!0)],l.prototype,"groupDelete",void 0),l}(t.ChildProperty),g=function(e){function c(t,l){var r=e.call(this,t,l)||this;return r.isReadonly=!0,r.fields={text:"label",value:"field"},r.updatedRule={not:!1,condition:"and"},r.isLocale=!1,r.isRefreshed=!1,r.isNotified=!1,r.isAddSuccess=!1,r.isNotValueChange=!1,i.MultiSelect.Inject(i.CheckBoxSelection),r}return u(c,e),c.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},c.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",this.enableNotCondition&&t.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",not:!1,rules:[]},this.disableRuleCondition(e.parentElement)},c.prototype.getWrapper=function(){return this.element},c.prototype.getModuleName=function(){return"query-builder"},c.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},c.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],i=void 0,r=!1,n=!1,o=void 0,s={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var a=0,u=(d=this.columns).length;a-1&&("string"===(i=typeof(o=this.dataColl[0][d[a].field]))?n=!isNaN(Date.parse(o)):"object"===i&&(n=o instanceof Date&&!isNaN(o.getTime()),i="string"),d[a].type=i,n=!1),i="string"),d[a].validation||(d[a].validation=s),d[a].category?r=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),d[a].operators&&!this.isLocale||(d[a].operators=this.customOperators[d[a].type+"Operator"]);r&&(l.length>1||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(var a=0,u=e.length;a-1){var r=e.operators[l],n=Object.keys(r),o=n.map(function(e){return r[e]}).join(",").split(","),s=n.indexOf("value");t.operators[o[s]]=o[i]}}(l)},c.prototype.focusEventHandler=function(e){this.target=e.target},c.prototype.clickEventHandler=function(e){var l,i=this,r=e.target;this.isImportRules=!1;var n;if("SPAN"===r.tagName&&(r=r.parentElement),r.className.indexOf("e-collapse-rule")>-1){var o=new t.Animation({duration:1e3,delay:0});this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary();var s=document.getElementById(this.element.id+"_summary_content"),a=s.querySelector(".e-summary-text");o.animate(".e-query-builder",{name:"SlideLeftIn"}),(d=this.element.querySelector(".e-group-container")).style.display="none",a.textContent=this.getSqlFromRules(this.rule),s.style.display="block",a.style.height=a.scrollHeight+"px"}if("BUTTON"===r.tagName&&r.className.indexOf("e-qb-toggle")<0){if(r.className.indexOf("e-removerule")>-1)this.actionButton=r,this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)this.actionButton=r,this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if((o=new t.Animation({duration:1e3,delay:0})).animate(".e-query-builder",{name:"SlideLeftIn"}),document.getElementById(this.element.id+"_summary_content").style.display="none",this.element.querySelectorAll(".e-group-container").length<1){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var u=t.extend({},this.rule,{},!0);this.setGroupRules(u),this.renderSummaryCollapse()}else{var d=this.element.querySelector(".e-group-container");d.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),d.style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1||r.className.indexOf("e-qb-toggle")>-1){var p=t.closest(r,".e-group-container");if(!this.headerTemplate){var c=r.getAttribute("for"),h=void 0;c&&(h=document.getElementById(c).getAttribute("value")),n=p.id.replace(this.element.id+"_","");var m=this.getGroup(n),f=void 0;if(this.enableNotCondition)if(r.className.indexOf("e-qb-toggle")>-1){var g=p.getElementsByClassName("e-qb-toggle")[0];g.className.indexOf("e-active-toggle")>-1?(t.removeClass([g],"e-active-toggle"),f=!1):(t.addClass([g],"e-active-toggle"),f=!0),h=m.condition}else f=m.not;l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase()},this.enableNotCondition&&(l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase(),not:f})}this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){i.beforeSuccessCallBack(e,r)}),this.target=r}},c.prototype.beforeSuccessCallBack=function(e,l){if(!e.cancel){var i=t.closest(l,".e-group-container"),r=i.id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),o=this.getParentGroup(i);o.condition=e.value,this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,type:"condition",value:o.condition}),this.filterRules(n,this.getValidRules(this.rule),"condition")}},c.prototype.selectBtn=function(e,l){"beforeOpen"===l.name?this.showButtons.groupInsert?this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.removeClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):l.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):l.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},c.prototype.appendRuleElem=function(e,l,i,r,n,o){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===i?s=t.select("#"+r,e):((s=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),d.appendChild(s),this.ruleIdCounter++),l&&l.ruleTemplate){u={requestType:"template-initialize",ruleID:s.id,action:n,fields:this.fields,rule:o},this.trigger("actionBegin",u),this.ruleTemplateFn=this.templateParser(l.ruleTemplate);var p=this.element.id+l.field,c=void 0;if(u.fields=this.fields,u.columns=this.columns,u.operators=this.getOperators(o.field),u.operatorFields={text:"key",value:"value"},this.isReact)c=this.ruleTemplateFn(u,this,s.id,p)[0];else if(this.isAngular){var h=this.ruleTemplateFn(u,this,s.id,p);c=3===h[0].nodeType?h[1]:h[0]}else c=this.ruleTemplateFn(u,this,"Template",p)[0];(a=c).className+=" e-rule-field"}else a=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0);return s.appendChild(a),l&&l.ruleTemplate&&this.renderReactTemplates(),s},c.prototype.addRuleElement=function(e,t,l,i,r,n){var o=this;if(e){var s={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(s,e,t,l,i,r,n)):this.trigger("beforeChange",s,function(s){o.addRuleSuccessCallBack(s,e,t,l,i,r,n)})}},c.prototype.addRuleSuccessCallBack=function(e,l,r,n,o,s,a){var u,p,c,h,m=this.element.className.indexOf("e-device")>-1?"250px":"200px",f=r&&r.field?this.getColumn(r.field):n||this.columns[0],g={label:"",field:"",type:"",operator:""};if(!e.cancel){if(f&&f.ruleTemplate){this.selectedColumn=f,p=this.selectedColumn.operators,g={label:f.label,field:f.field,type:f.type,operator:p[0].value};var v=Object.keys(r).length?r:g,y={requestType:"template-create",action:"insert-rule",ruleID:(h=this.appendRuleElem(l,f,o,s,"field",v)).id,fields:this.fields,rule:v};this.trigger("actionBegin",y)}else{(h=this.appendRuleElem(l,f,o,s,"field")).querySelector(".e-filter-input").setAttribute("id",h.id+"_filterkey");var C=h.querySelector("button");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?(C.textContent=this.l10n.getConstant("Remove"),t.addClass([C],"e-flat"),t.addClass([C],"e-primary")):(t.addClass([C],"e-round"),t.addClass([C],"e-icon-btn"),C.setAttribute("title",this.l10n.getConstant("DeleteRule")),C=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),h.querySelector("button").appendChild(C))}if("Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?h.className="e-rule-container e-vertical-mode":h.className="e-rule-container e-horizontal-mode",h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-rule-container")>-1&&(h.className.indexOf("e-joined-rule")<0&&(h.className+=" e-joined-rule"),h.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(h.previousElementSibling.className+=" e-prev-joined-rule")),h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-group-container")>-1&&h.className.indexOf("e-separate-rule")<0&&(h.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(l,r,g,a,s),!f||f&&!f.ruleTemplate){var b=void 0,S=this.isImportRules?this.GetRootColumnName(r.field):r.field;b={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?m:"auto",change:this.changeField.bind(this),value:r?S:null},this.fieldModel&&(b=d({},b,this.fieldModel)),(c=new i.DropDownList(b)).appendTo("#"+h.id+"_filterkey");var x=this.isImportRules?this.GetRootColumnName(r.field):c.value;this.selectedColumn=c.getDataByValue(x),Object.keys(r).length&&this.changeRule(r,{element:c.element,itemData:this.selectedColumn})}u=h.id.replace(this.element.id+"_",""),this.isImportRules||this.trigger("change",{groupID:l.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"})}},c.prototype.updateAddedRule=function(e,l,i,r,n){var o,s,a,u=0;if(r){for(o=t.select("#"+n,e),s=t.closest(e,".e-group-container"),a=this.getParentGroup(s);o&&null!==o.previousElementSibling;)o=o.previousElementSibling,u++;a.rules[u]=l}else s=t.closest(e,".e-group-container"),a=this.getParentGroup(s),Object.keys(l).length?a.rules.push({field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}):a.rules.push(i);this.disableRuleCondition(e,a)},c.prototype.changeRuleTemplate=function(e,l,i,r){var n=this.selectedColumn.operators;if(!e.ruleTemplate){var o=t.closest(l,".e-group-container"),s=t.closest(l,".e-rule-container").id;if(this.previousColumn&&this.previousColumn.ruleTemplate&&(t.detach(l.closest('[id="'+s+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([s])),e){var a={field:e.field,label:e.label,operator:n[0].value,value:""};this.addRuleElement(o,a,e,"change",s,!0)}}},c.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},c.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var l=["isnull","isnotnull","isempty","isnotempty"],i=void 0,r=void 0,n=void 0,o=void 0,s=[],a=void 0,u=void 0,d=void 0,p=void 0,c=void 0,h=this.element.querySelectorAll(".e-rule-container"),m=void 0;for(i=0,r=h.length;i-1?(C=t.closest(y,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):f[g].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(f[g].parentElement),g++}}}else d.element&&t.isNullOrUndefined(d.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},c.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)},c.prototype.refreshLevel=function(e){var l,i,r=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,o=r.length,s=0;for(i=0;i-1&&(e.level.push(s),this.levelColl[l.id]=e.level.slice(),s++,e.groupElement=l,e=this.refreshLevel(e));var a=t.closest(n,".e-rule-list");return e.groupElement=a?t.closest(a,".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},c.prototype.groupTemplate=function(){var e,t,l,i,r,n,o,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),l=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),i=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(l),t.appendChild(i),e.appendChild(t),this.headerTemplate||(r=this.createElement("div",{attrs:{class:"e-lib e-btn-group"}}),this.enableNotCondition&&(n=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),r.appendChild(n)),(n=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),r.appendChild(n),o=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),r.appendChild(o),n=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),r.appendChild(n),o=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),r.appendChild(o),l.appendChild(r),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),l.appendChild(s)),e},c.prototype.ruleTemplate=function(){var e,t,l,i,r,n;return e=this.createElement("div"),r=this.createElement("div",{attrs:{class:"e-rule-field"}}),l=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),l.appendChild(t),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-operator"}}),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value"}}),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),n=this.showButtons.ruleDelete?"e-removerule e-rule-delete e-css e-btn e-small":"e-removerule e-rule-delete e-css e-btn e-small e-button-hide",i=this.createElement("button",{attrs:{class:n}}),l.appendChild(i),r.appendChild(l),e.appendChild(r),e},c.prototype.addGroupElement=function(e,t,l,i,r){var n=this,o={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addGroupSuccess(o,e,t,l,i,r)):this.trigger("beforeChange",o,function(o){n.addGroupSuccess(o,e,t,l,i,r)})},c.prototype.addGroupSuccess=function(e,i,r,n,o,a){if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var u=r,d=void 0,p=this.groupElem.cloneNode(!0);if(p.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),this.headerTemplate&&this.headerTemplateFn(p,a,n),this.groupIdCounter++,!this.headerTemplate){var c=p.querySelector(".e-btngroup-and"),h=p.querySelector(".e-btngroup-or"),m=p.querySelector(".e-btngroup-and-lbl"),f=p.querySelector(".e-btngroup-or-lbl");c.setAttribute("id",this.element.id+"_and"+this.btnGroupId),h.setAttribute("id",this.element.id+"_or"+this.btnGroupId),c.setAttribute("name",this.element.id+"_and"+this.btnGroupId),h.setAttribute("name",this.element.id+"_and"+this.btnGroupId),m.setAttribute("for",this.element.id+"_and"+this.btnGroupId),f.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++}if(i){var g=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";d=this.createElement("button",{attrs:{class:g}}),new l.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(d),d.setAttribute("title",this.l10n.getConstant("DeleteGroup")),t.rippleEffect(d,{selector:".deletegroup"}),this.headerTemplate||p.querySelector(".e-group-action").appendChild(d);for(var v=u.querySelector(".e-rule-list"),y=v.children,C=0,b=0,S=y.length;b-1&&(C+=1);v.appendChild(p);var x=this.levelColl[u.id].slice(0);x.push(C),this.levelColl[p.id]=x,this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],u.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,o&&this.addRuleElement(p,{}))}else u.appendChild(p),this.levelColl[p.id]=[0];if(this.enableNotCondition&&!this.headerTemplate){var O=p.querySelector(".e-qb-toggle");new l.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"}).appendTo(O),p.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule&&this.updatedRule.not&&t.addClass([O],"e-active-toggle")}if(this.updatedRule=null,this.headerTemplate){var E={requestType:"header-template-create",ruleID:p.id,condition:n,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",E)}else{var w=p.querySelector(".e-add-btn");new s.DropDownButton({items:this.items,cssClass:"e-round e-small e-caret-hide e-addrulegroup",iconCss:"e-icons e-add-icon",beforeOpen:this.selectBtn.bind(this,w),select:this.selectBtn.bind(this,w)}).appendTo(w),w.setAttribute("title",this.l10n.getConstant("AddButton"))}if(!this.isImportRules){var N=u.id.replace(this.element.id+"_",""),q=p.id.replace(this.element.id+"_","");this.trigger("change",{groupID:N,type:"insertGroup",childGroupID:q})}}},c.prototype.headerTemplateFn=function(e,t,l){var i,r,n=this.element.id+"_header",o=e.querySelector(".e-group-header");if(this.headerTemplate){if(r={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?t:void 0,condition:l},this.trigger("actionBegin",r),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)i=this.headerFn(r,this,e.id,n)[0];else if(this.isAngular){var s=this.headerFn(r,this,e.id,n);i=3===s[0].nodeType?s[1]:s[0]}else i=this.headerFn(r,this,"Template",n)[0];o.appendChild(i),this.renderReactTemplates()}return e},c.prototype.notifyChange=function(e,l,i){var r=t.closest(l,".e-group-container"),n=this.getParentGroup(r),o=t.closest(l,".e-rule-container"),s=0;if("not"===i)return void(n.not=e);if("condition"===i)return void(n.condition=e);for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,s++;var a=n.rules[s],u=this.getColumn(a.field),d=this.getFormat(u.format);if("date"===u.type)if(e instanceof Date)e=this.intl.formatDate(e,d);else if(e instanceof Array)for(var p=0;p-1?a.value=[]:c.indexOf(p)>-1&&(a.value="");break;case"value":a.value=l}if(this.changeRuleTemplate(this.selectedColumn,e,a,i),this.filterRules(d,this.getValidRules(this.rule),i),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===i||"operator"===i)){var h=t.closest(e,".e-rule-container");this.destroyControls(h,!0),t.detach(h.querySelector(".e-rule-field"));var m=this.appendRuleElem(t.closest(h,".e-group-container"),this.selectedColumn,"change",h.id,i,a);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?m.className="e-rule-container e-vertical-mode":m.className="e-rule-container e-horizontal-mode",m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-rule-container")>-1&&(m.className.indexOf("e-joined-rule")<0&&(m.className+=" e-joined-rule"),m.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(m.previousElementSibling.className+=" e-prev-joined-rule")),m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-group-container")>-1&&m.className.indexOf("e-separate-rule")<0&&(m.className+=" e-separate-rule");var f={requestType:"template-create",action:i,ruleID:h.id,fields:this.fields,rule:a};this.trigger("actionBegin",f)}},c.prototype.changeValue=function(e,l){var i,r,n,o=this;((n=l.event?l.event.target:l.element).className.indexOf("e-day")>-1||n.className.indexOf("e-today")>-1||n.className.indexOf("e-cell")>-1)&&(n=l.element);var s=t.closest(n,".e-group-container"),a=t.closest(n,".e-rule-container");i=s&&s.id.replace(this.element.id+"_",""),r=a.id.replace(this.element.id+"_","");var u=l;u.element&&u.element.className.indexOf("e-datepicker")>-1&&(n=u.element);var d,p,c;n.className.indexOf("e-radio")>-1?(p=parseInt(n.id.split("valuekey")[1],0),c=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=c.getDataByValue(c.value),d=this.selectedColumn.values?this.selectedColumn.values[p]:[!0,!1][p]):d=n.className.indexOf("e-multiselect")>-1?t.getComponent(n,"multiselect").value:l.value,"input"===l.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){o.filterValue(i,r,d,e,n)},this.immediateModeDelay)):this.filterValue(i,r,d,e,n)},c.prototype.filterValue=function(e,t,l,i,r){var n=this,o={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(o,r,i,e,t):this.trigger("beforeChange",o,function(l){n.changeValueSuccessCallBack(l,r,i,e,t)})},c.prototype.changeValueSuccessCallBack=function(e,t,l,i,r){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:i,ruleID:r,value:e.value,cancel:!1,type:"value"}))},c.prototype.changeField=function(e){if(e.isInteracted){var l=t.closest(e.element,".e-rule-filter")||t.closest(e.element,".e-rule-sub-filter");this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0;var i=this.getColumn(e.value);if(i&&i.ruleTemplate)this.templateChange(e.element,i.field,"field");else{for(var r=t.closest(e.element,".e-group-container"),n=this.getParentGroup(r),o=t.closest(e.element,".e-rule-container"),s=0;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,s++;this.changeRule(n.rules[s],e)}}},c.prototype.changeRule=function(e,l){if(l.itemData){var i={},r=t.closest(l.element,".e-rule-filter");r=r||t.closest(l.element,".e-rule-sub-filter");var n=t.getComponent(l.element,"dropdownlist"),o=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(r,n,o,e,i,l)}},c.prototype.changeFilter=function(e,l,i,r,n,o){var s=this;if(e){var a=this.isImportRules?this.GetRootColumnName(l.value):l.value;this.selectedColumn=l.getDataByValue(a);var u=void 0;u={groupID:i,ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:l.value,cancel:!1,type:"field"},this.isImportRules?this.fieldChangeSuccess(u,n,e,r,o):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,n,e,r,o)})}else{var d=t.closest(o.element,".e-rule-operator");this.changeOperator(e,d,l,i,r,n,o)}},c.prototype.changeOperator=function(e,l,i,r,n,o,s){var a,u=this;l?(a={groupID:r,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:i.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(a,e,o,n,s):this.trigger("beforeChange",a,function(t){u.operatorChangeSuccess(t,e,o,n,s)})):this.changeRuleValues(e,n,o,s)},c.prototype.fieldChangeSuccess=function(e,l,i,r,n){for(var o=t.closest(i,".e-rule-container"),s=t.closest(n.element,".e-rule-operator"),a=t.closest(n.element,".e-group-container").id.replace(this.element.id+"_",""),u=t.getComponent(n.element,"dropdownlist"),d=o.querySelectorAll(".e-tooltip.e-input-group"),p=0;p-1?"250px":"200px",p=Object.keys(this.selectedColumn.columns[0]),c=new i.DropDownList({dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:p.length>5?d:"auto",change:this.changeField.bind(this),index:0});if(c.appendTo("#"+u+"_subfilterkey"+this.subFilterCounter),this.isImportRules)for(var h=this.selectedColumn.columns,m=0;m-1){c.value=h[m].field,this.selectedColumn=h[m];break}this.subFilterCounter++,this.subFieldElem=o,n.itemData=n.itemData,this.isImportRules||(this.selectedColumn=this.selectedColumn.columns[0]),this.selectedColumn.columns||this.changeRuleValues(s,l,r,n)},c.prototype.operatorChangeSuccess=function(e,l,i,r,n){if(!e.cancel){var o=t.closest(n.element,".e-rule-operator"),s=o.nextElementSibling,a=t.getComponent(n.element,"dropdownlist"),u=r.operator?r.operator.toString().toLowerCase():"";i.operator=a.value.toString();var d=i.operator.toLowerCase();if(i.operator.toLowerCase().indexOf("between")>-1||i.operator.toLowerCase().indexOf("in")>-1&&i.operator.toLowerCase().indexOf("contains")<0?(l=o.previousElementSibling,i.type=r.type,(i.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(r.value=[])):"object"==typeof r.value&&null!=r.value&&(r.value=r.value.length>0?r.value[0]:"number"===r.type?0:""),n.previousItemData){var p=n.previousItemData.value.toString().toLowerCase();(p.indexOf("between")>-1||(p.indexOf("in")>-1||p.indexOf("null")>-1||p.indexOf("empty")>-1)&&p.indexOf("contains")<0)&&(l=o.previousElementSibling,i.type=r.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),i.operator.indexOf("null")>-1||i.operator.indexOf("empty")>-1){var c=o.parentElement.querySelector(".e-rule-value"),h=c.querySelector(".e-tooltip.e-input-group");h&&t.getComponent(h,"tooltip").destroy(),t.removeClass([c],"e-show"),t.addClass([c],"e-hide")}s&&this.getColumn(r.field).template&&(l=o.previousElementSibling),this.changeRuleValues(l,r,i,n)}},c.prototype.changeRuleValues=function(e,l,r,n){var o,s,a,u=t.closest(n.element,".e-rule-operator");if(e)if(u=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(r.type=this.selectedColumn.type,u=u.classList.contains("e-rule-sub-filter")?u.nextElementSibling:u),t.addClass([u],"e-operator"),u.childElementCount){o=t.getComponent(u.querySelector(".e-dropdownlist"),"dropdownlist");var p=t.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist");r.operator=o.value,r.type=this.getColumn(p.value).type;var c=n.itemData;this.renderValues(u,c,n.previousItemData,!0,l,r,n.element)}else{var h=t.closest(u,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:h+"_operatorkey"}}),u.appendChild(a),this.selectedColumn.operators?s=this.selectedColumn.operators:n.itemData&&(s=this.customOperators[this.selectedColumn.type+"Operator"]);var m=this.element.className.indexOf("e-device")>-1?"250px":"200px",f=s[0].value;f=l&&""!==l.operator?l.operator:f;var g=void 0;g={dataSource:s,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:s.length>5?m:"auto",change:this.changeField.bind(this),index:0,value:f},this.operatorModel&&(g=d({},g,this.operatorModel)),new i.DropDownList(g).appendTo("#"+h+"_operatorkey"),r.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(r.type=this.selectedColumn.type,r.operator=l.operator),this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,r,n.element)}this.isImportRules||this.updateRules(n.element,n.item)},c.prototype.destroyControls=function(e,l){var i,r=l?e:e.nextElementSibling;i=r.querySelectorAll("input.e-control");var n;n=r.querySelectorAll("div.e-control:not(.e-handle)");for(var o=this.columns,s=0,a=i.length;s-1&&t.getComponent(i[s].parentElement,"tooltip").destroy(),t.getComponent(i[s],"dropdownlist").destroy();else if(i[s].classList.contains("e-radio"))t.getComponent(i[s],"radio").destroy();else if(i[s].classList.contains("e-numerictextbox"))t.getComponent(i[s],"numerictextbox").destroy(),t.detach(t.select("input#"+i[s].id,r));else if(i[s].classList.contains("e-datepicker"))t.getComponent(i[s],"datepicker").destroy();else if(i[s].classList.contains("e-multiselect"))t.getComponent(i[s],"multiselect").destroy();else if(i[s].className.indexOf("e-template")>-1)for(var u=i[s].className,d=0,p=o.length;d-1){this.templateDestroy(o[d],i[s].id);break}document.getElementById(i[s].id)&&t.detach(i[s])}for(var s=0,a=n.length;s-1)for(var u=n[s].className,d=0,p=o.length;d-1){this.templateDestroy(o[d],n[s].id);break}t.detach(n[s])}for(var c,s=0,a=(c=r.querySelectorAll(".e-template:not(.e-control)")).length;s0&&(r=e.split(this.separator));var n=this.dataColl;if(this.dataColl[1])for(var o=0,s=n.length;o1)for(var u=n[o],d=void 0,p=0,c=r.length;p1?this.createNestedObject(a,r,t):a[e]=t,i.push(a))}return i},c.prototype.createNestedObject=function(e,t,l){for(var i,r=t.length-1,n=0;n-1&&(a=!0,s=this.getDistinctValues(this.dataColl,e.field)),a=!e.columns&&a,!this.dataColl.length&&o.length&&(u=!0);var p;p={dataSource:u?o:a?s:this.dataManager,query:new r.Query([e.field]),fields:{text:this.selectedRule.field,value:this.selectedRule.field},placeholder:this.l10n.getConstant("SelectValue"),value:n,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,l),close:this.closePopup.bind(this,l),actionBegin:this.multiSelectOpen.bind(this,t+"_valuekey"+l)},this.valueModel&&this.valueModel.multiSelectModel&&(p=d({},p,this.valueModel.multiSelectModel));var c=new i.MultiSelect(p);c.appendTo("#"+t+"_valuekey"+l),this.updateRules(c.element,n,0)},c.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof r.DataManager){var i=document.getElementById(e),n=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist");this.selectedColumn=n.getDataByValue(n.value);var o=this.selectedColumn.field,s=!1;this.dataColl[1]&&Object.keys(this.dataColl[1]).indexOf(o)>-1&&(s=!0),s||(l.cancel=!0,this.bindMultiSelectData(i,o))}},c.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},c.prototype.getMultiSelectData=function(e,l){var i,n=this,o=new r.Deferred,s=this.dataManager.executeQuery((new r.Query).select(l)),u=t.getComponent(e,"multiselect");u.hideSpinner(),this.createSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),a.showSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),s.then(function(r){i=r.actual&&r.actual.result?r.actual.result:r.result,n.dataColl=t.extend(n.dataColl,i,[],!0),u.dataSource=n.getDistinctValues(n.dataColl,l),a.hideSpinner(t.closest(e,".e-multi-select-wrapper").parentElement)}).catch(function(e){o.reject(e)})},c.prototype.createSpinner=function(e){var l=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(l),a.createSpinner({target:l,width:t.Browser.isDevice?"16px":"14px"})},c.prototype.closePopup=function(e,l){var i=document.getElementById(l.popup.element.id.replace("_popup","")),r=t.getComponent(i,"multiselect").value;this.updateRules(i,r,e)},c.prototype.processTemplate=function(e,l,i,r){var n,o=t.closest(e,".e-rule-container"),s=o.querySelectorAll(".e-template");n=t.getComponent(o.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist");var a=this.getColumn(n.value);if("string"==typeof l.template||void 0===l.template.write){var u={rule:i,ruleID:o.id,operator:r.operator,field:a.field,requestType:"value-template-create"};this.trigger("actionBegin",u)}else{var d=l.template;"string"==typeof d.write?t.getValue(d.write,window)({elements:s.length>1?s:s[0],values:i.value,operator:r.operator,field:a.field,dataSource:a.values}):l.template.write({elements:s.length>1?s:s[0],values:i.value,operator:r.operator,field:a.field,dataSource:a.values})}},c.prototype.getItemData=function(e){var l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist");return this.getColumn(l.value)},c.prototype.setDefaultValue=function(e,l,i){var r=this.getItemData(e);if(t.isNullOrUndefined(r.value))return i?l?[0,0]:0:l?[]:"";if(l){if(!(r.value instanceof Array))return[r.value]}else if(r.value instanceof Array)return r.value[0];return r.value},c.prototype.renderStringValue=function(e,t,l,i,r){var o,s,a=this.getItemData(e),u="string"==typeof a.template;if(s=this.isImportRules||this.isPublic||u?t.value:this.setDefaultValue(e,!1,!1),"in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values){"in"!==l&&"notin"!==l||(s=(o=this.isImportRules?t.value:this.setDefaultValue(e,!0,!1)).join(","));var p=void 0;p={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.textBoxModel&&(p=d({},p,this.valueModel.textBoxModel));var c=new n.TextBox(p);c.appendTo("#"+e+"_valuekey"+i),c.value=s,c.dataBind()}else o=this.isImportRules?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,i,o,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?r.style.width="100%":(r.style.width=null,r.style.minWidth="200px")},c.prototype.renderNumberValue=function(e,l,i,r,o,s,a){var u=this.getItemData(e),p="string"==typeof u.template,c=this.isImportRules||this.isPublic||p?l.value:this.setDefaultValue(e,!1,!0);if("in"!==i&&"notin"!==i||!this.dataColl.length&&!u.values)if("in"===i||"notin"===i){var h=(c=this.isImportRules?l.value:this.setDefaultValue(e,!0,!1)).join(","),m=void 0;m={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,r)},this.valueModel&&this.valueModel.textBoxModel&&(m=d({},m,this.valueModel.textBoxModel));var f=new n.TextBox(m);f.appendTo("#"+e+"_valuekey"+r),f.value=h,f.dataBind()}else{var g=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),v=(s=this.getColumn(g.value)).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,C=s.format?s.format:"n";a>1&&l&&(c=l.value[r]?l.value[r]:this.setDefaultValue(e,!0,!0));var b=void 0;b={value:c instanceof Array?c[r]:c,format:C,min:v,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,r)},this.valueModel&&this.valueModel.numericTextBoxModel&&(b=d({},b,this.valueModel.numericTextBoxModel)),new n.NumericTextBox(b).appendTo("#"+e+"_valuekey"+r)}else c=this.isImportRules?l.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(u,e,r,c,u.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null)},c.prototype.processValueString=function(e,t){var l=[],i=e.split(",");if("string"===t)return i;for(var r=0,n=i.length;r-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,p=void 0;if(p=r.operator.toString(),e.className.indexOf("e-rule-operator")>-1||e.className.indexOf("e-rule-filter")>-1){u=e.parentElement.querySelector(".e-rule-value"),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?u.style.width="100%":"in"!==p&&"notin"!==p?t.addClass([u],"e-custom-value"):t.removeClass([u],"e-custom-value");for(var c=0;c1?i.value[c]:i.value,h=this.parseDate(m,f.format)):h=i.value),g){var S=this.getFormat(g);S.skeleton?(y={locale:this.getLocale(),value:h,placeholder:C,format:S,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y)):(y={value:h,locale:this.getLocale(),placeholder:C,format:S.format,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y))}else y={locale:this.getLocale(),value:h,placeholder:C,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y);if(v.appendTo("#"+a+"_valuekey"+c),!i.value){var x=document.getElementById(a+"_valuekey"+c);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},c.prototype.processBoolValues=function(e,i,r,n){var o,s,a=!1;t.isNullOrUndefined(i.type)&&e&&(i.type=e.type);var u;if(e.values){p=e.values;"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toLowerCase()===i.value.toString().toLowerCase(),s=o=u=p[n]}else{var p=[!0,!1];"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toString().toLowerCase()===i.value.toString().toLowerCase(),o=p[n].toString(),s=p[n],u=this.l10n.getConstant(["True","False"][n])}var c;c={label:u,name:r+"default",checked:a,value:o,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.radioButtonModel&&(c=d({},c,this.valueModel.radioButtonModel));var h=new l.RadioButton(c);h.appendTo("#"+r+"_valuekey"+n),a&&this.updateRules(h.element,s,0)},c.prototype.getOperatorIndex=function(e,t){var l,i=e.dataSource.length;for(l=0;l-1?l:this.selectedRule).operators&&(p.value=null,p.dataBind(),p.dataSource=l.operators,p.index=this.getOperatorIndex(p,n),p.value=o.operator=p.dataSource[p.index].value,p.dataBind())}var c=o.operator.toString(),h=!1;if(c.indexOf("null")>-1||c.indexOf("empty")>-1)(g=e.parentElement.querySelector(".e-rule-value"))&&(t.removeClass([g],"e-show"),t.addClass([g],"e-hide"));else{var m=t.closest(e,".e-rule-container").id;if((i=this.getPreviousItemData(i,d))&&i.template){this.templateDestroy(i,m+"_valuekey0");var f=t.select("#"+m+"_valuekey0",e.nextElementSibling);f&&!f.classList.contains("e-control")&&t.detach(t.select("#"+m+"_valuekey0",e.nextElementSibling)),"string"!=typeof i.template&&void 0!==i.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([m]),e.nextElementSibling.innerHTML="")}if(r&&(this.validatValue(n,t.closest(e,".e-rule-container")),this.destroyControls(e)),l.template=d.template,l.template&&(t.addClass([e.nextElementSibling],"e-template-value"),l.template=d.template,h=this.setColumnTemplate(l,m,d.field,l.value||c,e,n)),h){var g=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?g.style.width="100%":g.style.width="200px"}else{t.removeClass([e.nextElementSibling],"e-template-value");var v=1;v="boolean"===o.type?this.selectedColumn.values?this.selectedColumn.values.length:2:c&&c.toLowerCase().indexOf("between")>-1?2:1;for(var y=0;y-1&&(i=3);var r=e.className.split(" e-")[i],n=parseInt(e.id.slice(-1),2);switch(r){case"checkbox":var o=t.getComponent(e,r).value;l.value=""!==o?o:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,r).value;break;case"radio":var s=t.getComponent(e,r);s.checked&&("boolean"==typeof l.value?l.value="true"===s.value:this.getColumn(l.field).values?l.value=s.value:l.value="true"===s.value),s.refresh();break;case"numerictextbox":l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=t.getComponent(e,r).value):l.value=t.getComponent(e,r).value;break;case"datepicker":var a=this.getColumn(l.field),u=this.getFormat(a.format),d=t.getComponent(e,r).value;l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=this.intl.formatDate(d,u)):t.isNullOrUndefined(u.format)&&d?l.value=this.intl.formatDate(d):l.value=d?this.intl.formatDate(d,u):d;break;case"multiselect":l.value=t.getComponent(e,r).value}},c.prototype.updateRules=function(e,l,i,r){for(var n,o,s,a=t.closest(e,".e-group-container"),u=this.getParentGroup(a),d=t.closest(e,".e-rule-container"),p=0,c=a.id.replace(this.element.id+"_",""),h=this.getValidRules(this.rule);d&&null!==d.previousElementSibling;)d=d.previousElementSibling,p++;var m=u.rules[p].operator?u.rules[p].operator.toString():"";if(d=t.closest(e,".e-rule-container"),s=d.id.replace(this.element.id+"_",""),t.closest(e,".e-rule-filter")||t.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem),n=t.getComponent(e,"dropdownlist");var f=this.getColumn(n.value);!this.isImportRules&&u.rules[p].field&&u.rules[p].field.toLowerCase()!==f.field.toLowerCase()&&(!d.querySelectorAll(".e-template")&&!(m.indexOf("null")>-1)||m.indexOf("empty")>-1)&&(u.rules[p].value=""),this.selectedColumn=n.getDataByValue(n.value),u.rules[p].field=this.selectedColumn.field,u.rules[p].type=this.selectedColumn.type,u.rules[p].label=this.selectedColumn.label;var g=t.closest(e,".e-rule-filter"),v=(g=g||t.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control");v=v||g.nextElementSibling.nextElementSibling.querySelector("input.e-control"),m=t.getComponent(v,"dropdownlist").value.toString(),u.rules[p].operator=m;var y=g.nextElementSibling.nextElementSibling,C=y.querySelectorAll("input.e-control");C.length<1&&(C=y.querySelectorAll("div.e-control")),C.length<1&&(C=y.querySelectorAll(".e-template"));for(var b=0;b-1||m.indexOf("empty")>-1?u.rules[p].value=null:this.updateValues(C[b],u.rules[p]);this.isImportRules||this.trigger("change",o),this.allowValidation&&u.rules[p].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(h,this.getValidRules(this.rule),"field")}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),u.rules[p].operator=n.value.toString();var S=void 0;S=d.querySelectorAll(".e-rule-value input.e-control"),o={groupID:c,ruleID:s,value:n.value,type:"operator"},this.allowValidation&&u.rules[p].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),S.length>1&&!(S[0].className.indexOf("e-template")>-1)&&(u.rules[p].value=[]);for(var x=0;x-1||u.rules[p].operator.indexOf("empty")>-1?u.rules[p].value=null:S[x].classList.contains("e-template")||this.updateValues(S[x],u.rules[p]);this.isImportRules||this.trigger("change",o),this.filterRules(h,this.getValidRules(this.rule),"operator")}else t.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,l,u,p,a,d,i),r||this.filterRules(h,this.getValidRules(this.rule),"value"))},c.prototype.filterRules=function(e,t,l){JSON.stringify({condition:e.condition,not:e.not,rule:e.rules})!==JSON.stringify({condition:t.condition,not:t.not,rule:t.rules})&&(this.isImportRules||this.trigger("ruleChange",{previousRule:e,rule:t,type:l}))},c.prototype.ruleValueUpdate=function(e,l,r,n,o,s,a){var u,d,p=["in","between","notin","notbetween"];if(r.rules[n].operator&&(d=r.rules[n].operator.toString().toLowerCase()),null!==l){if(e.className.indexOf("e-multiselect")>-1&&"number"===r.rules[n].type&&!this.isNotified){for(var c=[],h=l,m=0,f=h.length;m-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?r.rules[n].value[a]=l:r.rules[n].value=l;else if(e.className.indexOf("e-radio")>-1)r.rules[n].value=l;else if(e.className.indexOf("e-multiselect")>-1)r.rules[n].value=l;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(r.rules[n].type,r.rules[n].value=this.processValueString(l,r.rules[n].type)):r.rules[n].value=l;else if(e.className.indexOf("e-datepicker")>-1){var g=t.getInstance(s.querySelector(".e-rule-filter input"),i.DropDownList),v=this.getFormat(this.getColumn(g.value).format);v.type&&(p.indexOf(d)>-1?("string"==typeof r.rules[n].value&&(r.rules[n].value=[]),r.rules[n].value[a]=this.intl.formatDate(l,v)):r.rules[n].value=this.intl.formatDate(l,v))}this.validatValue(r,s,n)}else e.className.indexOf("e-datepicker")>-1&&p.indexOf(d)>-1?("string"==typeof r.rules[n].value&&(r.rules[n].value=[]),r.rules[n].value[a]=l):r.rules[n].value=l},c.prototype.validatValue=function(e,l,i){t.isNullOrUndefined(i)||(e=e.rules[i]);var r="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(i)||(r?e.value.length>0:e.value))){var n=l.querySelectorAll(".e-rule-value .e-control");n.length>0&&(n[0].className.indexOf("e-tooltip")>-1?t.getComponent(n[0],"tooltip").destroy():n[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[0].parentElement,"tooltip").destroy(),n[1]&&n[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[1].parentElement,"tooltip").destroy())}},c.prototype.getFormat=function(e){var t;return e?"string"==typeof e?(t={type:"dateTime"},"short"===e||"yMd"===e?(t.type="date",t.skeleton=e):t.format=e):t={type:"dateTime",skeleton:e.skeleton}:t={type:"date",skeleton:"yMd"},t},c.prototype.findGroupByIdx=function(e,t,l){var i=t.rules,r=[];if(!l){for(var n=0,o=i.length;n-1&&this.renderSummaryCollapse(),n.style.display="block",o.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":e.showButtons.ruleDelete?t.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"),e.showButtons.groupDelete?t.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide");break;case"cssClass":l.cssClass&&t.removeClass([this.element],l.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?(t.addClass([this.element],"e-rtl"),this.notGroupRtl()):(t.removeClass([this.element],"e-rtl"),this.notGroupRtl());break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource,this.refresh();break;case"columns":this.columns=e.columns,this.columnSort();break;case"sortDirection":this.sortDirection=e.sortDirection,this.columnSort();break;case"maxGroupCount":this.maxGroupCount=e.maxGroupCount;break;case"height":this.height=e.height,this.element.style.height=this.height;break;case"rule":this.rule=e.rule,e.rule=this.getRuleCollection(this.rule,!1);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new t.Internationalization(this.locale),this.isLocale=!0,this.refresh(),this.isLocale=!1;break;case"enableNotCondition":this.onChangeNotGroup();break;case"readonly":this.isReadonly=e.readonly,this.enableReadonly()}},c.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",Equal:"Equal",NotEqual:"Not Equal",LessThan:"Less Than",LessThanOrEqual:"Less Than Or Equal",GreaterThan:"Greater Than",GreaterThanOrEqual:"Greater Than Or Equal",Between:"Between",NotBetween:"Not Between",In:"In",NotIn:"Not In",Remove:"REMOVE",SelectField:"Select a field",SelectOperator:"Select operator",DeleteRule:"Remove this condition",DeleteGroup:"Delete group",AddGroup:"Add Group",AddCondition:"Add Condition",Edit:"EDIT",ValidationMessage:"This field is required",SummaryViewTitle:"Summary View",OtherFields:"Other Fields",AND:"AND",OR:"OR",NOT:"NOT",SelectValue:"Enter Value",IsEmpty:"Is Empty",IsNotEmpty:"Is Not Empty",IsNull:"Is Null",IsNotNull:"Is Not Null",True:"true",False:"false",AddButton:"Add Group/Condition"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.subFilterCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")},{value:"isempty",key:this.l10n.getConstant("IsEmpty")},{value:"isnotempty",key:this.l10n.getConstant("IsNotEmpty")}],dateOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],booleanOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],numberOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"between",key:this.l10n.getConstant("Between")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")}]},this.operators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:"IN",notin:"NOT IN",lessthanorequal:"<=",startswith:"LIKE",endswith:"LIKE",between:"BETWEEN",notbetween:"NOT BETWEEN",contains:"LIKE",isnull:"IS NULL",isnotnull:"IS NOT NULL",isempty:"IS EMPTY",isnotempty:"IS NOT EMPTY",notstartswith:"NOT LIKE",notendswith:"NOT LIKE",notcontains:"NOT LIKE"},this.fields||(this.fields={text:"label",value:"field"})},c.prototype.render=function(){this.levelColl={},this.items=[{text:this.l10n.getConstant("AddGroup"),iconCss:"e-icons e-add-icon e-addgroup"},{text:this.l10n.getConstant("AddCondition"),iconCss:"e-icons e-add-icon e-addrule"}],this.ruleElem=this.ruleTemplate(),this.groupElem=this.groupTemplate();var e=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}],t=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}];this.customOperators.stringOperator=this.customOperators.stringOperator.concat(e),this.customOperators.numberOperator=this.customOperators.numberOperator.concat(t),this.dataSource instanceof r.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new r.Query).take(1))):(this.dataManager=new r.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new r.Query),this.initControl()),this.renderComplete()},c.prototype.templateParser=function(e){if(e)try{if(document.querySelectorAll(e).length)return t.compile(document.querySelector(e).innerHTML.trim())}catch(l){return t.compile(e)}},c.prototype.executeDataManager=function(e){var t=this,l=this.dataManager.executeQuery(e),i=new r.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){i.reject(e)})},c.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},c.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this),t.EventHandler.add(e,"focusout",this.focusEventHandler,this),t.EventHandler.add(e,"focusin",this.focusEventHandler,this),t.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this)},c.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler),t.EventHandler.remove(e,"focusout",this.focusEventHandler),t.EventHandler.remove(e,"focusin",this.focusEventHandler),t.EventHandler.remove(this.element,"keydown",this.keyBoardHandler)},c.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[e],i=t?l.length-1:l.length,r=this.rule,n=0;n-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),d&&d.className.indexOf("e-rule-container")>-1&&t.addClass([d],"e-prev-joined-rule"));var h=i.parentElement.parentElement.parentElement,m=[];if(this.isReact||this.isAngular){var f=r.rules[n],g=l.querySelectorAll(".e-rule-container");if(f&&f.rules)for(var v=0;v1?(i.disabled=!1,r.disabled=!1,(r.nextElementSibling.classList.contains("e-btn-disable")||i.nextElementSibling.classList.contains("e-btn-disable"))&&(r.nextElementSibling.classList.remove("e-btn-disable"),i.nextElementSibling.classList.remove("e-btn-disable")),t&&"or"===t.condition?r.checked=!0:i.checked=!0):(i.checked=!1,i.disabled=!0,r.checked=!1,r.disabled=!0,t&&(r.nextElementSibling.classList.add("e-btn-disable"),i.nextElementSibling.classList.add("e-btn-disable")))}},c.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,i=e.not,r=t.extend([],e.rules,[],!0);return this.getRuleCollection({condition:l,rules:r,not:i},!0)},c.prototype.getRuleCollection=function(e,t){var l;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||t))for(var i=e.rules.length,r=0;r-1||e.operator.toString().indexOf("empty")>-1)&&(e.value=null),this.isRefreshed&&this.enablePersistence||""!==this.rule.field&&""!==e.operator&&""!==e.value&&void 0!==e.value){var n=e.custom;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},n&&(e.custom=n)}else e={};return e},c.prototype.setRules=function(e){var l=t.extend({},e,{},!0);this.setGroupRules(l)},c.prototype.getRules=function(){return this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules}},c.prototype.getRule=function(e){var l,i,r=0;e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(i=this.element.id+"_"+e,l=document.getElementById(i));for(var n=t.closest(l,".e-group-container"),o=this.getParentGroup(n);null!==l.previousElementSibling;)l=l.previousElementSibling,r++;return o.rules[r]},c.prototype.getGroup=function(e){e instanceof Element&&e.className.indexOf("e-group-container")<1&&(e=t.closest(e,".e-group-container"));var l=e instanceof Element?e.id:this.element.id+"_"+e,i=this.getParentGroup(l);return this.enableNotCondition?{rules:i.rules,condition:i.condition,not:i.not}:{rules:i.rules,condition:i.condition}},c.prototype.deleteGroups=function(e){var t,l,i=e.length;for(t=0;t-1&&s[d].rules)(i=this.getPredicate(s[d]))&&(l=l?"and"===e.condition?l.and(i):l.or(i):i);else if(s[d].operator.length){var c=s[d].operator.toLowerCase(),h=!1,m=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"];if("string"===s[d].type&&(a=!this.matchCase),"date"===s[d].type&&m.indexOf(c)>-1&&(a=!0),o=this.getColumn(s[d].field),c.indexOf("null")>-1||c.indexOf("empty")>-1)s[d].value=null;else if("date"!==s[d].type||s[d].value instanceof Array)n=s[d].value;else{var f=this.getFormat(o.format);t.isNullOrUndefined(s[d].value)?n=null:(n=this.getDate(s[d].value,f),m.indexOf(c)>-1&&!this.isTime(s[d].value)&&(h=!0))}if(0===d)h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contains")<0?l=h?this.datePredicate(s[d],n):this.arrayPredicate(s[d]):""!==(g=n)&&u.indexOf(c)<0&&(l=new r.Predicate(s[d].field,s[d].operator,n,a));else{if(u.indexOf(c)>-1)continue;if(h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contains")<0)l=h?this.datePredicate(s[d],n,l,e.condition):this.arrayPredicate(s[d],l,e.condition);else if("and"===e.condition){g=n;l&&""!==g?l=l.and(s[d].field,s[d].operator,n,a):""!==g&&(l=new r.Predicate(s[d].field,s[d].operator,n,a))}else{var g=n;l&&""!==g?l=l.or(s[d].field,s[d].operator,n,a):""!==g&&(l=new r.Predicate(s[d].field,s[d].operator,n,a))}}}return l},c.prototype.getLocale=function(){var e=this.locale;return t.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",t.cldrData)||(e="en"),e},c.prototype.getColumn=function(e,t){for(var l,i=this.columns,r=0,n=(i=t||i).length;r-1||s.indexOf("empty")>-1)switch(s){case"isnull":n=new r.Predicate(e.field,"isnull",a);break;case"isnotnull":n=new r.Predicate(e.field,"notnull",a);break;case"isempty":n=new r.Predicate(e.field,"equal","");break;case"isnotempty":n=new r.Predicate(e.field,"notequal","")}if(!(s.indexOf("null")>-1||s.indexOf("empty")>-1))for(var d=0,p=o.length;d-1&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((l=new Date).setHours(parseInt(e.split(":")[0])),l.setMinutes(parseInt(e.split(":")[1])),e.split(":")[2]&&l.setSeconds(parseInt(e.split(":")[2]))),l},c.prototype.isTime=function(e){return!!(e&&e.indexOf(":")>-1)},c.prototype.importRules=function(e,l,i,r){if(i){if(e.rules.length>1&&!this.headerTemplate){var n=l.querySelector(".e-btngroup-or"),o=l.querySelector(".e-btngroup-and");n.disabled=!1,o.disabled=!1,"or"===e.condition?n.checked=!0:o.checked=!0}else this.disableRuleCondition(l);if(this.enableNotCondition&&!this.headerTemplate){var s=l.querySelector(".e-qb-toggle");e.not?t.addClass([s],"e-active-toggle"):t.removeClass([s],"e-active-toggle")}}else l=this.renderGroup(e.condition,l,r);var a=e.rules;if(!t.isNullOrUndefined(a))for(var u=0,d=a.length;u-1?(l=this.renderGroup(a[u].condition,l,a[u].not),l=this.importRules(a[u],l,!0)):this.renderRule(a[u],l)}return(l=t.closest(l,".e-rule-list"))&&(l=t.closest(l,".e-group-container")),l},c.prototype.renderGroup=function(e,t,l){this.addGroupElement(!0,t,e,!1,l);var i=t.querySelectorAll(".e-group-container");return i[i.length-1]},c.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},c.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),r=0;r-1)return!0;return!1},c.prototype.getSqlString=function(e,t,l){var i=!1;l||""===l?l+="(":(l="",i=!0);var r=e.condition;e.not&&(l+=i?"NOT (":" NOT (");for(var n=0,o=e.rules.length;n-1)"date"!==s.type||this.isDateFunction(s.value[0])?a+=s.value[0]+" AND "+s.value[1]:a+='"'+s.value[0]+'" AND "'+s.value[1]+'"';else if("string"==typeof s.value[0]&&null!==s.value){a+='("'+s.value[0]+'"';for(var u=1,d=s.value.length;u-1?a+=s.value?'("'+s.value+'%")':"("+s.value+")":s.operator.toString().indexOf("endswith")>-1?a+=s.value?'("%'+s.value+'")':"("+s.value+")":s.operator.toString().indexOf("contains")>-1?a+=s.value?'("%'+s.value+'%")':"("+s.value+")":"number"===s.type||"boolean"==typeof s.value||null===s.value?a+=s.value:a+='"'+s.value+'"';s.operator.toString().indexOf("null")>-1||s.operator.toString().indexOf("empty")>-1?(t?s.field="`"+s.field+"`":s.field.indexOf(" ")>-1&&(s.field='"'+s.field+'"'),l+=s.field+" "+this.operators[s.operator]):(t?s.field="`"+s.field+"`":s.field.indexOf(" ")>-1&&(s.field='"'+s.field+'"'),l+=s.field+" "+this.operators[s.operator]+" "+a)}n!==o-1&&(l+=" "+r.toUpperCase()+" ")}return i||(l+=")"),e.not&&(l+=")"),l},c.prototype.setRulesFromSql=function(e){e=e.replace(/`/g,"");var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,not:t.not,rules:t.rules})},c.prototype.getRulesFromSql=function(e){this.parser=[],this.sqlParser(e),this.rule={condition:"and",not:!1,rules:[]};var t=this.processParser(this.parser,this.rule,[0]);return this.enableNotCondition?{condition:t.condition,not:t.not,rules:t.rules}:{condition:t.condition,rules:t.rules}},c.prototype.getSqlFromRules=function(e,t){return e||(e=this.getValidRules()),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t).replace(/"/g,"'")},c.prototype.sqlParser=function(e){var t,l=0;do{t=e.slice(l),l+=this.parseSqlStrings(t)}while(""!==t);return this.parser},c.prototype.parseSqlStrings=function(e){for(var t,l,i=["=","!=","<=",">=","<",">"],r=["AND","OR","NOT"],n=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"],o=0,s=i.length;o":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween","is empty":"isempty","is null":"isnull","is not null":"isnotnull","is not empty":"isnotempty"};if(e){if(0===e.indexOf("%")&&"%"===e[e.length-1])return"not like"===t?"notcontains":"contains";if(0!==e.indexOf("%")&&e.indexOf("%")===e.length-1)return"not like"===t?"notstartswith":"startswith";if(0===e.indexOf("%")&&e.indexOf("%")!==e.length-1)return"not like"===t?"notendswith":"endswith"}else{if("not like"===t)return"notequal";if("like"===t)return"equal"}return l[t]},c.prototype.getTypeFromColumn=function(e){for(var t=this.columns,l=0;l-1||e[f+1][1].indexOf("empty")>-1)n.operator=this.getOperator(" ",e[f+1][1]),n.value=null,n.type=this.getTypeFromColumn(n);else{var v=e[f+3][1]?e[f+3][1].replace(/'/g,""):e[f+3][1];n.operator=this.getOperator(v,e[f+1][1])}for(c=e[f+1][1],i=++f+1,r=g,i=f+1;i-1||c.indexOf("empty")>-1)break;if(c.indexOf("like")>-1&&"String"===e[i][0]){var y=e[i][1]?e[i][1].replace(/'/g,"").replace(/%/g,""):e[i][1];n.value=y,n.type="string"}else if(c.indexOf("between")>-1){if("Literal"===e[i][0]||"Left"===e[i][0])break;"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""))}else"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""));n.type=this.getTypeFromColumn(n)}c.indexOf("like")<0&&("Number"===e[i-1][0]?(n.value=h,n.type="number"):"String"===e[i-1][0]?(n.value=m,n.type="string"):c.indexOf("between")>-1&&"Conditions"===e[i-1][0]&&(n.value=h,n.type="number"),h=[],m=[],n.type=this.getTypeFromColumn(n))}else"Operators"===e[f+1][0]&&(n.operator=this.getOperator(e[f+2][1],e[f+1][1]),"Number"===e[f+2][0]?(n.type="number",n.value=Number(e[f+2][1])):(n.type="string",n.value=e[f+2][1]?e[f+2][1].replace(/'/g,""):e[f+2][1]),n.type=this.getTypeFromColumn(n));t.rules.push(n)}else{if("Left"===e[f][0]){if("Left"!==e[0][0]&&"not"===e[f-1][1])continue;for(this.parser=e.splice(f+1,g-(f+1)),o=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},p=0,a=t.rules.length,s=0;s