@easyquery/core
Version:
EasyQuery.JS core modules
2 lines • 44.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("easyqueryCore",[],e):"object"==typeof exports?exports.easyqueryCore=e():t.easyqueryCore=e()}(window,function(){return function(n){var r={};function i(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}return i.m=n,i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",function(){return EqDataTable});var EqDataTable=function(){function EqDataTable(t){"string"==typeof t?this.loadFromJSON(t):this.tableObj=t}return EqDataTable.prototype.loadFromJSON=function(t){this.tableObj=JSON.parse(t)},EqDataTable.prototype.toJSON=function(){return JSON.stringify(this.tableObj)},EqDataTable.prototype.getObject=function(){return this.tableObj},EqDataTable.prototype.isEmpty=function(){return 0==this.getNumberOfColumns()||0==this.getNumberOfRows()},EqDataTable.prototype.getNumberOfColumns=function(){return this.tableObj.cols.length},EqDataTable.prototype.getColumnObject=function(t){return t<this.tableObj.cols.length?this.tableObj.cols[t]:null},EqDataTable.prototype.getColumnId=function(t){var e=this.getColumnObject(t);return e?e.id:null},EqDataTable.prototype.getColumnLabel=function(t){var e=this.getColumnObject(t);return e?e.label:null},EqDataTable.prototype.getColumnType=function(t){var e=this.getColumnObject(t);return e?e.type:null},EqDataTable.prototype.getColumnProperties=function(t){var e=this.getColumnObject(t);return e?e.p:null},EqDataTable.prototype.getNumberOfRows=function(){return this.tableObj.rows.length},EqDataTable.prototype.getFormattedValue=function(rowIndex,colIndex){var row=rowIndex<this.tableObj.rows.length?this.tableObj.rows[rowIndex]:null;if(row){var cell=colIndex<this.tableObj.cols.length?row.c[colIndex]:null;if(cell){if(void 0!==cell.f)return cell.f;var v=cell.v,dt;if(null!=v){var colType=this.getColumnType(colIndex);"date"==colType||"datetime"==colType?(dt=eval("new "+v),v="date"==colType?dt.toLocaleDateString():dt.toLocaleString()):"timeofday"==colType&&(dt=new Date,dt.setHours(v[0],v[1],v[2],v[3]),v=dt.toLocaleTimeString())}return v}}return null},EqDataTable}()},function(t,e,n){"use strict";n.r(e);var v,u={Locale:"en",AltMenuAttribute:"Attribute",AltMenuConstantExpression:"Constant expression",ButtonApply:"Apply",ButtonCancel:"Cancel",ButtonOK:"OK",ButtonClear:"Clear",ButtonEnable:"Toggle enable",MenuEnable:"Enabled",MenuParameterization:"Parameterized",MenuJoinCond:"Use in JOIN",ButtonDelete:"Delete",ButtonAddCondition:"Add condition",ButtonAddPredicate:"Add group of conditions",ButtonSelectAll:"Select all",ButtonDeselectAll:"Clear selection",ButtonAddColumns:"Add column(s)",ButtonAddConditions:"Add condition(s)",CmdAddConditionAfter:"Add a new condition after the current row",CmdAddConditionInto:"Add a new condition",CmdAddPredicateAfter:"Open a bracket after the current row",CmdAddPredicateInto:"Open a bracket",CmdClickToAddCondition:"[Add new condition]",CmdDeleteRow:"Delete this row",ErrIncorrectPredicateTitleFormat:"Incorrect predicate title format",ErrNotNumber:" is not a number",ErrIncorrectInteger:"Incorrect integer value",ErrIncorrectNumberList:"Incorrect list format",False:"False",LinkTypeAll:"all",LinkTypeAny:"any",LinkTypeNone:"none",LinkTypeNotAll:"not all",ConjAll:"and",ConjAny:"or",ConjNotAll:"and",ConjNone:"or",MsgApplySelection:"[Apply selection]",MsgAs:"as",MsgEmptyList:"(empty list)",MsgEmptyListValue:"[select value]",MsgEmptyScalarValue:"[enter value]",MsgSubQueryValue:"[edit sub-query]",MsgEmptyAttrValue:"[select attribute]",MsgEmptyCustomSql:"[enter SQL expression]",MsgCustomSql:"[Custom SQL]",MsgNoResult:"No result",MsgResultCount:"{0} records found",MsgOf:"of",PredicateTitle:"{lt} of the following apply",RootPredicateTitle:"Select records where {lt} of the following apply",StrAddConditions:"Add conditions",SubQueryDialogTitle:"Edit sub-query",SubQueryColumnTitle:"Column:",SubQueryEmptyColumn:"[select column]",SubQueryQueryPanelCaption:"Conditions",True:"True",ButtonSorting:"Sorting",ButtonToAggr:"Change to aggregate column",ButtonToSimple:"Change to simple column",CmdAscending:"Ascending",CmdClickToAddColumn:"[Add new column]",CmdDeleteColumn:"Delete column",CmdDeleteSorting:"Delete sorting",CmdDescending:"Descending",CmdGroupSort:"Sorting",CmdNotSorted:"Not sorted",ColTypeAggrFunc:"Aggregate function",ColTypeCompound:"Calculated",ColTypeGroup:"Column type",ColTypeSimple:"Simple column",HeaderExpression:"Expression",HeaderSorting:"Sorting",HeaderTitle:"Title",SortHeaderColumn:"Column",SortHeaderSorting:"Sorting",StrAddColumns:"Add columns",CustomExpression:"Custom Expression",CmdMoveToStart:"Move to start",CmdMoveRight:"Move right",CmdMoveLeft:"Move left",CmdMoveToEnd:"Move to the end",ButtonMenu:"Show menu",CmdToSimple:"Not aggregated",CmdMoveToFirst:"Move to the first",CmdMoveToPrev:"Move to the previous",CmdMoveToNext:"Move to the next",CmdMoveToLast:"Move to the last",StrNoFilterDefined:"No filter defined",StrNoFilterClickToAdd:"No filter defined. Click to add a new condition",Today:"Today",Yesterday:"Yesterday",Tomorrow:"Tomorrow",FirstDayOfMonth:"First day of the month",LastDayOfMonth:"Last day of the month",FirstDayOfWeek:"First day of the week",FirstDayOfYear:"First day of the year",FirstDayOfNextWeek:"First day of the next week",FirstDayOfNextMonth:"First day of the next month",FirstDayOfNextYear:"First day of the next week",Now:"Now",HourStart:"This hour start",Midnight:"Midnight",Noon:"Noon"};!function(a){var t=function(){this.Entities={},this.Attributes={},this.Operators={},this.AggregateFunctions={}};a.TextResources=t;var e="en";a.getLocale=function(){return e},a.setLocale=function(t){e=t},a.texts=new t,a.getText=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=a.texts,r="";if(t){for(var i=!1,o=t.length,s=0;s<o;s++){if(!(r=n[t[s]])){i=!0;break}n=r}if(i)for(n=u,s=0;s<o&&(r=n[t[s]]);s++)n=r}return r}}(v||(v={}));var o,r,b,i,s=function(){function t(t){this.start(t)}return t.prototype.start=function(t){this.formatStr=t,this.pos=0,this.exprNum=0,this.tokenText=""},t.prototype.skipSpaces=function(){for(;this.pos<this.formatStr.length&&" "===this.formatStr.charAt(this.pos);)this.pos++},t.prototype.next=function(){if(this.skipSpaces(),this.pos>=this.formatStr.length)return!1;var t=0;if("{"===this.formatStr.charAt(this.pos)){if((t=this.formatStr.indexOf("}",this.pos))<0)return!1;this.tokenText=this.formatStr.substring(this.pos,t+1),0===this.tokenText.indexOf("{expr")&&(this.token="expression",this.exprNum=parseInt(this.tokenText.substring(5,this.tokenText.length))),this.pos=t+1}else if("["===this.formatStr.charAt(this.pos)&&this.pos<this.formatStr.length-1&&"["===this.formatStr.charAt(this.pos+1))this.pos+=2,t=this.formatStr.indexOf("]]",this.pos),this.token="operator",this.tokenText=this.formatStr.substring(this.pos,t),this.pos=t+2;else{this.token="text";var e=this.formatStr.indexOf("{",this.pos);e<0&&(e=this.formatStr.length);var n=this.formatStr.indexOf("[[",this.pos);n<0&&(n=this.formatStr.length),t=Math.min(e,n),this.tokenText=this.formatStr.substring(this.pos,t).trim(),this.pos=t}return!0},t.prototype.parse=function(){for(var t=[];this.next();)"operator"===this.token?t.push({type:"operator",text:this.tokenText}):"expression"===this.token?t.push({type:"expression",index:this.exprNum-1}):"text"===this.token&&t.push({type:"text",text:this.tokenText});return t},t}();(r=o||(o={}))[r.Unknown=0]="Unknown",r[r.String=1]="String",r[r.Byte=2]="Byte",r[r.Word=3]="Word",r[r.Int32=4]="Int32",r[r.Int64=5]="Int64",r[r.Bool=6]="Bool",r[r.Float=7]="Float",r[r.Currency=8]="Currency",r[r.BCD=9]="BCD",r[r.Date=10]="Date",r[r.Time=11]="Time",r[r.DateTime=12]="DateTime",r[r.Autoinc=13]="Autoinc",r[r.Memo=14]="Memo",r[r.Blob=15]="Blob",r[r.FixedChar=16]="FixedChar",r[r.Guid=17]="Guid",r[r.Geometry=18]="Geometry",r[r.Geography=19]="Geography",(i=b||(b={}))[i.None=0]="None",i[i.Any=1]="Any",i[i.NotAll=2]="NotAll",i[i.All=3]="All";var T,a,d,l,h,x,p,c,f,C,y,g,m,A=[o.Byte,o.Word,o.Int32,o.Int64,o.Float,o.Currency],E=[o.Byte,o.Word,o.Int32,o.Int64];(a=T||(T={})).combinePath=function(t,e){var n=t;return null!=n&&0<n.length?("/"!=n.charAt(n.length-1)&&(n+="/"),n+=e):n=e,n},a.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)i.hasOwnProperty(o)&&(t[o]=i[o])}return t},a.assignInDepth=function t(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];for(var i=0;i<n.length;i++){var o=n[i];for(var s in o)if(o.hasOwnProperty(s)){var a=o[s];null!==a&&"object"==typeof a?(void 0===e[s]&&(e[s]={}),t(e[s],o[s])):e[s]=o[s]}}return e},a.generateId=function(){var t=new Date,e=Math.floor(1e4*Math.random());return"Y"+t.getFullYear()+"-M"+t.getMonth()+"-D"+t.getDay()+"-H"+t.getHours()+"-M"+t.getMinutes()+"-S"+t.getSeconds()+"-MS"+t.getMilliseconds()+"-"+e},a.findItemById=function(t,e){for(var n=t.length,r=0;r<n;r++)if(t[r].id===e)return t[r];return null},a.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=t.length,r=0;r<n;r++)if(e==t[r])return r;return-1},a.moveArrayItem=function(t,e,n){if(n>=t.length)for(var r=n-t.length;1+r--;)t.push(void 0);t.splice(n,0,t.splice(e,1)[0])},a.removeArrayItem=function(t,e){var n=t.indexOf(e);if(-1!=n)return t.splice(n,1)[0]},a.shiftToFitWindow=function(t,e){var n=document.getElementsByTagName("body")[0],r=window.innerWidth||document.documentElement.clientWidth||n.clientWidth,i=t+e,o=0;return r<i&&t+(o=r-i-10)<0&&(o=10-t),o},a.isObject=function(t){return null!==t&&("function"==typeof t||"object"==typeof t)},a.isNumericType=function(t){return 0<=A.indexOf(t)},a.isIntType=function(t){return 0<=E.indexOf(t)},a.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},a.areCompatibleDataTypes=function(t,e){return void 0===t||void 0===e||t==o.Unknown||e==o.Unknown||t==e||t==o.Date&&e==o.DateTime||t==o.DateTime&&e==o.Date},a.parseOperatorFormat=function(t){var e=v.getText("Operators",t.id,"displayFormat");return e||(e=t.displayFormat),new s(e).parse()},a.isPropSet=function(t,e){return t[e]||t[e.toLowerCase()]||t[e.toUpperCase()]},a.strToLinkType=function(t){return"All"==t?b.All:"NotAll"==t?b.NotAll:"Any"==t?b.Any:b.None},a.linkTypeToStr=function(t){return t===b.All?"All":t===b.NotAll?"NotAll":t==b.Any?"Any":"None"},l=d||(d={}),h=function(){this.SpecDateValues=[{id:"${Today}",key:"Today",isDefault:!0},{id:"${Yesterday}",key:"Yesterday"},{id:"${Tomorrow}",key:"Tomorrow"},{id:"${FirstDayOfMonth}",key:"FirstDayOfMonth"},{id:"${FirstDayOfYear}",key:"FirstDayOfYear"}],this.SpecTimeValues=[{id:"${Now}",key:"Now",isDefault:!0},{id:"${HourStart}",key:"HourStart"},{id:"${Midnight}",key:"Midnight"},{id:"${Noon}",key:"Noon"}],this.BooleanValues=[{id:"${false}",key:"False"},{id:"${true}",key:"True",isDefault:!0}]},l.ConstLists=h,l.constLists=new h,l.predicateLinkTypeList=[{id:"All",key:"LinkTypeAll"},{id:"Any",key:"LinkTypeAny"},{id:"None",key:"LinkTypeNone"},{id:"NotAll",key:"LinkTypeNotAll"}],(p=x||(x={}))[p.Scalar=0]="Scalar",p[p.Const=1]="Const",p[p.Attribute=2]="Attribute",p[p.List=4]="List",p[p.Query=5]="Query",(f=c||(c={}))[f.Unknown=0]="Unknown",f[f.Simple=1]="Simple",f[f.Predicate=51]="Predicate",(y=C||(C={}))[y.Unknown=0]="Unknown",y[y.Constant=1]="Constant",y[y.EntityAttribute=2]="EntityAttribute",y[y.ParentEntityAttribute=3]="ParentEntityAttribute",y[y.AggregateFunction=4]="AggregateFunction",y[y.Query=11]="Query",y[y.CustomSql=21]="CustomSql",(m=g||(g={}))[m.None=0]="None",m[m.Model=1]="Model",m[m.Query=2]="Query",m[m.Result=4]="Result",m[m.All=Number.MAX_SAFE_INTEGER]="All";var D,I,k=n(0),S=function(){function t(){this.id="",this.caption="",this.sqlExpr="",this.displayFormat=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.caption=t.cptn,this.displayFormat=t.fmt,this.sqlExpr=t.expr)},t}();(I=D||(D={})).Unknown="Unknown",I.Edit="EDIT",I.DateTime="DATETIME",I.List="LIST",I.SqlList="SQLLIST",I.CustomList="CUSTOMLIST",I.SubQuery="SUBQUERY";var w,O,M=function(){function t(){this.id="",this.tag=D.Unknown,this.resType=o.Unknown,this.defValue=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.tag=t.tag,this.defValue=t.defval,this.resType=t.rtype,t.subType&&(this.resType=t.subType),t.name&&(this.name=t.name),t.sql&&(this.sql=t.sql))},t}(),F=function(){function t(){this.id="",this.caption="{Unrecognized operator}",this.displayFormat="{expr1} [[{unrecognized operator}]] {expr2}",this.isRange=!1,this.caseIns=!1,this.paramCount=2,this.defaultOperand=new N,this.operands=new Array}return t.prototype.loadFromData=function(t,e){if(e&&(this.id=e.id,this.caption=e.cptn,this.caseIns=e.caseIns,this.isRange=e.isRange,this.displayFormat=e.fmt,this.paramCount=e.pcnt,e.defOperand&&this.defaultOperand.loadFromData(t,e.defOperand),e.editor&&(this.defaultOperand.editor=t.getEditorById(e.editor)||new M),e.operands))for(var n=0;n<e.operands.length;n++){var r=new N;r.loadFromData(t,e.operands[n]),e.editor&&(r.editor=t.getEditorById(e.editor)||new M),this.operands.push(r)}},t}(),N=function(){function t(){this.kind=x.Scalar,this.dataType=o.Unknown,this.editor=new M,this.defValue=""}return t.prototype.loadFromData=function(t,e){this.kind=e.kind,this.dataType=e.dtype,this.defValue=e.val,this.defText=e.txt,e.editor&&(this.editor=t.getEditorById(e.editor)||new M)},t.prototype.copyFrom=function(t){T.assign(this,t)},t}(),L=function(){function o(){this.name="",this.caption="",this.description="",this.useInConditions=!1,this.useInResult=!1,this.attributes=new Array,this.subEntities=new Array}return o.prototype.loadFromData=function(t,e){if(e){if(this.name=e.name,this.caption=e.name,this.description=e.desc,this.useInConditions=e.uic,this.useInResult=e.uir,this.useInSorting=e.uis,this.subEntities=new Array,e.ents)for(var n=0;n<e.ents.length;n++){var r=new o;r.loadFromData(t,e.ents[n]),this.subEntities.push(r)}if(this.attributes=new Array,e.attrs)for(n=0;n<e.attrs.length;n++){var i=new q;i.loadFromData(t,e.attrs[n]),this.attributes.push(i)}}},o}(),q=function(){function t(){this.params=[],this.id="",this.caption="{Unrecognized attribute}",this.dataType=o.String,this.size=0,this.usedInCondition=!1,this.usedInResult=!1,this.usedInSorting=!1,this.defaultOperator="",this.operators=new Array,this.lookupAttr="",this.sqlExpr=""}return t.prototype.loadFromData=function(t,e){e&&(this.id=e.id,this.description=e.desc,this.caption=e.cptn,this.dataType=e.dtype,this.usedInCondition=e.uic,this.usedInResult=e.uir,this.usedInSorting=e.uis,this.size=e.size,this.sqlExpr=e.sqlExpr,this.defaultOperator=e.defOperator,this.operators=e.ops,this.lookupAttr=e.lookupAttr,e.edtr&&(this.defaultEditor=t.getEditorById(e.edtr)||new M))},t}(),B=function(){function i(){this.id=null,this.tag=C.Constant,this.kind=x.Scalar,this.dataType=o.String,this.value="",this.text="",this.distinct=!1,this.args=new Array}return i.prototype.loadFromData=function(t,e){if(e){if(this.id=e.id,this.tag=e.tag,this.tag==C.EntityAttribute||this.tag==C.ParentEntityAttribute)return;if(this.kind=e.kind,this.dataType=e.dtype,e.query&&(this.query=new $(t),this.query.setData(e.query)),e.val&&(this.value=e.val,this.text=e.txt),void 0!==e.distinct&&(this.distinct=e.distinct),e.func&&(this.func=e.func,e.args))for(var n=0;n<e.args.length;n++){var r=new i;r.loadFromData(t,e.args[n]),this.args.push(r)}e.sql&&(this.sql=e.sql,this.baseAttrId=e.baseAttrId)}},i.prototype.saveToData=function(){var t={id:this.id,tag:this.tag};if(this.tag==C.EntityAttribute)return t;if(this.query&&(t.query=this.query.toJSONData()),void 0!==this.kind&&(t.kind=this.kind),void 0!==this.dataType&&(t.dtype=this.dataType),this.value&&(t.val=this.value),this.text&&(t.txt=this.text),this.distinct&&(t.distinct=this.distinct),this.func){t.func=this.func,t.args=[];for(var e=0;e<this.args.length;e++)t.args.push(this.args[e].saveToData())}return this.sql&&(t.sql=this.sql,t.baseAttrId=this.baseAttrId),t},i}();(O=w||(w={}))[O.None=0]="None",O[O.Ascending=1]="Ascending",O[O.Descending=2]="Descending";var R=function(){function t(){this.params=[],this.caption="",this.sorting=w.None,this.sortIndex=-1,this.expr=new B,this.blockId=""}return t.prototype.loadFromData=function(t,e){e&&(this.caption=e.cptn,void 0!==e.srt&&(this.sorting=e.srt,this.sortIndex=e.srtidx),this.expr.loadFromData(t,e.expr),this.blockId=e.blockId)},t.prototype.saveToData=function(){var t={};return this.caption&&(t.cptn=this.caption),void 0!==this.sorting&&(t.srt=this.sorting,t.srtidx=this.sortIndex),t.expr=this.expr.saveToData(),this.blockId&&(t.blockId=this.blockId),t},t}(),P=function(){function o(t){this.linkType=b.All,console.log("Creating condition...",t),this.justAdded=!1,this.tag=t||c.Unknown,this.enabled=!0,this.readOnly=!1,this.parameterized=!1,this.inJoin=!1,this.operatorID="",this.blockId="",this.expressions=new Array,this.conditions=new Array}return o.prototype.loadFromData=function(t,e){if(console.log("Loading condition...",e),e)if(this.tag=e.tag,this.tag==c.Simple){if(void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.readOnly&&(this.readOnly=e.readOnly),void 0!==e.inJoin&&(this.inJoin=e.inJoin),void 0!==e.parameterized&&(this.parameterized=e.parameterized),this.operatorID=e.op,e.exprs)for(var n=0;n<e.exprs.length;n++){var r=new B;r.loadFromData(t,e.exprs[n]),this.expressions.push(r)}}else if(this.linkType=e.linking,e.conds)for(n=0;n<e.conds.length;n++){var i=new o;i.loadFromData(t,e.conds[n]),this.conditions.push(i)}},o.prototype.saveToData=function(){var t={};if(t.tag=this.tag,this.tag==c.Simple){0==this.enabled&&(t.enabled=this.enabled),this.parameterized&&(t.parameterized=this.parameterized),this.inJoin&&(t.inJoin=this.inJoin),t.op=this.operatorID,t.exprs=[];for(var e=0;e<this.expressions.length;e++)t.exprs.push(this.expressions[e].saveToData())}else{t.linking=this.linkType,t.conds=[];for(e=0;e<this.conditions.length;e++)t.conds.push(this.conditions[e].saveToData())}return t},o}(),Q=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})},t}(),j=function(){function t(t){this.silentMode=0,this.events=new Array,this.source=t}return t.prototype.subscribe=function(t,e){var n=this.getEventRecByType(t),r={id:Q.newGuid(),callback:e};return n?n.eventCallbacks.push(r):(n={type:t,eventCallbacks:new Array(r)},this.events.push(n)),r.id},t.prototype.unsubscribe=function(t,e){var n=this.getEventRecByType(t);if(n){var r=-1;for(r=0;r<n.eventCallbacks.length&&n.eventCallbacks[r].id!==e;r++);0<=r&&n.eventCallbacks.splice(r,1)}},t.prototype.fire=function(t,e,n,r){if(void 0===n&&(n=0),void 0===r&&(r=!1),!this.silentMode||r){var i=this.getEventRecByType(t);if(i){var o={type:t,source:this.source,data:e},s=function(){for(var t=0,e=i.eventCallbacks;t<e.length;t++){e[t].callback(o)}};0<n?setTimeout(s,n):s()}}},t.prototype.enterSilentMode=function(){this.silentMode++},t.prototype.exitSilentMode=function(){this.silentMode&&this.silentMode--},t.prototype.isSilent=function(){return 0<this.silentMode},t.prototype.getEventRecByType=function(t){for(var e=0,n=this.events;e<n.length;e++){var r=n[e];if(r.type==t)return r}return null},t}(),$=function(){function t(t,e,n){this.eventEmitter=new j(this),this.id="",this.root=new P(c.Predicate),this.columns=new Array,this.justsorted=new Array,this.name="",this.description="",this.modelId="",this.modelName="",this.model=t||new U,e&&this.loadFromData(e),this.attrClassName=n&&n.attrTag||C.EntityAttribute,this.clientListRequestHandler=n?n.clientListRequestHandler:new Array,this.serverListRequestHandler=n?n.serverListRequestHandler:new Array,this.id||(this.id=T.generateId())}return t.prototype.setData=function(t,e){void 0===e&&(e=!1),this.eventEmitter.enterSilentMode();try{this.clear(),t&&("string"==typeof t?this.loadFromJson(t):this.loadFromData(t))}finally{this.eventEmitter.exitSilentMode()}e||this.fireChangedEvent({changeType:"query.all"})},t.prototype.loadFromJson=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(t&&(this.id=t.id,this.root.loadFromData(this.model,t.root),this.name=t.name,this.description=t.desc,this.justsorted=t.justsortcols,t.cols))for(var e=0;e<t.cols.length;e++){var n=new R;n.loadFromData(this.model,t.cols[e]),this.columns.push(n)}},t.prototype.getModel=function(){return this.model},t.prototype.setModel=function(t){this.model=t},t.prototype.loadModelData=function(t){this.model.setData(t)},t.prototype.toJSON=function(){return JSON.stringify(this.toJSONData())},t.prototype.toJSONData=function(){var t={modelId:this.model?this.model.getId():null,modelName:this.model?this.model.getName():null};t.id=this.id,t.name=this.name,this.description&&(t.desc=this.description),t.cols=[];for(var e=0;e<this.columns.length;e++)t.cols.push(this.columns[e].saveToData());return t.justsortcols=this.justsorted,t.root=this.root.saveToData(),t},t.prototype.isEmptyConditions=function(){return!this.root||!this.root.conditions||0===this.root.conditions.length},t.prototype.isEmptyColumns=function(){return!this.columns||0===this.columns.length},t.prototype.beginUpdate=function(){this.eventEmitter.enterSilentMode()},t.prototype.endUpdate=function(t){void 0===t&&(t=!1),this.eventEmitter.exitSilentMode(),!this.eventEmitter.isSilent()&&t&&this.fireChangedEvent({changeType:"query.all"})},t.prototype.clear=function(t){void 0===t&&(t=!1),this.beginUpdate();try{this.clearColumns(),this.clearConditions()}finally{this.endUpdate(!1),t||this.fireChangedEvent({changeType:"query.clear"})}},t.prototype.clearColumns=function(){this.columns=[],this.justsorted=[],this.fireChangedEvent({changeType:"query.columns.clear"})},t.prototype.clearConditions=function(){this.root.conditions=[],this.root.linkType=b.All,this.root.enabled=!0,this.fireChangedEvent({changeType:"query.conditions.clear"})},t.prototype.getId=function(){return this.id},t.prototype.setId=function(t){this.id=t},t.prototype.getName=function(){return this.name},t.prototype.setName=function(t){this.name=t},t.prototype.getDescription=function(){return this.description},t.prototype.setDescription=function(t){this.description=t},t.prototype.getColumns=function(){return this.columns},t.prototype.getSortedColumns=function(){for(var t,e=new Array,n=this.getColumns(),r=0;r<n.length;r++)0<=(t=n[r]).sortIndex&&e.push(t);return e.sort(function(t,e){return t.sortIndex-e.sortIndex}),e},t.prototype.getColumnSortIndex=function(t){if(t.sorting==w.None)return-1;if(t.sortIndex<0){var e=this.getColumns();return T.indexOfArrayItem(e,t)}return t.sortIndex},t.prototype.addColumn=function(t,e,n){var r=this.columns;void 0===t.length?"number"==typeof e?r.splice(e,0,t):r.push(t):"number"==typeof e?r.push.apply(r,[e,0].concat(t)):r.push.apply(r,[].concat(t)),this.fireChangedEvent({author:n,changeType:"column.add",column:t})},t.prototype.moveColumn=function(t,e,n){var r=this.getColumns(),i=r[t];T.moveArrayItem(r,t,e),this.fireChangedEvent({author:n,changeType:"column.move",column:i})},t.prototype.removeColumn=function(t,e){var n=this.getColumns(),r=n.indexOf(t);0<=r&&(n.splice(r,1),this.fireChangedEvent({author:e,changeType:"column.remove",column:t}))},t.prototype.addPredicate=function(t){var e=t.predicate||this.getRootPredicate(),n=this.getModel(),r=n.getFirstUICAttr(),i=n.getDefaultOperatorForAttr(r),o=this.createSimpleConditionObject(r,i,""),s=e.linkType===b.All?b.Any:b.All,a=new P(c.Predicate);return a.linkType=s,a.conditions.push(o),a},t.prototype.addSimpleCondition=function(t){var e=t.predicate||this.getRootPredicate(),n=this.getModel();if(!n)return null;var r=t.attr,i=n.getAttributeById(r);if(!i)return null;var o,s=t.operator;if(!(o=s?n.getOperatorById(s):n.getDefaultOperatorForAttr(i)))return null;var a=this.createSimpleConditionObject(i,o,t.value);return e.conditions.push(a),this.fireChangedEvent({changeType:"condition.add",condition:a}),a},t.prototype.createValueExpr=function(t,e,n,r){var i=this.getModel().getOperand(t,e,n),o=void 0===r,s=new B;if(i.kind===x.Query)s.tag=C.Query,s.dataType=i.dataType,s.kind=i.kind,s.value=r,s.text="";else if(i.kind===x.Attribute){if(!o){var a=this.getModel().getFirstAttributeByFilter(function(t){return 1==t.usedInCondition&&(!i.dataType||t.dataType==i.dataType)});r=a?a.id:null}s.tag=C.EntityAttribute,s.dataType=i.dataType,s.kind=i.kind,s.id=r,s.value=r,s.text=""}else o&&(r=i.defValue&&""!=i.defValue?i.defValue:i.editor&&i.editor.defValue?i.editor.defValue:""),s.tag=C.Constant,s.dataType=i.dataType,s.kind=i.kind,s.value=r,s.text=r;return s},t.prototype.createSimpleConditionObject=function(t,e,n){if(!t)return null;if(!t.usedInCondition)return null;var r=new B;r.id=t.id,r.tag=this.attrClassName;var i=new P(c.Simple);if(i.enabled=!0,i.operatorID=e.id,i.expressions.push(r),null!=n)if(Array.isArray(n))for(var o=n.length,s=0;s<o;s++)i.expressions.push(this.createValueExpr(t,e,s+1,n[s]));else i.expressions.push(this.createValueExpr(t,e,1,n));return i},t.prototype.removeColumns=function(t,e){for(var n=this.getColumns(),r=t.length,i=0;i<r;i++){var o=n.indexOf(t[i]);0<=o&&n.splice(o,1)}this.fireChangedEvent({author:e,changeType:"column.remove",column:t})},t.prototype.fireProcessEvent=function(t){this.eventEmitter.fire("query.process",t)},t.prototype.fireChangedEvent=function(t,e){void 0===e&&(e=100),this.eventEmitter.fire("query.change",t,e)},t.prototype.runThroughConditions=function(r){var i=function(t){for(var e=0;e<t.conditions.length;e++){var n=t.conditions[e];n.conditions?i(n):r&&r(n)}};i(this.getRootPredicate())},t.prototype.getOneValueForAttr=function(e){var n=null;return this.runThroughConditions(function(t){t.enabled&&(t.expressions[0].id!=e||!t.expressions[1]||"Equal"!=t.operatorID&&"InList"!=t.operatorID&&"StartsWith"!=t.operatorID||(n=t.expressions[1].value))}),n},t.prototype.getRootPredicate=function(){return this.root},t.prototype.addProcessCallback=function(t){return this.eventEmitter.subscribe("query.process",t)},t.prototype.removeProcessCallback=function(t){this.eventEmitter.unsubscribe("query.process",t)},t.prototype.addChangedCallback=function(t){return this.eventEmitter.subscribe("query.change",t)},t.prototype.removeChangedCallback=function(t){this.eventEmitter.unsubscribe("query.change",t)},t.prototype.getConditionsText=function(){var g=this.getModel();if(!g)return"";var m=function(t){var e,n,r="",i="Conj"+T.linkTypeToStr(t.linkType),o=v.getText(i);for(n=0;n<t.conditions.length;n++){e="";var s=t.conditions[n];if(s.enabled||void 0===s.enabled)if(s.conditions&&s.conditions.length)(e=m(s))&&(e="("+e+")");else for(var a=s.operatorID,u=g.getOperatorById(a),d=T.parseOperatorFormat(u),l=d.length,h=0;h<l;h++){var p=d[h],c=p.text;if("expression"==p.type){var f=s.expressions[p.index];if(f.kind==x.Attribute||f.tag==C.EntityAttribute){var y=g.getAttributeById(f.id);c=g.getAttributeText(y,"{entity} {attr}")}else c=f.text}0<h&&(e+=" "),e+=c}e&&(0<n&&r&&(r+=" "+o+" "),r+=e)}return t.linkType!=b.None&&t.linkType!=b.NotAll||(r="not ( "+r+" )"),r};return m(this.getRootPredicate())},t}(),U=function(){function t(){this.id="",this.name="",this.eqlcns=new V,this.operators=new Array,this.rootEntity=new L,this.aggrFunctions=new Array,this.dateMacros=["${Today}","${Yesterday}","${Tomorrow}","${FirstDayOfMonth}","${LastDayOfMonth}","${FirstDayOfWeek}","${FirstDayOfYear}","${FirstDayOfNextWeek}","${FirstDayOfNextMonth}","${FirstDayOfNextYear}"],this.timeMacros=["${Now}","${HourStart}","${Midnight}","${Noon}"],this.rgdlceval=!1}return t.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(this.id=t.id,this.name=t.name,this.version=t.vers,t.easyQuery&&(this.eqlcns.loadFromData(t.easyQuery),this.rgdlceval=this.eqlcns.chkrgd()),this.editors=new Array,t.editors)for(var e=0;e<t.editors.length;e++){var n=new M;n.loadFromData(t.editors[e]),this.editors.push(n)}if(this.operators=new Array,t.operators)for(e=0;e<t.operators.length;e++){var r=new F;r.loadFromData(this,t.operators[e]),this.operators.push(r)}if(this.rootEntity.loadFromData(this,t.entroot),this.aggrFunctions=new Array,t.aggrfuncs)for(e=0;e<t.aggrfuncs.length;e++){var i=new S;i.loadFromData(t.aggrfuncs[e]),this.aggrFunctions.push(i)}},t.prototype.getObject=function(){return this},t.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},t.prototype.createQuery=function(){return new $(this)},t.prototype.isEmpty=function(){return 0===this.rootEntity.subEntities.length&&0===this.rootEntity.attributes.length},t.prototype.getId=function(){return this.id},t.prototype.getName=function(){return this.name},t.prototype.getRootEntity=function(){return this.rootEntity},t.prototype.rgdlce=function(){return this.rgdlceval},t.prototype.getEditorById=function(t){for(var e=0,n=this.editors;e<n.length;e++){var r=n[e];if(r.id===t)return r}return null},t.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||(e=new q),e},t.prototype.checkAttrProperty=function(t,e){var n=this.getAttributeById(t);return!!n&&(!!n[e]||!!n.lookupAttr&&(t=n.lookupAttr,(n=this.getAttributeById(t))&&n[e]))},t.prototype.getEntityAttrById=function(t,e){var n,r;if(t.attributes){var i=t.attributes.length;for(n=0;n<i;n++)if(t.attributes[n].id==e)return t.attributes[n]}if(t.subEntities){var o=t.subEntities.length;for(n=0;n<o;n++)if(r=this.getEntityAttrById(t.subEntities[n],e))return r}return null},t.prototype.listByEntityWithFilter=function(t,e){var n,r=new Array,i=null;if(t.subEntities)for(var o=t.subEntities.length,s=0;s<o;s++){if(i=t.subEntities[s],!e||e(i))(n=v.getText("Entities",i.name))||(n=i.caption),(l=T.assign(new L,{id:i.name,text:n,items:[],isEntity:!0})).items=this.listByEntityWithFilter(i,e),0<l.items.length&&r.push(l)}var a=null;if(t.attributes)for(var u=t.attributes.length,d=0;d<u;d++)if(a=t.attributes[d],!e||e(a)){(n=v.getText("Attributes",a.id))||(n=a.caption);var l=T.assign(new L,{id:a.id,text:n,dataType:a.dataType});r.push(l)}return r},t.prototype.listByEntity=function(t,e){e=e||{};var n,r=[],i=[],o=null;if(t.subEntities)for(var s=t.subEntities.length,a=0;a<s;a++)if(o=t.subEntities[a],!1!==e.addUIC&&!1!==o.useInConditions||!1!==e.addUIR&&!1!==o.useInResult||!1!==e.addUIS&&!1!==o.useInSorting){(n=v.getText("Entities",o.name))||(n=o.caption);var u=T.assign(new L,{id:o.name,text:n,items:[],isEntity:!0,description:o.description}),d=T.assign({},e);d.includeRootData=!1,u.items=this.listByEntity(o,d),r.push(u)}var l=null;if(t.attributes)for(var h=t.attributes.length,p=0;p<h;p++)l=t.attributes[p],(!1!==e.addUIC&&!1!==l.usedInCondition||!1!==e.addUIR&&!1!==l.usedInResult||!1!==e.addUIS&&!1!==l.usedInSorting)&&((n=v.getText("Attributes",l.id))||(n=l.caption),i.push(T.assign(new q,{id:l.id,text:n,dataType:l.dataType,lookupAttr:l.lookupAttr,description:l.description})));var c,f=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(r.sort(f),i.sort(f)),c=e.attrPlacement&&0!=e.attrPlacement?i.concat(r):r.concat(i),2==e.attrPlacement&&c.sort(f),e.includeRootData?((n=v.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:c}):c},t.prototype.getEntitiesTree=function(t){return this.listByEntity(this.getRootEntity(),t)},t.prototype.getEntitiesTreeWithFilter=function(t){return this.listByEntityWithFilter(this.getRootEntity(),t)},t.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},t.prototype.getEntityPathByAttr=function(t,e,n,r){if(!t)return"";n=n||" ";var i="";if(t.caption&&!r){var o=v.getText("Entities",t.caption);i=o||t.caption}if(t.attributes)for(var s=t.attributes.length,a=0;a<s;a++)if(t.attributes[a].id==e)return i;if(t.subEntities){var u=t.subEntities.length;for(a=0;a<u;a++){var d=t.subEntities[a],l=this.getEntityPathByAttr(d,e,n,!1);if(""!==l)return""!==i&&(l=i+n+l),l}}return""},t.prototype.getAttributeText=function(t,e){var n=v.getText("Attributes",t.id);if(n||(n=t.caption),!e)return n;var r=this.getFullEntityPathByAttr(t.id," ");return(r?e.replace(new RegExp("{attr}","g"),n).replace(new RegExp("{entity}","g"),r):n).trim()},t.prototype.getFirstUICAttr=function(){return this.getFirstUICAttrInEntity(this.getRootEntity())},t.prototype.getFirstUICAttrInEntity=function(t){if(!1!==t.useInConditions){if(t.attributes)for(var e=t.attributes.length,n=0;n<e;n++)if(t.attributes[n].usedInCondition)return t.attributes[n];if(t.subEntities){var r=t.subEntities.length;for(n=0;n<r;n++){var i=this.getFirstUICAttrInEntity(t.subEntities[n]);if(i)return i}}}return null},t.prototype.runThroughEntities=function(o,s){var a={stop:!1},u=function(t){if(s&&s(t,a),t.attributes)for(var e=t.attributes.length,n=0;n<e&&!a.stop;n++){var r=t.attributes[n];if(o&&o(r,a),a.stop)return}if(t.subEntities){var i=t.subEntities.length;for(n=0;n<i&&!a.stop;n++)u(t.subEntities[n])}};u(this.getRootEntity())},t.prototype.getFirstAttributeByFilter=function(n){var r=null;return this.runThroughEntities(function(t,e){n(t)&&(e.stop=!0,r=t)},null),r},t.prototype.findOperatorById=function(t){if(0<this.operators.length)for(var e=this.operators.length,n=0;n<e;n++)if(this.operators[n].id==t)return this.operators[n];return null},t.prototype.getOperatorById=function(t){var e=this.findOperatorById(t);return e||(e=new F),e},t.prototype.getDefaultOperatorIdForAttr=function(t){return t.defaultOperator?t.defaultOperator:0<t.operators.length?t.operators[0]:(new F).id},t.prototype.getAggrFunctionCaption=function(t){var e=v.getText("AggregateFunctions",t),n=e?e.caption:v.getText("Aggr"+t.replace(" ","")+"_Caption");if(n)return n;var r=T.findItemById(this.aggrFunctions,t);return r&&r.caption?r.caption:t},t.prototype.getAggrFunctionFormat=function(t){var e=v.getText("AggregateFunctions",t),n=e?e.displayFormat:v.getText("Aggr"+t.replace(" ","")+"_Format");if(n)return n;var r=T.findItemById(this.aggrFunctions,t);return r&&r.displayFormat?r.displayFormat:""},t.prototype.getDefaultOperatorForAttr=function(t){var e=this.getDefaultOperatorIdForAttr(t);return this.getOperatorById(e)},t.prototype.getOperand=function(t,e,n){var r=new N;e&&e.defaultOperand?(r.copyFrom(e.defaultOperand),r.defValue||(r.defValue=""),r.defText||(r.defText="")):(r.kind=x.Scalar,r.dataType=o.Unknown,r.defValue="",r.defText="",r.editor=null);var i=r;return i.dataType===o.Unknown&&t&&(i.dataType=t.dataType),e&&0<=n&&e.operands&&e.operands[n-1]&&(i=T.assign(i,e.operands[n-1])),i.editor||(r.editor?i.editor=r.editor:r.kind===x.Query?i.editor.tag=D.SubQuery:t&&t.defaultEditor?i.editor=t.defaultEditor:i.dataType===o.Date||i.dataType===o.DateTime||i.dataType===o.Time?i.editor.tag=D.DateTime:i.editor.tag=D.Edit),i},t.prototype.getAggrFunctions=function(){return this.aggrFunctions},t.prototype.getDateMacroValue=function(t){var e=new Date;if(this.isDateMacro(t)){switch(t){case"${Today}":break;case"${Yesterday}":e.setDate(e.getDate()-1);break;case"${Tomorrow}":e.setDate(e.getDate()+1);break;case"${FirstDayOfMonth}":e.setDate(1);break;case"${LastDayOfMonth}":e.setMonth(e.getMonth()+1,0);break;case"${FirstDayOfWeek}":n=0==(n=e.getDay())?6:n-1,e.setDate(e.getDate()-n);break;case"${FirstDayOfYear}":e.setMonth(0,1);break;case"${FirstDayOfNextWeek}":var n;n=0==(n=e.getDay())?1:8-n,e.setDate(e.getDate()+n);break;case"${FirstDayOfNextMonth}":e.setMonth(e.getMonth()+1,1);break;case"${FirstDayOfNextYear}":e.setFullYear(e.getFullYear()+1,0,1)}return e}return null},t.prototype.isDateMacro=function(t){return 0<=T.indexOfArrayItem(this.dateMacros,t)},t.prototype.getDateOrMacroValue=function(t){var e=this.getDateMacroValue(t);return e||t},t.prototype.getTimeMacroValue=function(t){var e=new Date;if(this.isTimeMacro(t)){switch(t){case"${Now}":break;case"${HourStart}":e.setMinutes(0,0,0);break;case"${Midnight}":e.setHours(0,0,0,0);break;case"${Noon}":e.setHours(12,0,0,0)}return e}return null},t.prototype.isTimeMacro=function(t){return 0<=T.indexOfArrayItem(this.timeMacros,t)},t.prototype.getTimeOrMacroValue=function(t){var e=this.getTimeMacroValue(t);return e||t},t}(),V=function(){function t(){this.version="5.0.0-beta1",this.token=" "}return t.prototype.loadFromData=function(t){t.version&&(this.version=t.version),t.token&&(this.token=t.token)},t.prototype.chkrgd=function(){var t=this.token,e=this.version.split("."),n=0<e.length?parseInt(e[0]):0,r=1<e.length?parseInt(e[1]):0;return n%10+r%10+65==t.charCodeAt(r%14+2)},t}(),_=function(){function t(){this.internalListCache={},this.useBootstrap=!1,this.loadModelOnStart=!0,this.loadQueryOnStart=!1,this.dataModel=new U,this.query=new $(this.dataModel),this.widgets=new Array}return t.prototype.init=function(n){var r=this;(n=n||{}).defaultQueryId&&this.query.setId(n.defaultQueryId),n.listCache&&this.setExternalListCache(n.listCache),n.broker&&(this.broker=n.broker.resolver(this)),n.defaultQueryId&&this.query.setId(n.defaultQueryId),n.locale&&v.setLocale(n.locale),this.loadQueryOnStart=!1,n.loadQueryOnStart&&(this.loadQueryOnStart=n.loadQueryOnStart),this.loadModelOnStart=!0,void 0!==n.loadModelOnStart&&(this.loadModelOnStart=n.loadModelOnStart),n.handlers&&(n.handlers.onInit&&(this.onInit=n.handlers.onInit),n.handlers.onLoadModel&&(this.onLoadModel=n.handlers.onLoadModel),n.handlers.onLoadQuery&&(this.onLoadQuery=n.handlers.onLoadQuery),n.handlers.onInitialModelLoad&&(this.onInitialModelLoad=n.handlers.onInitialModelLoad),n.handlers.onProcessStart&&(this.onProcessStart=n.handlers.onProcessStart),n.handlers.onProcessEnd&&(this.onProcessEnd=n.handlers.onProcessEnd),n.handlers.onError&&(this.onError=n.handlers.onError),n.handlers.listRequestHandler&&(this.clientListRequestHandler=n.handlers.listRequestHandler)),this.initialQuery=n.initialQuery,this.defaultQueryId=n.defaultQueryId||"",this.defaultModelId=n.defaultModelId||"",n.broker&&this.broker.init(n.broker),this.widgets.forEach(function(t){var e={};n.widgets&&n.widgets[t.widgetType]&&(e=n.widgets[t.widgetType]),t.init(r,e),t.refresh()}),this.loadModelOnStart&&this.loadDefaultModel(),!1!==n.clearResultOnQueryChange&&this.addQueryChangedCallback(function(t){t.data&&"query.all"===t.data.changeType||r.clearData()})},t.prototype.addWidget=function(t){this.widgets.push(t)},t.prototype.refreshWidgets=function(e){void 0===e&&(e=g.All),console.log("Refreshing widgets..."),this.widgets.forEach(function(t){t.refresh(e)})},t.prototype.startLoadingWidgets=function(){this.widgets.forEach(function(t){t.startLoading()})},t.prototype.finishLoadingWidgets=function(){this.widgets.forEach(function(t){t.finishLoading()})},t.prototype.addQueryChangedCallback=function(t){this.query.addChangedCallback(t)},t.prototype.removeQueryChangedCallback=function(t){this.query.removeChangedCallback(t)},t.prototype.getBroker=function(){return this.broker},t.prototype.getQuery=function(){return this.query},t.prototype.getModel=function(){return this.dataModel},t.prototype.setModel=function(t){this.query.loadModelData(t),this.dataModel=this.query.getModel()},t.prototype.setDefaultModelId=function(t){this.defaultModelId=t},t.prototype.fireProcessStart=function(t){this.onProcessStart&&this.onProcessStart(t)},t.prototype.fireProcessEnd=function(t){this.onProcessEnd&&this.onProcessEnd(t)},t.prototype.throwError=function(t){if(this.onError)this.onError(t);else{var e=t&&t.type?t.type+" error":"Error",n=t&&t.text?t.text:"";console.error(e+": "+n)}},t.prototype.loadDefaultModel=function(){var n=this;this.broker.loadModel({modelId:n.defaultModelId,beforeSend:function(){n.startLoadingWidgets()},success:function(t){n.finishLoadingWidgets(),n.refreshWidgets(g.Model|g.Query);var e=n.getQuery();n.initialQuery&&e.setData(n.initialQuery),n.loadQueryOnStart?n.broker.loadQuery({id:n.defaultQueryId,modelId:n.defaultModelId,success:function(){n.onInit&&n.onInit()}}):n.onInit&&n.onInit(),n.onInitialModelLoad&&n.onInitialModelLoad(t)}})},t.prototype.clearQuery=function(){this.query.clear(),this.refreshWidgets(g.Query)},t.prototype.clearData=function(){(this.resultContent||this.resultStatement||this.resultSet)&&(this.resultStatement=null,this.resultSet=null,this.resultContent=null,this.refreshWidgets(g.Result))},t.prototype.setExternalListCache=function(t){this.externalListCache=t},t.prototype.getListFromCache=function(t){var e="SQL"==t.listName?"SQL_"+t.editorId:t.listName;return this.externalListCache?this.externalListCache.get(e):this.internalListCache[e]},t.prototype.addListToCache=function(t,e){var n="SQL"==t.listName?"SQL_"+t.editorId:t.listName;this.externalListCache?this.externalListCache.set(n,e):this.internalListCache[n]=e},t.prototype.resetListCache=function(){this.externalListCache?this.externalListCache.clear():this.internalListCache={}},t.prototype.getListRequestHandler=function(){var s=this;return function(e,n){if(null!=e&&e.listName){var t=e.listName.match(/{{(.+?)}}/);if(t){var r=s.query.getOneValueForAttr(t[1]);r||(r=""),e.listName=e.listName.replace(/{{.+?}}/,r)}var i=s.getListFromCache(e);if(i&&0<i.length)n(i);else{var o=!1;s.clientListRequestHandler&&(o=s.clientListRequestHandler(e,n)),o||s.broker.getRequestList({params:e,success:function(t){t&&s.addListToCache(e,t),n(t)}})}}}},t}(),W=function(){function t(t){}return t.prototype.init=function(t,e){this.context=t},t.prototype.getContext=function(){return this.context},t.prototype.refresh=function(t){void 0!==t&&null!=t&&0==(t&this.group)||this.refreshCore()},t.prototype.refreshCore=function(){},t.prototype.startLoading=function(){},t.prototype.finishLoading=function(){},t}();function H(n){var t=window.XDomainRequest,r=new("onload"in new XMLHttpRequest?XMLHttpRequest:t),e=n.type||"POST";r.open(e,n.url,!0);var i=n.contentType||"application/json";return r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.setRequestHeader("Content-Type",i),n.beforeSend&&n.beforeSend(r,n.data),"string"!=typeof n.data&&0==i.indexOf("application/json")&&(n.data=JSON.stringify(n.data)),r.onreadystatechange=function(){if(4==r.readyState){var t=parseInt(r.status);if(300<=t||t<200)n.error&&n.error(r,t,r.statusText);else if(n.success)if("json"===(n.dataType||r.responseType)){var e=JSON.parse(r.responseText);n.success(e)}else n.success(r.responseText)}},r.send(n.data),r}n.d(e,"equtils",function(){return T}),n.d(e,"eqi18n",function(){return v}),n.d(e,"eqconsts",function(){return d}),n.d(e,"DataKind",function(){return x}),n.d(e,"DataType",function(){return o}),n.d(e,"LinkType",function(){return b}),n.d(e,"CondTag",function(){return c}),n.d(e,"ExprTag",function(){return C}),n.d(e,"WidgetGroup",function(){return g}),n.d(e,"EqDataTable",function(){return k.a}),n.d(e,"AggrFunction",function(){return S}),n.d(e,"DataModel",function(){return U}),n.d(e,"EqLcns",function(){return V}),n.d(e,"Entity",function(){return L}),n.d(e,"EntityAttr",function(){return q}),n.d(e,"Expression",function(){return B}),n.d(e,"Operator",function(){return F}),n.d(e,"Operand",function(){return N}),n.d(e,"ValueEditor",function(){return M}),n.d(e,"EqContext",function(){return _}),n.d(e,"Widget",function(){return W}),n.d(e,"SortDirection",function(){return w}),n.d(e,"Column",function(){return R}),n.d(e,"Condition",function(){return P}),n.d(e,"Query",function(){return $}),n.d(e,"ajax",function(){return H}),n.d(e,"FormatParser",function(){return s})}])});
//# sourceMappingURL=easyquery.core.min.js.map