@syncfusion/ej2-querybuilder
Advanced tools
Comparing version 16.4.47 to 17.1.1-beta
/*! | ||
* filename: ej2-querybuilder.umd.min.js | ||
* version : 16.4.47 | ||
* version : 17.1.1-beta | ||
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved. | ||
@@ -10,3 +10,3 @@ * Use of this code is subject to the terms of our license. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t(e.ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,t,r,n,l,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(e,t,r,n){var l,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(i=(o<3?l(i):o>3?l(t,r,i):l(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};n.MultiSelect.Inject(n.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(r,n){var l=e.call(this,r,n)||this;return l.groupIdCounter=0,l.ruleIdCounter=0,l.btnGroupId=0,l.isImportRules=!1,l.parser=[],l.intl=new t.Internationalization,l}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,n=!1,l=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(l=this.dataSource[0][i[s].field]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),i[s].type=r,n=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(s=0,a=e.length;s<a;s++)"string"===(r=typeof(l=this.dataSource[0][e[s]]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:n?"date":r,validation:o},n=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var n=t.extend({},this.rule,{},!0);this.setGroupRules(n),this.renderSummaryCollapse()}else{(l=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),l.style.display="block"}else if(r.className.indexOf("e-collapse-rule")>-1){var l;(l=this.element.querySelector(".e-group-container")).style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i);this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var l=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.className="e-rule-container e-vertical-mode":l.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=l.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)h.textContent=this.l10n.getConstant("Remove");else{t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn");new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),l.querySelector("button").appendChild(h)}if(l.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,l.querySelector(".e-filter-input").setAttribute("id",l.id+"_filterkey"),c.appendChild(l),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-rule-container")>-1&&(l.className.indexOf("e-joined-rule")<0&&(l.className+=" e-joined-rule"),l.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(l.previousElementSibling.className+=" e-prev-joined-rule")),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-group-container")>-1&&l.className.indexOf("e-separate-rule")<0&&(l.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new n.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+l.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.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)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,n=void 0,l=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,n=c.length;r<n;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,l=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(l=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),l=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,f=m.length;y<f;y++){var g=m[y],v=void 0;g.parentElement.className.indexOf("e-searcher")>-1?(v=t.closest(g,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(v):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,n,l,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),n=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(n),e.appendChild(t),l=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),l.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),l.appendChild(i),r.appendChild(l),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,n,l,o;return e=this.createElement("div"),l=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",n=this.createElement("button",{attrs:{class:o}}),r.appendChild(n),l.appendChild(r),e.appendChild(l),e},d.prototype.addGroupElement=function(e,n,l,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}});new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i);new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=n.querySelector(".e-rule-list"),f=n.querySelectorAll(".e-group-container").length;y.appendChild(u);var g=this.levelColl[n.id].slice(0);g.push(f),this.levelColl[u.id]=g,this.isImportRules||(this.addGroups([],n.id),o&&this.addRuleElement(u,{}))}else n.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===l&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var v=u.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,v),select:this.selectBtn.bind(this,v)}).appendTo(v),t.rippleEffect(v,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var n=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),l=[],o=0,i=n.length;o<i;o++)n[o].nextElementSibling&&n[o].nextElementSibling.className.indexOf("e-check")>-1&&l.push(n[o].textContent);this.updateRules(r,n.length>1?l:e)},d.prototype.changeValue=function(e,r){var n,l;if(r.event)l=r.event.target;else{l=r.element}if(l.className.indexOf("e-day")>-1){l=r.element}var o=t.closest(l,".e-group-container"),i=t.closest(l,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(l=s.element);var a;a=l.className.indexOf("e-radio")>-1?t.getComponent(l,"radio").label:l.className.indexOf("e-multiselect")>-1?t.getComponent(l,"multiselect").value:r.value,n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",n),this.updateRules(l,a,e),n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",n)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),n=this.getGroup(r),l=t.closest(e.element,".e-rule-container"),o=0;l&&null!==l.previousElementSibling;)l=l.previousElementSibling,o++;this.changeRule(n.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var l,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var f=r.previousItemData.value.toLowerCase();(f.indexOf("between")>-1||f.indexOf("in")>-1&&f.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)l=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=l.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var g=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:g+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var v=this.element.className.indexOf("e-device")>-1?"250px":"200px";new n.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?v:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+g+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var n;n=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var l=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],r[o].id);break}t.detach(r[o])}for(o=0,i=n.length;o<i;o++){if(n[o].className.indexOf("e-template")>-1)for(s=n[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],n[o].id);break}t.detach(n[o])}},d.prototype.templateDestroy=function(e,r){var n=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof n?(n=t.getValue(n,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},n=[],l=0,o=e.length;l<o;l++){var i=e[l][t];Number(e[l][t])===e[l][t]&&e[l][t]%1!=0&&(i=e[l][t].toString());var s={};i in r||(r[i]=1,s[t]=i,n.push(s))}return n},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new n.MultiSelect({dataSource:new l.DataManager(i),query:new l.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,n,l){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:n.value,operator:l.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:n.value,operator:l.operator})},d.prototype.renderStringValue=function(e,t,r,n,l){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,n,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.style.width="100%":(l.style.width=null,l.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});a.appendTo("#"+e+"_valuekey"+n),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,n,l,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===n||"notin"===n)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,l,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===n||"notin"===n){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});c.appendTo("#"+e+"_valuekey"+l),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,f=s.format?s.format:"#";a>1&&r&&(p=r.value[l]?r.value[l]:0);new o.NumericTextBox({value:p,format:f,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,l)}).appendTo("#"+e+"_valuekey"+l)}},d.prototype.processValueString=function(e,t){var r=[],n=e.split(",");if("string"===t)return n;for(var l=0,o=n.length;l<o;l++)r.push(Number(n[l]));return r},d.prototype.renderControls=function(e,n,l,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),n.template)this.processTemplate(e,n,l,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;if(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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,l,o.operator,p,u);break;case"number":this.renderNumberValue(a,l,o.operator,p,u,n,s);break;case"boolean":var d=n.values&&n.values.length?n.values:["True","False"],c=!this.isImportRules||Boolean(l.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&l&&l.value){h=s>1?new Date(l.value[p]):new Date(l.value);var y=void 0,f=this.getColumn(l.field);m=s>1?l.value[p]:l.value,y={type:"dateTime",format:f.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var g=n.format?n.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:g,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,n,l,o,i,s){if(l){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;n&&n.template&&(this.templateDestroy(n,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),l&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;var c=void 0;if(r.template&&"string"==typeof r.template.create?c=t.getValue(r.template.create,window)():r.template&&r.template.create&&(c=r.template.create()),c instanceof Element)c.id=u+"_valuekey0",t.addClass([c],"e-template"),t.addClass([c],"e-"+r.field),e.nextElementSibling.appendChild(c);else if(c instanceof Array){t.addClass(c,"e-template");for(var h=0,m=c.length;h<m;h++)c[h].id=u+"_valuekey"+h,e.nextElementSibling.appendChild(c[h])}var y=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?y.style.width="100%":y.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(h=0;h<2;h++){c=void 0;c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+h}}),e.nextElementSibling.appendChild(c)}else{c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(c)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var n=e.className.split(" e-")[1],l=parseInt(e.id.slice(-1),2);switch(n){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,n).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=t.getComponent(e,n).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=this.intl.formatDate(t.getComponent(e,n).value,o)}},d.prototype.updateRules=function(e,r,n){for(var l,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){l=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[l.index].field,s.rules[u].type=this.columns[l.index].type,s.rules[u].label=this.columns[l.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){l=t.getComponent(e,"dropdownlist"),s.rules[u].operator=l.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,n)},d.prototype.ruleValueUpdate=function(e,r,l,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=l.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?l.rules[o].value=r:l.rules[o].value=r[0]:l.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?l.rules[o].value[a]=r:l.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(l.rules[o].type,l.rules[o].value=this.processValueString(r,l.rules[o].type)):l.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var f=t.getInstance(s.querySelector(".e-rule-filter input"),n.DropDownList),g={type:"dateTime",format:this.columns[f.index].format||"MM/dd/yyyy"};g.type&&(p.indexOf(d)>-1?l.rules[o].value[a]=this.intl.formatDate(r,g):l.rules[o].value=this.intl.formatDate(r,g))}this.validatValue(l,o,s)}},d.prototype.validatValue=function(e,r,n){if(this.allowValidation&&e.rules[r].value){var l=n.querySelectorAll(".e-rule-value .e-control");l[0].className.indexOf("e-tooltip")>-1?t.getComponent(l[0],"tooltip").destroy():l[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[0].parentElement,"tooltip").destroy(),l[1]&&l[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[1].parentElement,"tooltip").destroy()}},d.prototype.findGroupByIdx=function(e,t,r){var n=t.rules;if(!r&&n[e]){if((t=n[e]).rules)return t;for(var l=e+1,o=n.length;l<o;l++)if((t=n[l]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,n,l;for(e.prototype.destroy.call(this),l=(r=this.element.querySelectorAll(".e-addrulegroup")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdown-btn").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},n=0,l=e.length;n<l;n++)this.addRuleElement(document.getElementById(t),e[n]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),n=this.getGroup(r),l={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else n.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",l)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),n=void 0,l=0;l<r.length;l++)n=r.item(l),t.rippleEffect(n,{selector:".e-btn"})}},d.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var n=0,l=Object.keys(e);n<l.length;n++){switch(l[n]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;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;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}}},d.prototype.preRender=function(){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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],n=t?r.length-1:r.length,l=this.rule,o=0;o<n;o++)l=this.findGroupByIdx(r[o],l,0===o);return l},d.prototype.deleteGroup=function(e){var r,n,l=e,o=l.id,i=this.getGroup(l,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=l.nextElementSibling,p=l.previousElementSibling,d=l.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(n=c.length,r=0;r<n;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,n=d.length;r<n;r++)delete this.levelColl[d[r].id];for(;null!==l.previousElementSibling;)l=l.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,n=t.closest(e,".e-group-container"),l=this.getGroup(n),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:n.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;l.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0)},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new l.Query).where(this.getPredicate(this.rule));return new l.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],n=0,o=Object.keys(this.columns);n<o.length;n++)r.push(this.columns[n].field);return e.rules.length?(new l.Query).select(r).where(t):(new l.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,n,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++){if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase();if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&["equal","notequal"].indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var d={type:"dateTime",format:o.format||"MM/dd/yyyy"};n=this.intl.parseDate(i[a].value,d)}else n=i[a].value;if(0===a)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a]);else{""!==(c=n)&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var c=n;t&&""!==c?t=t.and(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{c=n;t&&""!==c?t=t.or(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,n=0,l=r.length;n<l;n++)r[n].field===e&&(t=r[n]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var n,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":n=new l.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":n=new l.Predicate(e.field,"lessthan",o[i]);break;case"in":n=new l.Predicate(e.field,"equal",o[i]);break;case"notin":n=new l.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":n=n.and(e.field,"lessthan",o[i]);break;case"notbetween":n=n.or(e.field,"greaterthan",o[i]);break;case"in":n=n.or(e.field,"equal",o[i]);break;case"notin":n=n.and(e.field,"notequal",o[i])}return n&&(t?"and"===r?t=t.and(n):"or"===r&&(t=t.or(n)):t=n),t},d.prototype.importRules=function(e,r,n){n||(r=this.renderGroup(e.condition,r));for(var l=e.rules,o=0,i=l.length;o<i;o++){Object.keys(l[o]).indexOf("rules")>-1?(r=this.renderGroup(l[o].condition,r),r=this.importRules(l[o],r,!0)):this.renderRule(l[o],r)}return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var n=e.condition,l=0,o=e.rules.length;l<o;l++){if(e.rules[l].rules)t=this.getSqlString(e.rules[l],t);else{var i=e.rules[l],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}l!==o-1&&(t+=" "+n+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,n=["=","!=","<",">","<=",">="],l=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",n[i].toLowerCase()]),n[i].length;for(i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",l[i].toLowerCase()]),l[i].length;for(i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(r=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",r]),r.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):1},d.prototype.getOperator=function(e,t){return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":{"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"}[t]},d.prototype.processParser=function(e,t,r){for(var n,l,o,i,s,a,u,p,d,c,h=[],m=[],y=0,f=e.length;y<f;y++)if("Literal"===e[y][0]){if(n={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(n.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=f,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(n.value=e[o][1].replace(/'/g,"").replace(/%/g,""),n.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(n.value=h,n.type="number"):"String"===e[o-1][0]&&(n.value=m,n.type="string"))}else"Operators"===e[y+1][0]&&(n.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(n.type="number",n.value=Number(e[y+2][1])):(n.type="string",n.value=e[y+2][1].replace(/'/g,"")));t.rules.push(n)}else{if("Left"===e[y][0]){for(l={condition:"",rules:[]},this.parser=e.splice(y+1,f-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(l),l=this.processParser(this.parser,l,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,f-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t(e.ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,t,r,n,l,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(e,t,r,n){var l,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(i=(o<3?l(i):o>3?l(t,r,i):l(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};n.MultiSelect.Inject(n.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,n=!1,l=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(l=this.dataSource[0][i[s].field]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),i[s].type=r,n=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(s=0,a=e.length;s<a;s++)"string"===(r=typeof(l=this.dataSource[0][e[s]]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:n?"date":r,validation:o},n=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var n=t.extend({},this.rule,{},!0);this.setGroupRules(n),this.renderSummaryCollapse()}else{(l=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),l.style.display="block"}else if(r.className.indexOf("e-collapse-rule")>-1){var l;(l=this.element.querySelector(".e-group-container")).style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i);this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var l=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.className="e-rule-container e-vertical-mode":l.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=l.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)h.textContent=this.l10n.getConstant("Remove");else{t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn");new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),l.querySelector("button").appendChild(h)}if(l.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,l.querySelector(".e-filter-input").setAttribute("id",l.id+"_filterkey"),c.appendChild(l),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-rule-container")>-1&&(l.className.indexOf("e-joined-rule")<0&&(l.className+=" e-joined-rule"),l.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(l.previousElementSibling.className+=" e-prev-joined-rule")),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-group-container")>-1&&l.className.indexOf("e-separate-rule")<0&&(l.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new n.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+l.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.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)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,n=void 0,l=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,n=c.length;r<n;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,l=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(l=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),l=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,f=m.length;y<f;y++){var g=m[y],v=void 0;g.parentElement.className.indexOf("e-searcher")>-1?(v=t.closest(g,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(v):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,n,l,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),n=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(n),e.appendChild(t),l=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),l.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),l.appendChild(i),r.appendChild(l),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,n,l,o;return e=this.createElement("div"),l=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",n=this.createElement("button",{attrs:{class:o}}),r.appendChild(n),l.appendChild(r),e.appendChild(l),e},d.prototype.addGroupElement=function(e,n,l,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}});new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i);new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=n.querySelector(".e-rule-list"),f=n.querySelectorAll(".e-group-container").length;y.appendChild(u);var g=this.levelColl[n.id].slice(0);g.push(f),this.levelColl[u.id]=g,this.isImportRules||(this.addGroups([],n.id),o&&this.addRuleElement(u,{}))}else n.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===l&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var v=u.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,v),select:this.selectBtn.bind(this,v)}).appendTo(v),t.rippleEffect(v,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var n=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),l=[],o=0,i=n.length;o<i;o++)n[o].nextElementSibling&&n[o].nextElementSibling.className.indexOf("e-check")>-1&&l.push(n[o].textContent);this.updateRules(r,n.length>1?l:e)},d.prototype.changeValue=function(e,r){var n,l;if(r.event)l=r.event.target;else{l=r.element}if(l.className.indexOf("e-day")>-1){l=r.element}var o=t.closest(l,".e-group-container"),i=t.closest(l,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(l=s.element);var a;a=l.className.indexOf("e-radio")>-1?t.getComponent(l,"radio").label:l.className.indexOf("e-multiselect")>-1?t.getComponent(l,"multiselect").value:r.value,n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",n),this.updateRules(l,a,e),n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",n)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),n=this.getGroup(r),l=t.closest(e.element,".e-rule-container"),o=0;l&&null!==l.previousElementSibling;)l=l.previousElementSibling,o++;this.changeRule(n.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var l,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var f=r.previousItemData.value.toLowerCase();(f.indexOf("between")>-1||f.indexOf("in")>-1&&f.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)l=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=l.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var g=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:g+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var v=this.element.className.indexOf("e-device")>-1?"250px":"200px";new n.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?v:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+g+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var n;n=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var l=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],r[o].id);break}document.getElementById(r[o].id)&&t.detach(r[o])}for(o=0,i=n.length;o<i;o++){if(n[o].className.indexOf("e-template")>-1)for(s=n[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],n[o].id);break}t.detach(n[o])}},d.prototype.templateDestroy=function(e,r){var n=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof n?(n=t.getValue(n,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},n=[],l=0,o=e.length;l<o;l++){var i=e[l][t];Number(e[l][t])===e[l][t]&&e[l][t]%1!=0&&(i=e[l][t].toString());var s={};i in r||(r[i]=1,s[t]=i,n.push(s))}return n},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new n.MultiSelect({dataSource:new l.DataManager(i),query:new l.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,n,l){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:n.value,operator:l.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:n.value,operator:l.operator})},d.prototype.renderStringValue=function(e,t,r,n,l){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,n,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.style.width="100%":(l.style.width=null,l.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});a.appendTo("#"+e+"_valuekey"+n),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,n,l,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===n||"notin"===n)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,l,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===n||"notin"===n){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});c.appendTo("#"+e+"_valuekey"+l),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,f=s.format?s.format:"#";a>1&&r&&(p=r.value[l]?r.value[l]:0);new o.NumericTextBox({value:p,format:f,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,l)}).appendTo("#"+e+"_valuekey"+l)}},d.prototype.processValueString=function(e,t){var r=[],n=e.split(",");if("string"===t)return n;for(var l=0,o=n.length;l<o;l++)r.push(Number(n[l]));return r},d.prototype.renderControls=function(e,n,l,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),n.template)this.processTemplate(e,n,l,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;if(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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,l,o.operator,p,u);break;case"number":this.renderNumberValue(a,l,o.operator,p,u,n,s);break;case"boolean":var d=n.values&&n.values.length?n.values:["True","False"],c=!this.isImportRules||Boolean(l.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&l&&l.value){h=s>1?new Date(l.value[p]):new Date(l.value);var y=void 0,f=this.getColumn(l.field);m=s>1?l.value[p]:l.value,y={type:"dateTime",format:f.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var g=n.format?n.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:g,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,n,l,o,i,s){if(l){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;n&&n.template&&(this.templateDestroy(n,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),l&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;var c=void 0;if(r.template&&"string"==typeof r.template.create?c=t.getValue(r.template.create,window)():r.template&&r.template.create&&(c=r.template.create()),c instanceof Element)c.id=u+"_valuekey0",t.addClass([c],"e-template"),t.addClass([c],"e-"+r.field),e.nextElementSibling.appendChild(c);else if(c instanceof Array){t.addClass(c,"e-template");for(var h=0,m=c.length;h<m;h++)c[h].id=u+"_valuekey"+h,e.nextElementSibling.appendChild(c[h])}var y=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?y.style.width="100%":y.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(h=0;h<2;h++){c=void 0;c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+h}}),e.nextElementSibling.appendChild(c)}else{c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(c)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var n=e.className.split(" e-")[1],l=parseInt(e.id.slice(-1),2);switch(n){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,n).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=t.getComponent(e,n).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=this.intl.formatDate(t.getComponent(e,n).value,o)}},d.prototype.updateRules=function(e,r,n){for(var l,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){l=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[l.index].field,s.rules[u].type=this.columns[l.index].type,s.rules[u].label=this.columns[l.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){l=t.getComponent(e,"dropdownlist"),s.rules[u].operator=l.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,n)},d.prototype.ruleValueUpdate=function(e,r,l,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=l.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?l.rules[o].value=r:l.rules[o].value=r[0]:l.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?l.rules[o].value[a]=r:l.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(l.rules[o].type,l.rules[o].value=this.processValueString(r,l.rules[o].type)):l.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var f=t.getInstance(s.querySelector(".e-rule-filter input"),n.DropDownList),g={type:"dateTime",format:this.columns[f.index].format||"MM/dd/yyyy"};g.type&&(p.indexOf(d)>-1?l.rules[o].value[a]=this.intl.formatDate(r,g):l.rules[o].value=this.intl.formatDate(r,g))}this.validatValue(l,o,s)}},d.prototype.validatValue=function(e,r,n){if(this.allowValidation&&e.rules[r].value){var l=n.querySelectorAll(".e-rule-value .e-control");l[0].className.indexOf("e-tooltip")>-1?t.getComponent(l[0],"tooltip").destroy():l[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[0].parentElement,"tooltip").destroy(),l[1]&&l[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[1].parentElement,"tooltip").destroy()}},d.prototype.findGroupByIdx=function(e,t,r){var n=t.rules;if(!r&&n[e]){if((t=n[e]).rules)return t;for(var l=e+1,o=n.length;l<o;l++)if((t=n[l]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,n,l;for(e.prototype.destroy.call(this),l=(r=this.element.querySelectorAll(".e-addrulegroup")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdown-btn").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},n=0,l=e.length;n<l;n++)this.addRuleElement(document.getElementById(t),e[n]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),n=this.getGroup(r),l={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else n.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",l)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),n=void 0,l=0;l<r.length;l++)n=r.item(l),t.rippleEffect(n,{selector:".e-btn"})}},d.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var n=0,l=Object.keys(e);n<l.length;n++){switch(l[n]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;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;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}}},d.prototype.preRender=function(){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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,this.groupIdCounter=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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],n=t?r.length-1:r.length,l=this.rule,o=0;o<n;o++)l=this.findGroupByIdx(r[o],l,0===o);return l},d.prototype.deleteGroup=function(e){var r,n,l=e,o=l.id,i=this.getGroup(l,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=l.nextElementSibling,p=l.previousElementSibling,d=l.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(n=c.length,r=0;r<n;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,n=d.length;r<n;r++)delete this.levelColl[d[r].id];for(;null!==l.previousElementSibling;)l=l.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,n=t.closest(e,".e-group-container"),l=this.getGroup(n),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:n.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;l.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new l.Query).where(this.getPredicate(this.rule));return new l.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],n=0,o=Object.keys(this.columns);n<o.length;n++)r.push(this.columns[n].field);return e.rules.length?(new l.Query).select(r).where(t):(new l.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,n,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++){if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase();if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&["equal","notequal"].indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var d={type:"dateTime",format:o.format||"MM/dd/yyyy"};n=this.intl.parseDate(i[a].value,d)}else n=i[a].value;if(0===a)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a]);else{""!==(c=n)&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var c=n;t&&""!==c?t=t.and(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{c=n;t&&""!==c?t=t.or(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,n=0,l=r.length;n<l;n++)r[n].field===e&&(t=r[n]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var n,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":n=new l.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":n=new l.Predicate(e.field,"lessthan",o[i]);break;case"in":n=new l.Predicate(e.field,"equal",o[i]);break;case"notin":n=new l.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":n=n.and(e.field,"lessthan",o[i]);break;case"notbetween":n=n.or(e.field,"greaterthan",o[i]);break;case"in":n=n.or(e.field,"equal",o[i]);break;case"notin":n=n.and(e.field,"notequal",o[i])}return n&&(t?"and"===r?t=t.and(n):"or"===r&&(t=t.or(n)):t=n),t},d.prototype.importRules=function(e,r,n){n||(r=this.renderGroup(e.condition,r));for(var l=e.rules,o=0,i=l.length;o<i;o++){Object.keys(l[o]).indexOf("rules")>-1?(r=this.renderGroup(l[o].condition,r),r=this.importRules(l[o],r,!0)):this.renderRule(l[o],r)}return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var n=e.condition,l=0,o=e.rules.length;l<o;l++){if(e.rules[l].rules)t=this.getSqlString(e.rules[l],t);else{var i=e.rules[l],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}l!==o-1&&(t+=" "+n+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,n=["=","!=","<",">","<=",">="],l=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",n[i].toLowerCase()]),n[i].length;for(i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",l[i].toLowerCase()]),l[i].length;for(i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(r=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",r]),r.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):1},d.prototype.getOperator=function(e,t){return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":{"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"}[t]},d.prototype.processParser=function(e,t,r){for(var n,l,o,i,s,a,u,p,d,c,h=[],m=[],y=0,f=e.length;y<f;y++)if("Literal"===e[y][0]){if(n={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(n.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=f,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(n.value=e[o][1].replace(/'/g,"").replace(/%/g,""),n.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(n.value=h,n.type="number"):"String"===e[o-1][0]&&(n.value=m,n.type="string"))}else"Operators"===e[y+1][0]&&(n.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(n.type="number",n.value=Number(e[y+2][1])):(n.type="string",n.value=e[y+2][1].replace(/'/g,"")));t.rules.push(n)}else{if("Left"===e[y][0]){for(l={condition:"",rules:[]},this.parser=e.splice(y+1,f-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(l),l=this.processParser(this.parser,l,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,f-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ej2-querybuilder.umd.min.js.map |
/*! | ||
* filename: ej2-querybuilder.min.js | ||
* version : 16.4.47 | ||
* version : 17.1.1-beta | ||
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved. | ||
@@ -10,3 +10,3 @@ * Use of this code is subject to the terms of our license. | ||
*/ | ||
this.ej=this.ej||{},this.ej.querybuilder=function(e,t,r,l,n,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function l(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(l.prototype=r.prototype,new l)}}(),p=function(e,t,r,l){var n,o=arguments.length,i=o<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,l);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};l.MultiSelect.Inject(l.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(r,l){var n=e.call(this,r,l)||this;return n.groupIdCounter=0,n.ruleIdCounter=0,n.btnGroupId=0,n.isImportRules=!1,n.parser=[],n.intl=new t.Internationalization,n}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,l=!1,n=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(n=this.dataSource[0][i[s].field]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),i[s].type=r,l=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(var s=0,a=e.length;s<a;s++)"string"===(r=typeof(n=this.dataSource[0][e[s]]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:l?"date":r,validation:o},l=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var l=t.extend({},this.rule,{},!0);this.setGroupRules(l),this.renderSummaryCollapse()}else(n=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),n.style.display="block";else if(r.className.indexOf("e-collapse-rule")>-1){var n=this.element.querySelector(".e-group-container");n.style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i),this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var n=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.className="e-rule-container e-vertical-mode":n.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=n.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?h.textContent=this.l10n.getConstant("Remove"):(t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn"),new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),n.querySelector("button").appendChild(h)),n.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,n.querySelector(".e-filter-input").setAttribute("id",n.id+"_filterkey"),c.appendChild(n),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-rule-container")>-1&&(n.className.indexOf("e-joined-rule")<0&&(n.className+=" e-joined-rule"),n.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(n.previousElementSibling.className+=" e-prev-joined-rule")),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-group-container")>-1&&n.className.indexOf("e-separate-rule")<0&&(n.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new l.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+n.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.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)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,l=void 0,n=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,l=c.length;r<l;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,n=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(n=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),n=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,g=m.length;y<g;y++){var v=m[y],f=void 0;v.parentElement.className.indexOf("e-searcher")>-1?(f=t.closest(v,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(f):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,l,n,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),l=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(l),e.appendChild(t),n=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),n.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),n.appendChild(i),r.appendChild(n),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,l,n,o;return e=this.createElement("div"),n=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",l=this.createElement("button",{attrs:{class:o}}),r.appendChild(l),n.appendChild(r),e.appendChild(n),e},d.prototype.addGroupElement=function(e,l,n,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}}),new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i),new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=l.querySelector(".e-rule-list"),g=l.querySelectorAll(".e-group-container").length;y.appendChild(u);var v=this.levelColl[l.id].slice(0);v.push(g),this.levelColl[u.id]=v,this.isImportRules||(this.addGroups([],l.id),o&&this.addRuleElement(u,{}))}else l.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===n&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var f=u.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,f),select:this.selectBtn.bind(this,f)}).appendTo(f),t.rippleEffect(f,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var l=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),n=[],o=0,i=l.length;o<i;o++)l[o].nextElementSibling&&l[o].nextElementSibling.className.indexOf("e-check")>-1&&n.push(l[o].textContent);this.updateRules(r,l.length>1?n:e)},d.prototype.changeValue=function(e,r){var l,n;(n=r.event?r.event.target:r.element).className.indexOf("e-day")>-1&&(n=r.element);var o=t.closest(n,".e-group-container"),i=t.closest(n,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(n=s.element);var a;a=n.className.indexOf("e-radio")>-1?t.getComponent(n,"radio").label:n.className.indexOf("e-multiselect")>-1?t.getComponent(n,"multiselect").value:r.value,l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",l),this.updateRules(n,a,e),l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",l)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),l=this.getGroup(r),n=t.closest(e.element,".e-rule-container"),o=0;n&&null!==n.previousElementSibling;)n=n.previousElementSibling,o++;this.changeRule(l.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var n,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){var h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var g=r.previousItemData.value.toLowerCase();(g.indexOf("between")>-1||g.indexOf("in")>-1&&g.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)n=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=n.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var v=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:v+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var f=this.element.className.indexOf("e-device")>-1?"250px":"200px";new l.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?f:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+v+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var l;l=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var n=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],r[o].id);break}t.detach(r[o])}for(var o=0,i=l.length;o<i;o++){if(l[o].className.indexOf("e-template")>-1)for(var s=l[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],l[o].id);break}t.detach(l[o])}},d.prototype.templateDestroy=function(e,r){var l=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof l?(l=t.getValue(l,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},l=[],n=0,o=e.length;n<o;n++){var i=e[n][t];Number(e[n][t])===e[n][t]&&e[n][t]%1!=0&&(i=e[n][t].toString());var s={};i in r||(r[i]=1,s[t]=i,l.push(s))}return l},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new l.MultiSelect({dataSource:new n.DataManager(i),query:new n.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,l,n){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:l.value,operator:n.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:l.value,operator:n.operator})},d.prototype.renderStringValue=function(e,t,r,l,n){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,l,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.style.width="100%":(n.style.width=null,n.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});a.appendTo("#"+e+"_valuekey"+l),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,l,n,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===l||"notin"===l)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,n,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===l||"notin"===l){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});c.appendTo("#"+e+"_valuekey"+n),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,g=s.format?s.format:"#";a>1&&r&&(p=r.value[n]?r.value[n]:0),new o.NumericTextBox({value:p,format:g,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,n)}).appendTo("#"+e+"_valuekey"+n)}},d.prototype.processValueString=function(e,t){var r=[],l=e.split(",");if("string"===t)return l;for(var n=0,o=l.length;n<o;n++)r.push(Number(l[n]));return r},d.prototype.renderControls=function(e,l,n,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),l.template)this.processTemplate(e,l,n,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;if(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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,n,o.operator,p,u);break;case"number":this.renderNumberValue(a,n,o.operator,p,u,l,s);break;case"boolean":var d=l.values&&l.values.length?l.values:["True","False"],c=!this.isImportRules||Boolean(n.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&n&&n.value){h=s>1?new Date(n.value[p]):new Date(n.value);var y=void 0,g=this.getColumn(n.field);m=s>1?n.value[p]:n.value,y={type:"dateTime",format:g.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var v=l.format?l.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:v,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,l,n,o,i,s){if(n){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;l&&l.template&&(this.templateDestroy(l,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),n&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;y=void 0;if(r.template&&"string"==typeof r.template.create?y=t.getValue(r.template.create,window)():r.template&&r.template.create&&(y=r.template.create()),y instanceof Element)y.id=u+"_valuekey0",t.addClass([y],"e-template"),t.addClass([y],"e-"+r.field),e.nextElementSibling.appendChild(y);else if(y instanceof Array){t.addClass(y,"e-template");for(var c=0,h=y.length;c<h;c++)y[c].id=u+"_valuekey"+c,e.nextElementSibling.appendChild(y[c])}var m=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?m.style.width="100%":m.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(c=0;c<2;c++){y=void 0;y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+c}}),e.nextElementSibling.appendChild(y)}else{var y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(y)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var l=e.className.split(" e-")[1],n=parseInt(e.id.slice(-1),2);switch(l){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,l).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=t.getComponent(e,l).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=this.intl.formatDate(t.getComponent(e,l).value,o)}},d.prototype.updateRules=function(e,r,l){for(var n,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){n=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[n.index].field,s.rules[u].type=this.columns[n.index].type,s.rules[u].label=this.columns[n.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),s.rules[u].operator=n.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,l)},d.prototype.ruleValueUpdate=function(e,r,n,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=n.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===n.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?n.rules[o].value=r:n.rules[o].value=r[0]:n.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?n.rules[o].value[a]=r:n.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(n.rules[o].type,n.rules[o].value=this.processValueString(r,n.rules[o].type)):n.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var g=t.getInstance(s.querySelector(".e-rule-filter input"),l.DropDownList),v={type:"dateTime",format:this.columns[g.index].format||"MM/dd/yyyy"};v.type&&(p.indexOf(d)>-1?n.rules[o].value[a]=this.intl.formatDate(r,v):n.rules[o].value=this.intl.formatDate(r,v))}this.validatValue(n,o,s)}},d.prototype.validatValue=function(e,r,l){if(this.allowValidation&&e.rules[r].value){var n=l.querySelectorAll(".e-rule-value .e-control");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()}},d.prototype.findGroupByIdx=function(e,t,r){var l=t.rules;if(!r&&l[e]){if((t=l[e]).rules)return t;for(var n=e+1,o=l.length;n<o;n++)if((t=l[n]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,l,n;for(e.prototype.destroy.call(this),n=(r=this.element.querySelectorAll(".e-addrulegroup")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdown-btn").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),l=this.getGroup(r),n={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else l.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",n)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),l=void 0,n=0;n<r.length;n++)l=r.item(n),t.rippleEffect(l,{selector:".e-btn"})}},d.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var l=0,n=Object.keys(e);l<n.length;l++)switch(n[l]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;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;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}},d.prototype.preRender=function(){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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],l=t?r.length-1:r.length,n=this.rule,o=0;o<l;o++)n=this.findGroupByIdx(r[o],n,0===o);return n},d.prototype.deleteGroup=function(e){var r,l,n=e,o=n.id,i=this.getGroup(n,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=n.nextElementSibling,p=n.previousElementSibling,d=n.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(l=c.length,r=0;r<l;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,l=d.length;r<l;r++)delete this.levelColl[d[r].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,l=t.closest(e,".e-group-container"),n=this.getGroup(l),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:l.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;n.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0)},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new n.Query).where(this.getPredicate(this.rule));return new n.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],l=0,o=Object.keys(this.columns);l<o.length;l++)r.push(this.columns[l].field);return e.rules.length?(new n.Query).select(r).where(t):(new n.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,l,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++)if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase(),d=["equal","notequal"];if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&d.indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var c={type:"dateTime",format:o.format||"MM/dd/yyyy"};l=this.intl.parseDate(i[a].value,c)}else l=i[a].value;if(0===a)(p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p?t=this.arrayPredicate(i[a]):""!==(h=l)&&(t=new n.Predicate(i[a].field,i[a].operator,l,s));else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{h=l;t&&""!==h?t=t.and(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var h=l;t&&""!==h?t=t.or(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,l=0,n=r.length;l<n;l++)r[l].field===e&&(t=r[l]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var l,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":l=new n.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":l=new n.Predicate(e.field,"lessthan",o[i]);break;case"in":l=new n.Predicate(e.field,"equal",o[i]);break;case"notin":l=new n.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":l=l.and(e.field,"lessthan",o[i]);break;case"notbetween":l=l.or(e.field,"greaterthan",o[i]);break;case"in":l=l.or(e.field,"equal",o[i]);break;case"notin":l=l.and(e.field,"notequal",o[i])}return l&&(t?"and"===r?t=t.and(l):"or"===r&&(t=t.or(l)):t=l),t},d.prototype.importRules=function(e,r,l){l||(r=this.renderGroup(e.condition,r));for(var n=e.rules,o=0,i=n.length;o<i;o++)Object.keys(n[o]).indexOf("rules")>-1?(r=this.renderGroup(n[o].condition,r),r=this.importRules(n[o],r,!0)):this.renderRule(n[o],r);return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var l=e.condition,n=0,o=e.rules.length;n<o;n++){if(e.rules[n].rules)t=this.getSqlString(e.rules[n],t);else{var i=e.rules[n],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}n!==o-1&&(t+=" "+l+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,l=["=","!=","<",">","<=",">="],n=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",l[i].toLowerCase()]),l[i].length;for(var i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",n[i].toLowerCase()]),n[i].length;for(var i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(r=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",r]),r.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):1},d.prototype.getOperator=function(e,t){var r={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"};return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":r[t]},d.prototype.processParser=function(e,t,r){for(var l,n,o,i,s,a,u,p,d,c,h=[],m=[],y=0,g=e.length;y<g;y++)if("Literal"===e[y][0]){if(l={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(l.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=g,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(l.value=e[o][1].replace(/'/g,"").replace(/%/g,""),l.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(l.value=h,l.type="number"):"String"===e[o-1][0]&&(l.value=m,l.type="string"))}else"Operators"===e[y+1][0]&&(l.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(l.type="number",l.value=Number(e[y+2][1])):(l.type="string",l.value=e[y+2][1].replace(/'/g,"")));t.rules.push(l)}else{if("Left"===e[y][0]){for(n={condition:"",rules:[]},this.parser=e.splice(y+1,g-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(n),n=this.processParser(this.parser,n,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,g-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);return e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej; | ||
this.ej=this.ej||{},this.ej.querybuilder=function(e,t,r,l,n,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function l(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(l.prototype=r.prototype,new l)}}(),p=function(e,t,r,l){var n,o=arguments.length,i=o<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,l);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};l.MultiSelect.Inject(l.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,l=!1,n=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(n=this.dataSource[0][i[s].field]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),i[s].type=r,l=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(var s=0,a=e.length;s<a;s++)"string"===(r=typeof(n=this.dataSource[0][e[s]]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:l?"date":r,validation:o},l=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var l=t.extend({},this.rule,{},!0);this.setGroupRules(l),this.renderSummaryCollapse()}else(n=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),n.style.display="block";else if(r.className.indexOf("e-collapse-rule")>-1){var n=this.element.querySelector(".e-group-container");n.style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i),this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var n=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.className="e-rule-container e-vertical-mode":n.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=n.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?h.textContent=this.l10n.getConstant("Remove"):(t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn"),new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),n.querySelector("button").appendChild(h)),n.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,n.querySelector(".e-filter-input").setAttribute("id",n.id+"_filterkey"),c.appendChild(n),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-rule-container")>-1&&(n.className.indexOf("e-joined-rule")<0&&(n.className+=" e-joined-rule"),n.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(n.previousElementSibling.className+=" e-prev-joined-rule")),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-group-container")>-1&&n.className.indexOf("e-separate-rule")<0&&(n.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new l.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+n.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.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)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,l=void 0,n=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,l=c.length;r<l;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,n=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(n=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),n=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,g=m.length;y<g;y++){var v=m[y],f=void 0;v.parentElement.className.indexOf("e-searcher")>-1?(f=t.closest(v,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(f):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,l,n,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),l=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(l),e.appendChild(t),n=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),n.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),n.appendChild(i),r.appendChild(n),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,l,n,o;return e=this.createElement("div"),n=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",l=this.createElement("button",{attrs:{class:o}}),r.appendChild(l),n.appendChild(r),e.appendChild(n),e},d.prototype.addGroupElement=function(e,l,n,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}}),new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i),new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=l.querySelector(".e-rule-list"),g=l.querySelectorAll(".e-group-container").length;y.appendChild(u);var v=this.levelColl[l.id].slice(0);v.push(g),this.levelColl[u.id]=v,this.isImportRules||(this.addGroups([],l.id),o&&this.addRuleElement(u,{}))}else l.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===n&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var f=u.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,f),select:this.selectBtn.bind(this,f)}).appendTo(f),t.rippleEffect(f,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var l=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),n=[],o=0,i=l.length;o<i;o++)l[o].nextElementSibling&&l[o].nextElementSibling.className.indexOf("e-check")>-1&&n.push(l[o].textContent);this.updateRules(r,l.length>1?n:e)},d.prototype.changeValue=function(e,r){var l,n;(n=r.event?r.event.target:r.element).className.indexOf("e-day")>-1&&(n=r.element);var o=t.closest(n,".e-group-container"),i=t.closest(n,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(n=s.element);var a;a=n.className.indexOf("e-radio")>-1?t.getComponent(n,"radio").label:n.className.indexOf("e-multiselect")>-1?t.getComponent(n,"multiselect").value:r.value,l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",l),this.updateRules(n,a,e),l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",l)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),l=this.getGroup(r),n=t.closest(e.element,".e-rule-container"),o=0;n&&null!==n.previousElementSibling;)n=n.previousElementSibling,o++;this.changeRule(l.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var n,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){var h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var g=r.previousItemData.value.toLowerCase();(g.indexOf("between")>-1||g.indexOf("in")>-1&&g.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)n=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=n.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var v=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:v+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var f=this.element.className.indexOf("e-device")>-1?"250px":"200px";new l.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?f:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+v+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var l;l=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var n=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],r[o].id);break}document.getElementById(r[o].id)&&t.detach(r[o])}for(var o=0,i=l.length;o<i;o++){if(l[o].className.indexOf("e-template")>-1)for(var s=l[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],l[o].id);break}t.detach(l[o])}},d.prototype.templateDestroy=function(e,r){var l=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof l?(l=t.getValue(l,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},l=[],n=0,o=e.length;n<o;n++){var i=e[n][t];Number(e[n][t])===e[n][t]&&e[n][t]%1!=0&&(i=e[n][t].toString());var s={};i in r||(r[i]=1,s[t]=i,l.push(s))}return l},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new l.MultiSelect({dataSource:new n.DataManager(i),query:new n.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,l,n){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:l.value,operator:n.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:l.value,operator:n.operator})},d.prototype.renderStringValue=function(e,t,r,l,n){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,l,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.style.width="100%":(n.style.width=null,n.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});a.appendTo("#"+e+"_valuekey"+l),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,l,n,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===l||"notin"===l)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,n,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===l||"notin"===l){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});c.appendTo("#"+e+"_valuekey"+n),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,g=s.format?s.format:"#";a>1&&r&&(p=r.value[n]?r.value[n]:0),new o.NumericTextBox({value:p,format:g,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,n)}).appendTo("#"+e+"_valuekey"+n)}},d.prototype.processValueString=function(e,t){var r=[],l=e.split(",");if("string"===t)return l;for(var n=0,o=l.length;n<o;n++)r.push(Number(l[n]));return r},d.prototype.renderControls=function(e,l,n,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),l.template)this.processTemplate(e,l,n,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;if(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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,n,o.operator,p,u);break;case"number":this.renderNumberValue(a,n,o.operator,p,u,l,s);break;case"boolean":var d=l.values&&l.values.length?l.values:["True","False"],c=!this.isImportRules||Boolean(n.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&n&&n.value){h=s>1?new Date(n.value[p]):new Date(n.value);var y=void 0,g=this.getColumn(n.field);m=s>1?n.value[p]:n.value,y={type:"dateTime",format:g.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var v=l.format?l.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:v,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,l,n,o,i,s){if(n){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;l&&l.template&&(this.templateDestroy(l,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),n&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;y=void 0;if(r.template&&"string"==typeof r.template.create?y=t.getValue(r.template.create,window)():r.template&&r.template.create&&(y=r.template.create()),y instanceof Element)y.id=u+"_valuekey0",t.addClass([y],"e-template"),t.addClass([y],"e-"+r.field),e.nextElementSibling.appendChild(y);else if(y instanceof Array){t.addClass(y,"e-template");for(var c=0,h=y.length;c<h;c++)y[c].id=u+"_valuekey"+c,e.nextElementSibling.appendChild(y[c])}var m=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?m.style.width="100%":m.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(c=0;c<2;c++){y=void 0;y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+c}}),e.nextElementSibling.appendChild(y)}else{var y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(y)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var l=e.className.split(" e-")[1],n=parseInt(e.id.slice(-1),2);switch(l){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,l).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=t.getComponent(e,l).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=this.intl.formatDate(t.getComponent(e,l).value,o)}},d.prototype.updateRules=function(e,r,l){for(var n,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){n=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[n.index].field,s.rules[u].type=this.columns[n.index].type,s.rules[u].label=this.columns[n.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),s.rules[u].operator=n.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,l)},d.prototype.ruleValueUpdate=function(e,r,n,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=n.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===n.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?n.rules[o].value=r:n.rules[o].value=r[0]:n.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?n.rules[o].value[a]=r:n.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(n.rules[o].type,n.rules[o].value=this.processValueString(r,n.rules[o].type)):n.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var g=t.getInstance(s.querySelector(".e-rule-filter input"),l.DropDownList),v={type:"dateTime",format:this.columns[g.index].format||"MM/dd/yyyy"};v.type&&(p.indexOf(d)>-1?n.rules[o].value[a]=this.intl.formatDate(r,v):n.rules[o].value=this.intl.formatDate(r,v))}this.validatValue(n,o,s)}},d.prototype.validatValue=function(e,r,l){if(this.allowValidation&&e.rules[r].value){var n=l.querySelectorAll(".e-rule-value .e-control");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()}},d.prototype.findGroupByIdx=function(e,t,r){var l=t.rules;if(!r&&l[e]){if((t=l[e]).rules)return t;for(var n=e+1,o=l.length;n<o;n++)if((t=l[n]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,l,n;for(e.prototype.destroy.call(this),n=(r=this.element.querySelectorAll(".e-addrulegroup")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdown-btn").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),l=this.getGroup(r),n={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else l.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",n)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),l=void 0,n=0;n<r.length;n++)l=r.item(n),t.rippleEffect(l,{selector:".e-btn"})}},d.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var l=0,n=Object.keys(e);l<n.length;l++)switch(n[l]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;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;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}},d.prototype.preRender=function(){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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,this.groupIdCounter=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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],l=t?r.length-1:r.length,n=this.rule,o=0;o<l;o++)n=this.findGroupByIdx(r[o],n,0===o);return n},d.prototype.deleteGroup=function(e){var r,l,n=e,o=n.id,i=this.getGroup(n,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=n.nextElementSibling,p=n.previousElementSibling,d=n.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(l=c.length,r=0;r<l;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,l=d.length;r<l;r++)delete this.levelColl[d[r].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,l=t.closest(e,".e-group-container"),n=this.getGroup(l),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:l.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;n.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new n.Query).where(this.getPredicate(this.rule));return new n.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],l=0,o=Object.keys(this.columns);l<o.length;l++)r.push(this.columns[l].field);return e.rules.length?(new n.Query).select(r).where(t):(new n.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,l,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++)if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase(),d=["equal","notequal"];if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&d.indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var c={type:"dateTime",format:o.format||"MM/dd/yyyy"};l=this.intl.parseDate(i[a].value,c)}else l=i[a].value;if(0===a)(p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p?t=this.arrayPredicate(i[a]):""!==(h=l)&&(t=new n.Predicate(i[a].field,i[a].operator,l,s));else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{h=l;t&&""!==h?t=t.and(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var h=l;t&&""!==h?t=t.or(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,l=0,n=r.length;l<n;l++)r[l].field===e&&(t=r[l]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var l,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":l=new n.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":l=new n.Predicate(e.field,"lessthan",o[i]);break;case"in":l=new n.Predicate(e.field,"equal",o[i]);break;case"notin":l=new n.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":l=l.and(e.field,"lessthan",o[i]);break;case"notbetween":l=l.or(e.field,"greaterthan",o[i]);break;case"in":l=l.or(e.field,"equal",o[i]);break;case"notin":l=l.and(e.field,"notequal",o[i])}return l&&(t?"and"===r?t=t.and(l):"or"===r&&(t=t.or(l)):t=l),t},d.prototype.importRules=function(e,r,l){l||(r=this.renderGroup(e.condition,r));for(var n=e.rules,o=0,i=n.length;o<i;o++)Object.keys(n[o]).indexOf("rules")>-1?(r=this.renderGroup(n[o].condition,r),r=this.importRules(n[o],r,!0)):this.renderRule(n[o],r);return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var l=e.condition,n=0,o=e.rules.length;n<o;n++){if(e.rules[n].rules)t=this.getSqlString(e.rules[n],t);else{var i=e.rules[n],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}n!==o-1&&(t+=" "+l+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,l=["=","!=","<",">","<=",">="],n=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",l[i].toLowerCase()]),l[i].length;for(var i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",n[i].toLowerCase()]),n[i].length;for(var i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(r=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",r]),r.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):1},d.prototype.getOperator=function(e,t){var r={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"};return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":r[t]},d.prototype.processParser=function(e,t,r){for(var l,n,o,i,s,a,u,p,d,c,h=[],m=[],y=0,g=e.length;y<g;y++)if("Literal"===e[y][0]){if(l={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(l.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=g,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(l.value=e[o][1].replace(/'/g,"").replace(/%/g,""),l.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(l.value=h,l.type="number"):"String"===e[o-1][0]&&(l.value=m,l.type="string"))}else"Operators"===e[y+1][0]&&(l.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(l.type="number",l.value=Number(e[y+2][1])):(l.type="string",l.value=e[y+2][1].replace(/'/g,"")));t.rules.push(l)}else{if("Left"===e[y][0]){for(n={condition:"",rules:[]},this.parser=e.splice(y+1,g-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(n),n=this.processParser(this.parser,n,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,g-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);return e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej; | ||
//# sourceMappingURL=ej2-querybuilder.min.js.map |
/*! | ||
* filename: index.d.ts | ||
* version : 16.4.47 | ||
* version : 17.1.1-beta | ||
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved. | ||
@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license. |
{ | ||
"name": "@syncfusion/ej2-querybuilder", | ||
"version": "16.4.47", | ||
"version": "17.1.1-beta", | ||
"description": "Essential JS 2 QueryBuilder", | ||
@@ -11,8 +11,8 @@ "author": "Syncfusion Inc.", | ||
"dependencies": { | ||
"@syncfusion/ej2-base": "~16.4.47", | ||
"@syncfusion/ej2-buttons": "~16.4.47", | ||
"@syncfusion/ej2-calendars": "~16.4.47", | ||
"@syncfusion/ej2-dropdowns": "~16.4.47", | ||
"@syncfusion/ej2-splitbuttons": "~16.4.47", | ||
"@syncfusion/ej2-inputs": "~16.4.47" | ||
"@syncfusion/ej2-base": "~17.1.1-beta", | ||
"@syncfusion/ej2-buttons": "~17.1.1-beta", | ||
"@syncfusion/ej2-calendars": "~17.1.1-beta", | ||
"@syncfusion/ej2-dropdowns": "~17.1.1-beta", | ||
"@syncfusion/ej2-splitbuttons": "~17.1.1-beta", | ||
"@syncfusion/ej2-inputs": "~17.1.1-beta" | ||
}, | ||
@@ -19,0 +19,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1494091
69
16645
3
+ Added@syncfusion/ej2-base@17.1.49(transitive)
+ Added@syncfusion/ej2-buttons@17.1.50(transitive)
+ Added@syncfusion/ej2-calendars@17.1.51(transitive)
+ Added@syncfusion/ej2-data@17.1.51(transitive)
+ Added@syncfusion/ej2-dropdowns@17.1.49(transitive)
+ Added@syncfusion/ej2-icons@17.1.47(transitive)
+ Added@syncfusion/ej2-inputs@17.1.50(transitive)
+ Added@syncfusion/ej2-lists@17.1.47(transitive)
+ Added@syncfusion/ej2-popups@17.1.50(transitive)
+ Added@syncfusion/ej2-splitbuttons@17.1.51(transitive)
- Removed@syncfusion/ej2-base@16.4.52(transitive)
- Removed@syncfusion/ej2-buttons@16.4.55(transitive)
- Removed@syncfusion/ej2-calendars@16.4.55(transitive)
- Removed@syncfusion/ej2-data@16.4.52(transitive)
- Removed@syncfusion/ej2-dropdowns@16.4.55(transitive)
- Removed@syncfusion/ej2-inputs@16.4.55(transitive)
- Removed@syncfusion/ej2-lists@16.4.52(transitive)
- Removed@syncfusion/ej2-popups@16.4.54(transitive)
- Removed@syncfusion/ej2-splitbuttons@16.4.53(transitive)