UNPKG

@easyquery/core

Version:

EasyQuery.JS core modules

1,413 lines (1,344 loc) 114 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("easyqueryCore", [], factory); else if(typeof exports === 'object') exports["easyqueryCore"] = factory(); else root["easyqueryCore"] = factory(); })(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 1); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EqDataTable; }); var EqDataTable = /** @class */ (function () { function EqDataTable(data) { if (typeof data === "string") { this.loadFromJSON(data); } else { this.tableObj = data; } } EqDataTable.prototype.loadFromJSON = function (json) { this.tableObj = JSON.parse(json); }; EqDataTable.prototype.toJSON = function () { return JSON.stringify(this.tableObj); }; EqDataTable.prototype.getObject = function () { return this.tableObj; }; EqDataTable.prototype.isEmpty = function () { return this.getNumberOfColumns() == 0 || this.getNumberOfRows() == 0; }; EqDataTable.prototype.getNumberOfColumns = function () { return this.tableObj.cols.length; }; EqDataTable.prototype.getColumnObject = function (colIndex) { return colIndex < this.tableObj.cols.length ? this.tableObj.cols[colIndex] : null; }; EqDataTable.prototype.getColumnId = function (colIndex) { var col = this.getColumnObject(colIndex); return col ? col.id : null; }; EqDataTable.prototype.getColumnLabel = function (colIndex) { var col = this.getColumnObject(colIndex); return col ? col.label : null; }; EqDataTable.prototype.getColumnType = function (colIndex) { var col = this.getColumnObject(colIndex); return col ? col.type : null; }; EqDataTable.prototype.getColumnProperties = function (colIndex) { var col = this.getColumnObject(colIndex); return col ? col.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 (typeof cell.f != 'undefined') { return cell.f; } var v = cell.v; var dt; if (typeof v != 'undefined' && v !== null) { var colType = this.getColumnType(colIndex); if (colType == 'date' || colType == 'datetime') { dt = eval("new " + v); if (colType == 'date') { v = dt.toLocaleDateString(); } else { v = dt.toLocaleString(); } } else if (colType == 'timeofday') { dt = new Date(); dt.setHours(v[0], v[1], v[2], v[3]); v = dt.toLocaleTimeString(); } } return v; } } return null; }; return EqDataTable; }()); /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./src/i18n/i18n.ts var defaultTexts = { 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", //FilterBar StrNoFilterDefined: "No filter defined", StrNoFilterClickToAdd: "No filter defined. Click to add a new condition", //DateTime macroses 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" }; var eqi18n; (function (eqi18n) { var TextResources = /** @class */ (function () { function TextResources() { this.Entities = {}; this.Attributes = {}; this.Operators = {}; this.AggregateFunctions = { //"SUM": { // caption: "Maximum", // displayFormat: "[[Maximum]] of {expr1}" //} }; } return TextResources; }()); eqi18n.TextResources = TextResources; var locale = 'en'; function getLocale() { return locale; } eqi18n.getLocale = getLocale; function setLocale(l) { locale = l; } eqi18n.setLocale = setLocale; /// <var name="texts" type="Object" default="{Entities: {}, Attributes: {}, Operators: {}, AggregateFunctions: {}}"> /// <summary> /// Contains the text strings that are used in the UI divided by 3 lists. By default the internal (English) list of strings is used. /// </summary> /// <notes>These lists are usually used to localize the UI.</notes> /// </var> eqi18n.texts = new TextResources(); /// <function version="1.0.0"> /// <summary>Returns localized text by the key defined in parameters</summary> /// <returns type="String"> /// Text of the resource defined by key /// </returns> /// <param name="key" type="String"> /// The key of the resource string. /// </param> /// <example> /// Here we get the text of the resource string assigned to CmdClickToAddCondition key /// <code> /// var text = EQ.core.getText("CmdClickToAddCondition") /// </code> /// </example> /// </function> function getText() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var textsObj = eqi18n.texts; var resText = ""; if (args) { var bStop = false; var argLength = args.length; for (var i = 0; i < argLength; i++) { resText = textsObj[args[i]]; if (!resText) { bStop = true; break; } else { textsObj = resText; } } if (bStop) { textsObj = defaultTexts; for (var i = 0; i < argLength; i++) { resText = textsObj[args[i]]; if (!resText) { break; } else { textsObj = resText; } } } } return resText; } eqi18n.getText = getText; })(eqi18n || (eqi18n = {})); // CONCATENATED MODULE: ./src/utils/format_parser.ts var FormatParser = /** @class */ (function () { function FormatParser(format) { this.start(format); } FormatParser.prototype.start = function (format) { this.formatStr = format; this.pos = 0; this.exprNum = 0; this.tokenText = ''; }; FormatParser.prototype.skipSpaces = function () { while (this.pos < this.formatStr.length && this.formatStr.charAt(this.pos) === ' ') this.pos++; }; FormatParser.prototype.next = function () { this.skipSpaces(); if (this.pos >= this.formatStr.length) return false; var npos = 0; if (this.formatStr.charAt(this.pos) === '{') { npos = this.formatStr.indexOf('}', this.pos); if (npos < 0) return false; this.tokenText = this.formatStr.substring(this.pos, npos + 1); if (this.tokenText.indexOf('{expr') === 0) { this.token = 'expression'; this.exprNum = parseInt(this.tokenText.substring(5, this.tokenText.length)); } this.pos = npos + 1; } else if (this.formatStr.charAt(this.pos) === '[' && this.pos < this.formatStr.length - 1 && this.formatStr.charAt(this.pos + 1) === '[') { this.pos += 2; npos = this.formatStr.indexOf(']]', this.pos); this.token = 'operator'; this.tokenText = this.formatStr.substring(this.pos, npos); this.pos = npos + 2; } else { this.token = 'text'; var npos1 = this.formatStr.indexOf('{', this.pos); if (npos1 < 0) npos1 = this.formatStr.length; var npos2 = this.formatStr.indexOf('[[', this.pos); if (npos2 < 0) npos2 = this.formatStr.length; npos = Math.min(npos1, npos2); this.tokenText = this.formatStr.substring(this.pos, npos).trim(); this.pos = npos; } return true; }; FormatParser.prototype.parse = function () { var result = []; while (this.next()) { if (this.token === 'operator') { result.push({ type: 'operator', text: this.tokenText }); } else if (this.token === 'expression') { result.push({ type: 'expression', index: this.exprNum - 1 }); } else if (this.token === 'text') { result.push({ type: 'text', text: this.tokenText }); } } return result; }; return FormatParser; }()); // CONCATENATED MODULE: ./src/types/data_type.ts /** Represents the common types of the data. */ var DataType; (function (DataType) { /** Unknown type value*/ DataType[DataType["Unknown"] = 0] = "Unknown"; /** String value*/ DataType[DataType["String"] = 1] = "String"; /** 8-bit integer value */ DataType[DataType["Byte"] = 2] = "Byte"; /** 16-bit integer value */ DataType[DataType["Word"] = 3] = "Word"; /** 32-bit integer value */ DataType[DataType["Int32"] = 4] = "Int32"; /** 64-bit integer value */ DataType[DataType["Int64"] = 5] = "Int64"; /** Boolean value */ DataType[DataType["Bool"] = 6] = "Bool"; /** Floating-point numeric value */ DataType[DataType["Float"] = 7] = "Float"; /** Money value */ DataType[DataType["Currency"] = 8] = "Currency"; /** Binary-coded decimal value */ DataType[DataType["BCD"] = 9] = "BCD"; /** Date value */ DataType[DataType["Date"] = 10] = "Date"; /** Time value */ DataType[DataType["Time"] = 11] = "Time"; /** Date and time value */ DataType[DataType["DateTime"] = 12] = "DateTime"; /** Autoincrement 32-bit integer value */ DataType[DataType["Autoinc"] = 13] = "Autoinc"; /** MEMO value (text with unlimited length) */ DataType[DataType["Memo"] = 14] = "Memo"; /** BLOB value (any data with unlimited length) */ DataType[DataType["Blob"] = 15] = "Blob"; /** Fixed character value */ DataType[DataType["FixedChar"] = 16] = "FixedChar"; /** The unique identifier */ DataType[DataType["Guid"] = 17] = "Guid"; /*-------- Spatial data types ----------*/ /** Any geometry data */ DataType[DataType["Geometry"] = 18] = "Geometry"; /** Any data that represents some geography objects</summary> */ DataType[DataType["Geography"] = 19] = "Geography"; })(DataType || (DataType = {})); // CONCATENATED MODULE: ./src/types/link_type.ts /** Represents type of linking of conditions in group (predicate).*/ var LinkType; (function (LinkType) { /** * None of the conditions must be truth (all must be false). * @example * In SQL it will look like: NOT (Condition1 OR Condition2 OR ...). */ LinkType[LinkType["None"] = 0] = "None"; /** At least one condition must be truth. In SQL they are connected by OR operator.*/ LinkType[LinkType["Any"] = 1] = "Any"; /** * Not all conditions must be truth (at least one must false). * In SQL it will look like: * @example * NOT(Condition1 AND Condition2 AND ...). */ LinkType[LinkType["NotAll"] = 2] = "NotAll"; /** All conditions must be truth, in result SQL they are connected by AND operator;*/ LinkType[LinkType["All"] = 3] = "All"; })(LinkType || (LinkType = {})); // CONCATENATED MODULE: ./src/utils/utils.ts var _numericTypes = [DataType.Byte, DataType.Word, DataType.Int32, DataType.Int64, DataType.Float, DataType.Currency]; var _intTypes = [DataType.Byte, DataType.Word, DataType.Int32, DataType.Int64]; var utils_equtils; (function (equtils) { function combinePath(path1, path2) { var result = path1; if (result != null && result.length > 0) { if (result.charAt(result.length - 1) != '/') result += "/"; result += path2; } else result = path2; return result; } equtils.combinePath = combinePath; function assign(target) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } for (var i = 0; i < args.length; i++) { var source = args[i]; for (var key in source) { if (source.hasOwnProperty(key)) { target[key] = source[key]; } } } return target; } equtils.assign = assign; function assignInDepth(target) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } for (var i = 0; i < args.length; i++) { var source = args[i]; for (var key in source) { if (source.hasOwnProperty(key)) { var sourceVal = source[key]; if (sourceVal !== null && typeof sourceVal === 'object') { var targetVal = target[key]; if (typeof targetVal === 'undefined') { target[key] = {}; } assignInDepth(target[key], source[key]); } else { target[key] = source[key]; } } } } return target; } equtils.assignInDepth = assignInDepth; function generateId() { var now = new Date(); var num = Math.floor(Math.random() * 10000); return "Y" + now.getFullYear() + "-M" + now.getMonth() + "-D" + now.getDay() + "-H" + now.getHours() + "-M" + now.getMinutes() + "-S" + now.getSeconds() + "-MS" + now.getMilliseconds() + "-" + num; } equtils.generateId = generateId; function findItemById(array, id) { var arrLength = array.length; for (var idx = 0; idx < arrLength; idx++) { if (array[idx].id === id) return array[idx]; } return null; } equtils.findItemById = findItemById; function indexOfArrayItem(arr, item) { if (arr.indexOf) { return arr.indexOf(item); } else { var len = arr.length; for (var i = 0; i < len; i++) { if (item == arr[i]) { return i; } } return -1; } } equtils.indexOfArrayItem = indexOfArrayItem; function moveArrayItem(arr, old_index, new_index) { if (new_index >= arr.length) { var k = new_index - arr.length; while ((k--) + 1) { arr.push(undefined); } } arr.splice(new_index, 0, arr.splice(old_index, 1)[0]); } equtils.moveArrayItem = moveArrayItem; function removeArrayItem(arr, value) { var index = arr.indexOf(value); if (index != -1) { return arr.splice(index, 1)[0]; } } equtils.removeArrayItem = removeArrayItem; function shiftToFitWindow(absLeft, width) { var body = document.getElementsByTagName('body')[0]; var winWidth = window.innerWidth || document.documentElement.clientWidth || body.clientWidth; var absRight = absLeft + width; var shift = 0; if (absRight > winWidth) { shift = winWidth - absRight - 10; if (absLeft + shift < 0) { shift = 10 - absLeft; } } return shift; } equtils.shiftToFitWindow = shiftToFitWindow; function isObject(val) { if (val === null) { return false; } return ((typeof val === 'function') || (typeof val === 'object')); } equtils.isObject = isObject; function isNumericType(typeName) { var index = _numericTypes.indexOf(typeName); return (index >= 0); } equtils.isNumericType = isNumericType; function isIntType(typeName) { var index = _intTypes.indexOf(typeName); return (index >= 0); } equtils.isIntType = isIntType; function isNumeric(val) { return !isNaN(parseFloat(val)) && isFinite(val); } equtils.isNumeric = isNumeric; function areCompatibleDataTypes(type1, type2) { return typeof type1 == "undefined" || typeof type2 == "undefined" || type1 == DataType.Unknown || type2 == DataType.Unknown || (type1 == type2) || (type1 == DataType.Date && type2 == DataType.DateTime) || (type1 == DataType.DateTime && type2 == DataType.Date); } equtils.areCompatibleDataTypes = areCompatibleDataTypes; function parseOperatorFormat(operator) { var format = eqi18n.getText('Operators', operator.id, 'displayFormat'); if (!format) format = operator.displayFormat; var parser = new FormatParser(format); return parser.parse(); } equtils.parseOperatorFormat = parseOperatorFormat; function isPropSet(obj, propName) { return obj[propName] || obj[propName.toLowerCase()] || obj[propName.toUpperCase()]; } equtils.isPropSet = isPropSet; function strToLinkType(str) { if (str == "All") { return LinkType.All; } else if (str == "NotAll") { return LinkType.NotAll; } else if (str == "Any") { return LinkType.Any; } else { return LinkType.None; } } equtils.strToLinkType = strToLinkType; function linkTypeToStr(type) { if (type === LinkType.All) { return "All"; } else if (type === LinkType.NotAll) { return "NotAll"; } else if (type == LinkType.Any) { return "Any"; } else { return "None"; } } equtils.linkTypeToStr = linkTypeToStr; })(utils_equtils || (utils_equtils = {})); // CONCATENATED MODULE: ./src/utils/constants.ts var eqconsts; (function (eqconsts) { var ConstLists = /** @class */ (function () { function ConstLists() { this.SpecDateValues = [ { id: '${Today}', key: 'Today', isDefault: true }, { id: '${Yesterday}', key: 'Yesterday' }, { id: '${Tomorrow}', key: 'Tomorrow' }, { id: '${FirstDayOfMonth}', key: 'FirstDayOfMonth' }, { id: '${FirstDayOfYear}', key: 'FirstDayOfYear' } ]; this.SpecTimeValues = [ { id: '${Now}', key: 'Now', isDefault: true }, { id: '${HourStart}', key: 'HourStart' }, { id: '${Midnight}', key: 'Midnight' }, { id: '${Noon}', key: 'Noon' } ]; this.BooleanValues = [ { id: '${false}', key: 'False' }, { id: '${true}', key: 'True', isDefault: true } ]; } return ConstLists; }()); eqconsts.ConstLists = ConstLists; /// <var name="constLists" type="ConstLists"> /// <summary> /// Contains the constants used to work with date/time and boolean values. /// </summary> /// </var> eqconsts.constLists = new ConstLists(); eqconsts.predicateLinkTypeList = [ { id: 'All', key: 'LinkTypeAll' }, { id: 'Any', key: 'LinkTypeAny' }, { id: 'None', key: 'LinkTypeNone' }, { id: 'NotAll', key: 'LinkTypeNotAll' } ]; })(eqconsts || (eqconsts = {})); // CONCATENATED MODULE: ./src/types/data_kind.ts /** Represents expression kinds.*/ var DataKind; (function (DataKind) { /** Represents one value of some type: one constant or one attribute (field).*/ DataKind[DataKind["Scalar"] = 0] = "Scalar"; /** The same as Scalar but represents only one constant value of some type.*/ DataKind[DataKind["Const"] = 1] = "Const"; /** The same as Scalar but represents only one attribute.*/ DataKind[DataKind["Attribute"] = 2] = "Attribute"; /** Represents a list of scalar values. */ DataKind[DataKind["List"] = 4] = "List"; /** Special expression kind which represents a sub query.*/ DataKind[DataKind["Query"] = 5] = "Query"; })(DataKind || (DataKind = {})); // CONCATENATED MODULE: ./src/types/cond_tag.ts /** * Represents a type of condition. * Current we have 2 possible types: a simple condition or a predicate - a group of conditions */ var CondTag; (function (CondTag) { /** An unknown type of condition (just in case).*/ CondTag[CondTag["Unknown"] = 0] = "Unknown"; /** A simple condition (e.g. SomeField > SomeValue).*/ CondTag[CondTag["Simple"] = 1] = "Simple"; /** A predicate (a group of conditions).*/ CondTag[CondTag["Predicate"] = 51] = "Predicate"; })(CondTag || (CondTag = {})); // CONCATENATED MODULE: ./src/types/expr_tag.ts /** Contains several constant definitions for expressions tag */ var ExprTag; (function (ExprTag) { /** Unknown expression */ ExprTag[ExprTag["Unknown"] = 0] = "Unknown"; /** Constant expression */ ExprTag[ExprTag["Constant"] = 1] = "Constant"; /** Entity attributre expression */ ExprTag[ExprTag["EntityAttribute"] = 2] = "EntityAttribute"; /** Parent entity attribute expression */ ExprTag[ExprTag["ParentEntityAttribute"] = 3] = "ParentEntityAttribute"; /** Agrregate function expression */ ExprTag[ExprTag["AggregateFunction"] = 4] = "AggregateFunction"; /** Query expression */ ExprTag[ExprTag["Query"] = 11] = "Query"; /** Custom sql expression */ ExprTag[ExprTag["CustomSql"] = 21] = "CustomSql"; })(ExprTag || (ExprTag = {})); // CONCATENATED MODULE: ./src/types/widget_group.ts var WidgetGroup; (function (WidgetGroup) { WidgetGroup[WidgetGroup["None"] = 0] = "None"; WidgetGroup[WidgetGroup["Model"] = 1] = "Model"; WidgetGroup[WidgetGroup["Query"] = 2] = "Query"; WidgetGroup[WidgetGroup["Result"] = 4] = "Result"; WidgetGroup[WidgetGroup["All"] = Number.MAX_SAFE_INTEGER] = "All"; })(WidgetGroup || (WidgetGroup = {})); // EXTERNAL MODULE: ./src/data/data_table.ts var data_table = __webpack_require__(0); // CONCATENATED MODULE: ./src/dm/aggr_function.ts var AggrFunction = /** @class */ (function () { function AggrFunction() { this.id = ""; this.caption = ""; this.sqlExpr = ""; this.displayFormat = ""; } AggrFunction.prototype.loadFromData = function (aggrFunction) { if (aggrFunction) { this.id = aggrFunction.id; this.caption = aggrFunction.cptn; this.displayFormat = aggrFunction.fmt; this.sqlExpr = aggrFunction.expr; } }; return AggrFunction; }()); // CONCATENATED MODULE: ./src/types/editor_tag.ts var EditorTag; (function (EditorTag) { EditorTag["Unknown"] = "Unknown"; EditorTag["Edit"] = "EDIT"; EditorTag["DateTime"] = "DATETIME"; EditorTag["List"] = "LIST"; EditorTag["SqlList"] = "SQLLIST"; EditorTag["CustomList"] = "CUSTOMLIST"; EditorTag["SubQuery"] = "SUBQUERY"; })(EditorTag || (EditorTag = {})); // CONCATENATED MODULE: ./src/dm/value_editor.ts var value_editor_ValueEditor = /** @class */ (function () { function ValueEditor() { this.id = ""; this.tag = EditorTag.Unknown; this.resType = DataType.Unknown; this.defValue = ""; } ValueEditor.prototype.loadFromData = function (data) { if (data) { this.id = data.id; this.tag = data.tag; this.defValue = data.defval; this.resType = data.rtype; if (data.subType) { this.resType = data.subType; } if (data.name) { this.name = data.name; } if (data.sql) { this.sql = data.sql; } } }; return ValueEditor; }()); // CONCATENATED MODULE: ./src/dm/operator.ts var operator_Operator = /** @class */ (function () { function Operator() { this.id = ""; this.caption = "{Unrecognized operator}"; this.displayFormat = "{expr1} [[{unrecognized operator}]] {expr2}"; this.isRange = false; this.caseIns = false; this.paramCount = 2; this.defaultOperand = new operator_Operand(); this.operands = new Array(); } Operator.prototype.loadFromData = function (model, data) { if (data) { this.id = data.id; this.caption = data.cptn; this.caseIns = data.caseIns; this.isRange = data.isRange; this.displayFormat = data.fmt; this.paramCount = data.pcnt; if (data.defOperand) { this.defaultOperand.loadFromData(model, data.defOperand); } if (data.editor) { this.defaultOperand.editor = model.getEditorById(data.editor) || new value_editor_ValueEditor(); } if (data.operands) { for (var i = 0; i < data.operands.length; i++) { var newOperand = new operator_Operand(); newOperand.loadFromData(model, data.operands[i]); if (data.editor) { newOperand.editor = model.getEditorById(data.editor) || new value_editor_ValueEditor(); } this.operands.push(newOperand); } } } }; return Operator; }()); var operator_Operand = /** @class */ (function () { function Operand() { this.kind = DataKind.Scalar; this.dataType = DataType.Unknown; this.editor = new value_editor_ValueEditor(); this.defValue = ""; } Operand.prototype.loadFromData = function (model, operand) { this.kind = operand.kind; this.dataType = operand.dtype; this.defValue = operand.val; this.defText = operand.txt; ; if (operand.editor) { this.editor = model.getEditorById(operand.editor) || new value_editor_ValueEditor(); } }; Operand.prototype.copyFrom = function (src) { utils_equtils.assign(this, src); }; return Operand; }()); // CONCATENATED MODULE: ./src/dm/entity.ts var Entity = /** @class */ (function () { function Entity() { this.name = ""; this.caption = ""; this.description = ""; this.useInConditions = false; this.useInResult = false; this.attributes = new Array(); this.subEntities = new Array(); } Entity.prototype.loadFromData = function (model, data) { if (data) { this.name = data.name; this.caption = data.name; this.description = data.desc; this.useInConditions = data.uic; this.useInResult = data.uir; this.useInSorting = data.uis; this.subEntities = new Array(); if (data.ents) { for (var i = 0; i < data.ents.length; i++) { var newEntity = new Entity(); newEntity.loadFromData(model, data.ents[i]); this.subEntities.push(newEntity); } } this.attributes = new Array(); if (data.attrs) { for (var i = 0; i < data.attrs.length; i++) { var newAttr = new entity_EntityAttr(); newAttr.loadFromData(model, data.attrs[i]); this.attributes.push(newAttr); } } } }; return Entity; }()); var entity_EntityAttr = /** @class */ (function () { function EntityAttr() { this.params = []; this.id = ""; this.caption = "{Unrecognized attribute}"; this.dataType = DataType.String; this.size = 0; this.usedInCondition = false; this.usedInResult = false; this.usedInSorting = false; this.defaultOperator = ""; this.operators = new Array(); this.lookupAttr = ""; this.sqlExpr = ""; } EntityAttr.prototype.loadFromData = function (model, data) { if (data) { this.id = data.id; this.description = data.desc; this.caption = data.cptn; this.dataType = data.dtype; this.usedInCondition = data.uic; this.usedInResult = data.uir; this.usedInSorting = data.uis; this.size = data.size; this.sqlExpr = data.sqlExpr; this.defaultOperator = data.defOperator; this.operators = data.ops; this.lookupAttr = data.lookupAttr; if (data.edtr) { this.defaultEditor = model.getEditorById(data.edtr) || new value_editor_ValueEditor(); } } }; return EntityAttr; }()); // CONCATENATED MODULE: ./src/dm/expression.ts var expression_Expression = /** @class */ (function () { function Expression() { this.id = null; this.tag = ExprTag.Constant; this.kind = DataKind.Scalar; this.dataType = DataType.String; //DO NOT forget remove any this.value = ''; this.text = ''; this.distinct = false; this.args = new Array(); } Expression.prototype.loadFromData = function (model, data) { if (data) { this.id = data.id; this.tag = data.tag; //Do not save other info for EntityAttr if (this.tag == ExprTag.EntityAttribute || this.tag == ExprTag.ParentEntityAttribute) { return; } this.kind = data.kind; this.dataType = data.dtype; if (data.query) { this.query = new query_Query(model); this.query.setData(data.query); } if (data.val) { this.value = data.val; this.text = data.txt; } if (typeof data.distinct !== 'undefined') { this.distinct = data.distinct; } if (data.func) { this.func = data.func; if (data.args) { for (var i = 0; i < data.args.length; i++) { var arg = new Expression(); arg.loadFromData(model, data.args[i]); this.args.push(arg); } } } if (data.sql) { this.sql = data.sql; this.baseAttrId = data.baseAttrId; } } }; Expression.prototype.saveToData = function () { var obj = { id: this.id, tag: this.tag }; //Do not save other info for EntityAttr if (this.tag == ExprTag.EntityAttribute) { return obj; } if (this.query) { obj.query = this.query.toJSONData(); } if (typeof this.kind !== "undefined") { obj.kind = this.kind; } if (typeof this.dataType !== "undefined") { obj.dtype = this.dataType; } if (this.value) { obj.val = this.value; } if (this.text) { obj.txt = this.text; } if (this.distinct) { obj.distinct = this.distinct; } if (this.func) { obj.func = this.func; obj.args = []; for (var i = 0; i < this.args.length; i++) { obj.args.push(this.args[i].saveToData()); } } if (this.sql) { obj.sql = this.sql; obj.baseAttrId = this.baseAttrId; } return obj; }; return Expression; }()); // CONCATENATED MODULE: ./src/query/column.ts /** Represents sorting direction. */ var SortDirection; (function (SortDirection) { /** No sorting. */ SortDirection[SortDirection["None"] = 0] = "None"; /** Ascending order. */ SortDirection[SortDirection["Ascending"] = 1] = "Ascending"; /** Descending order. */ SortDirection[SortDirection["Descending"] = 2] = "Descending"; })(SortDirection || (SortDirection = {})); var column_Column = /** @class */ (function () { function Column() { this.params = []; this.caption = ""; this.sorting = SortDirection.None; this.sortIndex = -1; this.expr = new expression_Expression(); this.blockId = ""; } Column.prototype.loadFromData = function (model, data) { if (data) { this.caption = data.cptn; if (typeof data.srt !== "undefined") { this.sorting = data.srt; this.sortIndex = data.srtidx; } this.expr.loadFromData(model, data.expr); //this.params = column.params as string[]; !!!!!!!!!!! this.blockId = data.blockId; } }; Column.prototype.saveToData = function () { var obj = {}; if (this.caption) { obj.cptn = this.caption; } if (typeof this.sorting !== "undefined") { obj.srt = this.sorting; obj.srtidx = this.sortIndex; } obj.expr = this.expr.saveToData(); if (this.blockId) { obj.blockId = this.blockId; } return obj; }; return Column; }()); // CONCATENATED MODULE: ./src/query/condition.ts var condition_Condition = /** @class */ (function () { function Condition(tag) { this.linkType = LinkType.All; //only for predicates console.log("Creating condition...", tag); this.justAdded = false; this.tag = tag || CondTag.Unknown; this.enabled = true; this.readOnly = false; this.parameterized = false; this.inJoin = false; this.operatorID = ""; this.blockId = ""; this.expressions = new Array(); this.conditions = new Array(); } Condition.prototype.loadFromData = function (model, data) { console.log("Loading condition...", data); if (data) { this.tag = data.tag; if (this.tag == CondTag.Simple) { if (typeof data.enabled !== "undefined") { this.enabled = data.enabled; } if (typeof data.readOnly !== "undefined") { this.readOnly = data.readOnly; } if (typeof data.inJoin !== "undefined") { this.inJoin = data.inJoin; } if (typeof data.parameterized !== "undefined") { this.parameterized = data.parameterized; } this.operatorID = data.op; ///!!!!!!!!!!!TODO: read ReadOnly and other condition properties if (data.exprs) { for (var i = 0; i < data.exprs.length; i++) { var newExpr = new expression_Expression(); newExpr.loadFromData(model, data.exprs[i]); this.expressions.push(newExpr); } } } else { //if predicate this.linkType = data.linking; if (data.conds) { for (var i = 0; i < data.conds.length; i++) { var newCond = new Condition(); newCond.loadFromData(model, data.conds[i]); this.conditions.push(newCond); } } } } }; Condition.prototype.saveToData = function () { var obj = {}; obj.tag = this.tag; if (this.tag == CondTag.Simple) { if (this.enabled == false) { obj.enabled = this.enabled; } if (this.parameterized) { obj.parameterized = this.parameterized; } if (this.inJoin) { obj.inJoin = this.inJoin; } obj.op = this.operatorID; ///!!!!!!!!!!!TODO: read ReadOnly and other condition properties obj.exprs = []; for (var i = 0; i < this.expressions.length; i++) { obj.exprs.push(this.expressions[i].saveToData()); } } else { //if predicate obj.linking = this.linkType; obj.conds = []; for (var i = 0; i < this.conditions.length; i++) { obj.conds.push(this.conditions[i].saveToData()); } } return obj; }; return Condition; }()); // CONCATENATED MODULE: ./src/event/event_emitter.ts var EqGuid = /** @class */ (function () { function EqGuid() { } EqGuid.newGuid = function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }; return EqGuid; }()); var EventEmitter = /** @class */ (function () { function EventEmitter(source) { this.silentMode = 0; this.events = new Array(); this.source = source; } EventEmitter.prototype.subscribe = function (eventType, callback) { var event = this.getEventRecByType(eventType); var eventCallback = { id: EqGuid.newGuid(), callback: callback }; if (event) { event.eventCallbacks.push(eventCallback); } else { event = { type: eventType, eventCallbacks: new Array(eventCallback) }; this.events.push(event); } return eventCallback.id; }; EventEmitter.prototype.unsubscribe = function (eventType, callbackId) { var event = this.getEventRecByType(eventType); if (event) { var index = -1; for (index = 0; index < event.eventCallbacks.length; index++) { if (event.eventCallbacks[index].id === callbackId) { break; } } if (index >= 0) { event.eventCallbacks.splice(index, 1); } } }; EventEmitter.prototype.fire = function (eventType, data, postpone, force) { if (postpone === void 0) { postpone = 0; } if (force === void 0) { force = false; } if (this.silentMode && !force) { return; } var eventRec = this.getEventRecByType(eventType); if (eventRec) { var eqevent_1 = { type: eventType, source: this.source, data: data }; var emitAllFunc = function () { for (var _i = 0, _a = eventRec.eventCallbacks; _i < _a.length; _i++) { var callback = _a[_i]; callback.callback(eqevent_1); } }; if (postpone > 0) { setTimeout(emitAllFunc, postpone); } else { emitAllFunc(); } } }; EventEmitter.prototype.enterSilentMode = function () { this.silentMode++; }; EventEmitter.prototype.exitSilentMode = function () { if (this.silentMode) { this.silentMode--; } }; EventEmitter.prototype.isSilent = function () { return this.silentMode > 0; }; EventEmitter.prototype.getEventRecByType = function (eventType) { for (var _i = 0, _a = this.events; _i < _a.length; _i++) { var event_1 = _a[_i]; if (event_1.type == eventType) { return event_1; } } return null; }; return EventEmitter; }()); // CONCATENATED MODULE: ./src/query/query.ts var query_Query = /** @class */ (function () { function Query(model, data, options) { this.eventEmitter = new EventEmitter(this); this.id = ""; this.root = new condition_Condition(CondTag.Predicate); this.columns = new Array(); this.justsorted = new Array(); this.name = ""; this.description = ""; this.modelId = ""; this.modelName = ""; this.model = (model) ? model : new data_model_DataModel(); if (data) { this.loadFro