devexpress-reporting
Version:
DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.
979 lines (975 loc) • 932 kB
JavaScript
/**
* DevExpress HTML/JS Analytics Core (dx-designer.js)
* Version: 18.1.10
* Build date: 2019-03-10
* Copyright (c) 2012 - 2019 Developer Express Inc. ALL RIGHTS RESERVED
* License: https://www.devexpress.com/Support/EULAs/NetComponents.xml
*/
var $ = require('jquery');
var ko = require('knockout');
require('jquery-ui/ui/widgets/draggable');
require('jquery-ui/ui/widgets/resizable');
require('jquery-ui/ui/widgets/selectable');
require('jquery-ui/ui/widgets/mouse');
require('devextreme/integration/jquery');
require('devextreme/integration/knockout');
require('devextreme/ui/button');
require('devextreme/ui/scroll_view');
require('devextreme/ui/text_area');
require('devextreme/ui/select_box');
require('devextreme/ui/tab_panel');
require('devextreme/ui/color_box');
require('devextreme/ui/date_box');
require('devextreme/ui/tag_box');
require('devextreme/ui/validator');
require('devextreme/ui/validation_group');
require('devextreme/localization/globalize/date');
var ace = require("ace-builds/src-noconflict/ace");
require("ace-builds/webpack-resolver");
require("ace-builds/src-noconflict/ext-language_tools");
require("ace-builds/src-noconflict/snippets/text");
var DevExpress = DevExpress || {};
DevExpress.Analytics = DevExpress.Analytics || {};
DevExpress.Analytics.Localization = DevExpress.Analytics.Localization || {};
DevExpress.Analytics.Localization.Globalize = DevExpress.Analytics.Localization.Globalize || require('globalize');
DevExpress.Analytics.Widgets = DevExpress.Analytics.Widgets || {};
DevExpress.Analytics.Widgets.ace = ace;
DevExpress.ui = DevExpress.ui || {};
DevExpress.ui.dxTextBox = DevExpress.ui.dxTextBox || require('devextreme/ui/text_box');
DevExpress.ui.dxPopup = DevExpress.ui.dxPopup || require('devextreme/ui/popup');
DevExpress.ui.dxDropDownEditor = DevExpress.ui.dxDropDownEditor || require('devextreme/ui/drop_down_editor/ui.drop_down_editor');
DevExpress.ui.notify = DevExpress.ui.notify || require('devextreme/ui/notify');
DevExpress.data = DevExpress.data || {};
DevExpress.data.ArrayStore = DevExpress.data.ArrayStore || require('devextreme/data/array_store');
DevExpress.data.DataSource = DevExpress.data.DataSource || require('devextreme/data/data_source');
DevExpress.validationEngine = DevExpress.validationEngine || require('devextreme/ui/validation_engine');
DevExpress.config = DevExpress.config || require('devextreme/core/config');
DevExpress.registerComponent = DevExpress.registerComponent || require('devextreme/core/component_registrator');
module.exports = DevExpress;
module.exports.default = module.exports;
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Internal;
(function (Internal) {
function _defineProperty(legacyObject, realObject, propertyName) {
delete legacyObject[propertyName];
Object.defineProperty(legacyObject, propertyName, {
get: function () { return realObject[propertyName]; },
set: function (newVal) { realObject[propertyName] = newVal; },
configurable: true
});
}
Internal._defineProperty = _defineProperty;
})(Internal = Analytics.Internal || (Analytics.Internal = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Utils;
(function (Utils) {
function deserializeArray(model, creator) {
var result = [];
getPropertyValues(model).forEach(function (item) {
var createdItem = creator(item);
result.push(createdItem);
});
return ko.observableArray(result);
}
Utils.deserializeArray = deserializeArray;
function toStringWithDelimiter(values, delimiter) {
return (values || []).map(function (value) {
var str = value !== undefined && value !== null ? value.toString() : "00";
if (str.length === 1) {
str = "0" + str;
}
return str;
}).join(delimiter);
}
function serializeDate(date) {
var datePart = [date.getMonth() + 1, date.getDate(), date.getFullYear()];
var timePart = toStringWithDelimiter([date.getHours(), date.getMinutes(), date.getSeconds()], ":");
return timePart === "00:00:00" ? toStringWithDelimiter([datePart[2], datePart[0], datePart[1]], "-")
: toStringWithDelimiter(datePart, "/") + " " + timePart;
}
Utils.serializeDate = serializeDate;
function knockoutArrayWrapper(items) {
var onChange = [];
for (var _i = 1; _i < arguments.length; _i++) {
onChange[_i - 1] = arguments[_i];
}
var array = ko.observableArray(items);
var notifySubscribers = array.notifySubscribers;
array.notifySubscribers = function (valueToNotify, event) {
if (onChange) {
for (var i = 0, len = onChange.length; i < len; i++) {
onChange[i](valueToNotify, event);
}
}
return notifySubscribers.call(array, valueToNotify, event);
};
return array;
}
Utils.knockoutArrayWrapper = knockoutArrayWrapper;
function isWindow(obj) {
return obj != null && obj === obj.window;
}
var class2type = {};
var hasOwn = class2type.hasOwnProperty;
["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Object", "Error"].forEach(function (name) { return class2type["[object " + name + "]"] = name.toLowerCase(); });
function type(obj) {
if (obj == null) {
return obj + "";
}
return typeof obj === "object" || typeof obj === "function" ?
class2type[class2type.toString.call(obj)] || "object" :
typeof obj;
}
function isNumeric(obj) {
return !Array.isArray(obj) && (obj - parseFloat(obj) + 1) >= 0;
}
function isPlainObject(obj) {
if (type(obj) !== "object" || obj.nodeType || isWindow(obj)) {
return false;
}
return !(obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf"));
}
Utils.isPlainObject = isPlainObject;
function isEmptyObject(obj) {
if ((typeof obj) === "string") {
return false;
}
for (var name in obj) {
return false;
}
return true;
}
Utils.isEmptyObject = isEmptyObject;
function isFunction(obj) {
return type(obj) === "function";
}
function extend(target, object1) {
var objectN = [];
for (var _i = 2; _i < arguments.length; _i++) {
objectN[_i - 2] = arguments[_i];
}
var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;
if (typeof target === "boolean") {
deep = target;
target = arguments[i] || {};
i++;
}
if (typeof target !== "object" && !isFunction(target)) {
target = {};
}
if (i === length) {
target = this;
i--;
}
for (; i < length; i++) {
if ((options = arguments[i]) != null) {
for (name in options) {
src = target[name];
copy = options[name];
if (target === copy) {
continue;
}
if (deep && copy && (isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && Array.isArray(src) ? src : [];
}
else {
clone = src && isPlainObject(src) ? src : {};
}
target[name] = extend(deep, clone, copy);
}
else if (copy !== undefined) {
target[name] = copy;
}
}
}
}
return target;
}
Utils.extend = extend;
;
function getPropertyValues(target) {
if (target === void 0) { target = {}; }
var result = [];
for (var propertyName in target) {
result.push(target[propertyName]);
}
return result;
}
Utils.getPropertyValues = getPropertyValues;
})(Utils = Analytics.Utils || (Analytics.Utils = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
/// <reference path="utils.ts" />
/// <reference path="serializationInfo.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Utils;
(function (Utils) {
var ModelSerializer = (function () {
function ModelSerializer(options) {
this._refTable = {};
this._linkTable = {};
this._options = Utils.extend({
useRefs: true,
serializeDate: Utils.serializeDate
}, options);
}
ModelSerializer.prototype.linkObjects = function () {
for (var index in this._linkTable) {
var val = this._refTable[index];
if (val) {
var properties = this._linkTable[index];
properties.forEach(function (property) { return property(val); });
}
}
;
};
ModelSerializer.prototype.deserializeProperty = function (modelPropertyInfo, model) {
var _this = this;
var modelValue = modelPropertyInfo.defaultVal, propertyName = modelPropertyInfo.propertyName, propName = modelPropertyInfo.modelName;
if (!propName) {
return;
}
if (model[propName] !== undefined) {
modelValue = model[propName];
}
if (typeof modelPropertyInfo === "string") {
return ko.observable(modelValue);
}
else if (modelPropertyInfo.link) {
var value = ko.observable(null);
if (modelValue) {
var refVal = modelValue && modelValue.slice("#Ref-".length);
this._linkTable[refVal] = this._linkTable[refVal] || [];
this._linkTable[refVal].push(value);
}
return value;
}
else if (modelPropertyInfo.array) {
if (modelPropertyInfo.from) {
return modelPropertyInfo.from(modelValue, this);
}
else if (modelPropertyInfo.info) {
var result = [];
Utils.getPropertyValues(modelValue).forEach(function (item) {
var object = { getInfo: function () { return modelPropertyInfo.info; } };
_this.deserialize(object, item || {});
result.push(object);
});
return ko.observableArray(result);
}
}
else if (modelPropertyInfo.from) {
return modelPropertyInfo.from(modelValue, this);
}
else if (modelPropertyInfo.type) {
var ctorResult = new modelPropertyInfo.type(modelValue, this, modelPropertyInfo.info);
if (!ctorResult._model) {
this.deserialize(ctorResult, modelValue || {}, modelPropertyInfo.info);
}
return ctorResult;
}
else if (modelPropertyInfo.info) {
var object = { getInfo: function () { return modelPropertyInfo.info; } };
this.deserialize(object, modelValue || {});
return object;
}
else if (modelPropertyInfo.modelName) {
return ko.observable(modelValue);
}
else {
throw new Error("Invalid info '" + JSON.stringify(modelPropertyInfo) + "'");
}
};
ModelSerializer.prototype.deserialize = function (viewModel, model, serializationsInfo) {
var _this = this;
if (serializationsInfo === void 0) { serializationsInfo = null; }
if (!model) {
return;
}
viewModel._model = Utils.extend({}, model);
var serializationsInfo = viewModel.getInfo ? viewModel.getInfo() : serializationsInfo;
var refValue = model["@Ref"];
if (refValue) {
this._refTable[refValue] = viewModel;
}
serializationsInfo.forEach(function (modelPropertyInfo) {
var propertyName = modelPropertyInfo.propertyName, propName = modelPropertyInfo.modelName;
if (model[propName] !== undefined) {
delete viewModel._model[propName];
}
var property = _this.deserializeProperty(modelPropertyInfo, model);
if (property !== undefined)
viewModel[propertyName] = property;
});
this.linkObjects();
};
ModelSerializer.prototype.serialize = function (viewModel, serializationsInfo, refs) {
if (refs === void 0) { refs = null; }
if (!serializationsInfo && !refs) {
return this._serialize(viewModel, null, null);
}
return this._serialize(viewModel, serializationsInfo, refs);
};
ModelSerializer.prototype._isSerializableValue = function (resultValue) {
return (Utils.isPlainObject(resultValue) && !Utils.isEmptyObject(resultValue)) || (Array.isArray(resultValue) && resultValue["length"] > 0) || (!Array.isArray(resultValue) && !Utils.isPlainObject(resultValue));
};
ModelSerializer.prototype._serialize = function (viewModel, serializationsInfo, refs) {
var _this = this;
var result = Utils.extend({}, viewModel._model), isInitial = refs === null;
refs = refs || { linkObjTable: [], objects: [] };
serializationsInfo = viewModel.getInfo ? viewModel.getInfo() : serializationsInfo;
delete result["@Ref"];
if (viewModel["isEmpty"] && viewModel["isEmpty"]())
return {};
serializationsInfo.forEach(function (modelPropertyInfo) {
var propertyName = modelPropertyInfo.propertyName, value = ko.unwrap(viewModel["_" + propertyName] || viewModel[propertyName]), defaultVal = modelPropertyInfo.defaultVal;
if (!!modelPropertyInfo.from) {
defaultVal = ko.unwrap(modelPropertyInfo.from(defaultVal, _this));
}
var resultValue = {};
if (!modelPropertyInfo.modelName) {
return;
}
if (modelPropertyInfo.alwaysSerialize || ((value !== undefined && value !== null) && ((Utils.isPlainObject(value) || !Utils.isEmptyObject(value)) || (Array.isArray(value) && value.length > 0) || (!Array.isArray(value) && !Utils.isPlainObject(value))) && (value !== defaultVal))) {
if (modelPropertyInfo.link) {
refs.linkObjTable.push({
obj: value,
setRef: function (index) {
if (index < 0) {
delete result[modelPropertyInfo.modelName];
}
else {
result[modelPropertyInfo.modelName] = "#Ref-" + index;
}
}
});
resultValue = undefined;
}
else if (modelPropertyInfo.array) {
resultValue = {};
var index = 1;
value.forEach(function (item) {
var info = modelPropertyInfo.info || null;
var item_ = _this._serialize(item, info, refs);
if (_this._isSerializableValue(item_)) {
resultValue["Item" + index] = item_;
if (_this._options.useRefs) {
item_["@Ref"] = (refs.objects.push(item) - 1).toString();
}
index++;
}
});
}
else if (modelPropertyInfo.from) {
if (value["isEmpty"] && value["isEmpty"]()) {
resultValue = {};
}
else {
resultValue = modelPropertyInfo.toJsonObject ? modelPropertyInfo.toJsonObject(value, _this, refs) : value.toString();
}
}
else if (modelPropertyInfo.info || value["getInfo"]) {
resultValue = _this._serialize(value, modelPropertyInfo.info, refs);
}
else if (modelPropertyInfo.modelName) {
if (value instanceof Date) {
resultValue = _this._options.serializeDate(value);
}
else {
resultValue = value;
}
}
else {
throw new Error("Invalid info '" + serializationsInfo.stringify() + "'");
}
if (modelPropertyInfo.alwaysSerialize || _this._isSerializableValue(resultValue)) {
result[modelPropertyInfo.modelName] = resultValue;
}
}
});
if (isInitial) {
refs.linkObjTable.forEach(function (item) {
var refValue = refs.objects.indexOf(item.obj);
item.setRef(refValue);
});
}
return result;
};
return ModelSerializer;
})();
Utils.ModelSerializer = ModelSerializer;
})(Utils = Analytics.Utils || (Analytics.Utils = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
/// <reference path="serializer.ts" />
/// <reference path="serializationInfo.ts" />
/// <reference path="utils.ts" />
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var DevExpress;
(function (DevExpress) {
var JS;
(function (JS) {
var Utils;
(function (Utils) {
Utils.deserializeArray = DevExpress.Analytics.Utils.deserializeArray;
var ModelSerializer = (function (_super) {
__extends(ModelSerializer, _super);
function ModelSerializer() {
_super.apply(this, arguments);
}
return ModelSerializer;
})(DevExpress.Analytics.Utils.ModelSerializer);
Utils.ModelSerializer = ModelSerializer;
Utils.serializeDate = DevExpress.Analytics.Utils.serializeDate;
Utils.extend = DevExpress.Analytics.Utils.extend;
Utils.isPlainObject = DevExpress.Analytics.Utils.isPlainObject;
Utils.isEmptyObject = DevExpress.Analytics.Utils.isEmptyObject;
Utils.getPropertyValues = DevExpress.Analytics.Utils.getPropertyValues;
Utils.knockoutArrayWrapper = DevExpress.Analytics.Utils.knockoutArrayWrapper;
;
;
;
;
;
})(Utils = JS.Utils || (JS.Utils = {}));
})(JS = DevExpress.JS || (DevExpress.JS = {}));
})(DevExpress || (DevExpress = {}));
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "deserializeArray");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "ModelSerializer");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "serializeDate");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "extend");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "isPlainObject");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "isEmptyObject");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "getPropertyValues");
DevExpress.Analytics.Internal._defineProperty(DevExpress.JS.Utils, DevExpress.Analytics.Utils, "knockoutArrayWrapper");
//# sourceMappingURL=dx-ko-serializer.js.map
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Localization;
(function (Localization) {
Localization.Globalize = DevExpress.Analytics.Localization.Globalize || window["Globalize"];
Localization.messages = {};
function addCultureInfo(json) {
$.extend(Localization.messages, json.messages);
}
Localization.addCultureInfo = addCultureInfo;
function localize(val) {
return Localization.messages[val];
}
Localization.localize = localize;
function parseDate(val) {
if (val) {
if (val instanceof Date)
return val;
var enGlobalize = new Localization.Globalize("en");
var date = enGlobalize["parseDate"](val, { raw: "MM/dd/yyyy HH:mm:ss" });
if (!date)
date = enGlobalize["parseDate"](val, { raw: "yyyy-MM-dd" });
return date;
}
return null;
}
Localization.parseDate = parseDate;
function selectPlaceholder() {
return Analytics.getLocalization("Select...", "ASPxReportsStringId.ReportDesigner_PropertyGrid_Editor_EmptyText");
}
Localization.selectPlaceholder = selectPlaceholder;
function noDataText() {
return Analytics.getLocalization("No data to display", "ASPxReportsStringId.ReportDesigner_DataPreview_Empty");
}
Localization.noDataText = noDataText;
})(Localization = Analytics.Localization || (Analytics.Localization = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
function _getLocalization(text) {
return (Analytics.Localization.localize(text)) || text;
}
var custom_localization_values = {};
function isCustomizedWithUpdateLocalizationMethod(text) {
return !!custom_localization_values[text];
}
Analytics.isCustomizedWithUpdateLocalizationMethod = isCustomizedWithUpdateLocalizationMethod;
function getLocalization(text, id) {
if (id === void 0) { id = null; }
var result;
if (id && !isCustomizedWithUpdateLocalizationMethod(text)) {
result = Analytics.Localization.localize(id);
}
return result || _getLocalization(text);
}
Analytics.getLocalization = getLocalization;
function updateLocalization(object) {
$.extend(custom_localization_values, object);
var messages = {};
for (var name in object) {
messages[name] = object[name];
}
Analytics.Localization.addCultureInfo({
messages: messages
});
}
Analytics.updateLocalization = updateLocalization;
;
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Utils;
(function (Utils) {
DevExpress.Analytics.Utils.getLocalization = Analytics.getLocalization;
})(Utils = Analytics.Utils || (Analytics.Utils = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
Analytics.StringId = {
MasterDetailRelationsEditor: "DataAccessUIStringId.MasterDetailEditorForm_Title",
DataAccessBtnOK: "DataAccessUIStringId.Button_OK",
DataAccessBtnCancel: "DataAccessUIStringId.Button_Cancel",
DataSourceWizardTitle: "DataAccessUIStringId.WizardTitleDatasource",
WizardPageConfigureQuery: 'DataAccessUIStringId.WizardPageConfigureQuery'
};
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Utils;
(function (Utils) {
function compareEditorInfo(editor1, editor2) {
return !!editor1 && !!editor2 &&
editor1.header === editor2.header
&& editor1.content === editor2.content
&& editor1.editorType === editor2.editorType;
}
Utils.compareEditorInfo = compareEditorInfo;
function getLocalization(value) {
return Analytics.Localization && Analytics.Localization.localize(value) || value;
}
Utils.getLocalization = getLocalization;
function findMatchesInString(textToTest, searchPattern) {
var searchExpr = escapeToRegExp(searchPattern);
return !!textToTest && textToTest.match(new RegExp(searchExpr, "gi"));
}
Utils.findMatchesInString = findMatchesInString;
function escapeToRegExp(string) {
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
Utils.escapeToRegExp = escapeToRegExp;
function formatUnicorn(text) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var str = text.toString();
if (args.length) {
var t = typeof args[0];
var key;
var argsFinal = ("string" === t || "number" === t) ?
Array.prototype.slice.call(args)
: args[0];
for (key in argsFinal) {
str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), argsFinal[key]);
}
}
return str;
}
Utils.formatUnicorn = formatUnicorn;
})(Utils = Analytics.Utils || (Analytics.Utils = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Widgets;
(function (Widgets) {
Widgets.editorTemplates = {
color: { header: "dx-color" },
bool: { header: "dx-boolean" },
boolSelect: { header: "dx-boolean-select" },
numeric: { header: "dx-numeric" },
date: { header: "dx-date" },
modificators: { custom: "dx-modificators" },
combobox: { header: "dx-combobox" },
comboboxEditable: { header: "dx-combobox-editable" },
text: { header: "dx-text" },
image: { header: "dx-image" },
file: { header: "dx-file" },
commonCollection: { custom: "dx-commonCollection" },
stringArray: { header: "dx-emptyHeader", content: "dx-string-array" }
};
})(Widgets = Analytics.Widgets || (Analytics.Widgets = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
/// <reference path="editorsInfo.ts" />
/// <reference path="../utils.ts" />
///<reference path="../Localization/localization.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Widgets;
(function (Widgets) {
Widgets.propertiesGridEditorsPaddingLeft = 19;
var Editor = (function () {
function Editor(modelPropertyInfo, level, parentDisabled, textToSearch) {
var _this = this;
if (parentDisabled === void 0) { parentDisabled = ko.observable(false); }
if (textToSearch === void 0) { textToSearch = undefined; }
this._model = ko.observable();
this.isVisibleByContent = ko.observable(true);
this.isSearchedProperty = ko.observable(true);
this.isParentSearched = ko.observable(false);
this.rtl = DevExpress["config"]()["rtlEnabled"];
this.isEditorSelected = ko.observable(false);
this.isPropertyModified = ko.computed(function () {
return _this._model() && _this._model().isPropertyModified && _this._model().isPropertyModified(_this.name);
});
this.collapsed = ko.observable(true);
this.info = ko.observable(modelPropertyInfo);
this.displayName = ko.computed(function () {
var info = _this.info();
return info && DevExpress.Analytics.getLocalization(info.displayName, info["localizationId"]);
});
if (textToSearch) {
this.textToSearch = textToSearch;
this.isSearchedProperty = ko.computed(function () {
return _this.isParentSearched() || !!Analytics.Utils.findMatchesInString(_this.displayName(), textToSearch());
});
}
this.padding = this._setPadding(this.rtl ? "right" : "left", level * Widgets.propertiesGridEditorsPaddingLeft);
var defaultValue = ko.observable(null), propertyName = modelPropertyInfo.propertyName;
this.editorOptions = modelPropertyInfo.editorOptions;
if (modelPropertyInfo.defaultVal !== undefined) {
defaultValue = ko.observable(modelPropertyInfo.defaultVal);
}
if (modelPropertyInfo.from) {
defaultValue = modelPropertyInfo.from(modelPropertyInfo.defaultVal);
}
if (modelPropertyInfo.array) {
defaultValue = ko.observableArray();
}
this.values = ko.computed(function () {
var _values = _this.info().valueStore || _this.info().valuesArray;
if (_values) {
return _values;
}
_values = ko.unwrap(_this.info().values);
if (_values) {
return $.map(_values, function (displayValue, value) {
return { value: value, displayValue: displayValue };
});
}
});
this.level = level;
this._init(modelPropertyInfo.editor, defaultValue, propertyName);
var calculateAccessibleByPropertyInfo = function (model, propertyInfo, defaultValue) {
var result;
if (ko.isObservable(propertyInfo)) {
result = propertyInfo();
}
else if (typeof propertyInfo === 'function') {
result = propertyInfo(model);
}
else {
result = propertyInfo !== undefined ? propertyInfo : defaultValue;
}
return result;
};
this.disabled = ko.computed(function () {
var model = _this._model(), result = parentDisabled() || model && (model.isPropertyDisabled && model.isPropertyDisabled(_this.name));
if (!result) {
result = calculateAccessibleByPropertyInfo(model, _this.info().disabled, false);
}
return result;
});
this.visible = ko.computed(function () {
var model = _this._model(), result = _this.isSearchedProperty() && ((model && model.isPropertyVisible) ? model.isPropertyVisible(_this.name) : _this.isVisibleByContent());
if (result) {
result = calculateAccessibleByPropertyInfo(model, _this.info().visible, true);
}
return result;
});
}
Editor.prototype._setPadding = function (position, value) {
var obj = {};
obj["padding-" + position] = value;
return obj;
};
Editor.prototype._init = function (editorTemplate, value, name) {
var _this = this;
editorTemplate = editorTemplate || Widgets.editorTemplates.text;
this.templateName = editorTemplate.header;
this.contentTemplateName = editorTemplate.content;
this.defaultValue = editorTemplate === Widgets.editorTemplates.color ? "transparent" : null;
var cachedValue = undefined;
this.value = ko.computed({
read: function () {
var model = _this._model();
if (!model && cachedValue) {
return cachedValue;
}
var modelValue = model && model[name] !== undefined ? model[name] : value;
if (ko.isObservable(modelValue) && !modelValue["push"]) {
var hasValueInModel = modelValue() !== undefined && modelValue() !== null;
cachedValue = hasValueInModel ? modelValue() : _this.defaultValue;
return cachedValue;
}
else {
cachedValue = modelValue;
return cachedValue;
}
},
write: function (val) {
var model = _this._model();
if (!model) {
return;
}
var modelValue = model[name];
if (!DevExpress["validationEngine"].validate(val, _this.validationRules, _this.displayName()).isValid) {
return;
}
if (ko.isObservable(modelValue)) {
modelValue(val);
}
else {
model[name] = val;
}
}
});
this.name = name;
this.editorTemplate = editorTemplate && editorTemplate.custom || 'dx-property-editor';
};
Editor.prototype.findInfo = function (viewModel) {
var _this = this;
if (!viewModel)
return null;
var modelInfo = viewModel["getInfo"] && viewModel["getInfo"]();
if (modelInfo) {
return modelInfo.filter(function (property) { return property.propertyName === _this.name; })[0];
}
return null;
};
Editor.prototype.updateInfo = function (propertyInfo) {
if (propertyInfo && Analytics.Utils.compareEditorInfo(propertyInfo.editor, this.info().editor)) {
if (this.info() !== propertyInfo) {
this.info(propertyInfo);
}
return true;
}
return !propertyInfo;
};
Editor.prototype.update = function (viewModel) {
if (!!viewModel) {
var propertyInfo = this.findInfo(viewModel);
this.isVisibleByContent(this.name in viewModel && this.updateInfo(propertyInfo));
this._model(this.isVisibleByContent() ? viewModel : null);
}
else {
this.isVisibleByContent(false);
this._model(null);
}
};
Editor.prototype.getOptions = function (templateOptions) {
var extendedOptions = this.info.peek().editor.extendedOptions;
return $.extend({}, templateOptions, this.editorOptions, extendedOptions);
};
Editor.prototype.getValidationRules = function () {
return !!this.info && !!this.info() && this.info().validationRules || [];
};
Object.defineProperty(Editor.prototype, "validationRules", {
get: function () {
return this.getValidationRules();
},
enumerable: true,
configurable: true
});
Object.defineProperty(Editor.prototype, "isComplexEditor", {
get: function () { return !!this.contentTemplateName; },
enumerable: true,
configurable: true
});
return Editor;
})();
Widgets.Editor = Editor;
})(Widgets = Analytics.Widgets || (Analytics.Widgets = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
/// <reference path="utils.ts" />
/// <reference path="widgets/editor.ts" />
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Widgets;
(function (Widgets) {
var ObjectProperties = (function () {
function ObjectProperties(target, editorsInfo, level, parentDisabled, recreateEditors, textToSearch) {
var _this = this;
if (level === void 0) { level = 0; }
if (parentDisabled === void 0) { parentDisabled = ko.observable(false); }
if (recreateEditors === void 0) { recreateEditors = false; }
this._targetSubscription = null;
this._infoSubscription = null;
this._getInfoComputed = null;
this.level = 0;
this.rtl = DevExpress['config']()['rtlEnabled'];
this._editors = ko.observableArray([]);
this.level = level;
this._parentDisabled = parentDisabled;
this._textToSearch = textToSearch;
this.visible = ko.computed(function () {
return _this._editors().some(function (editor) { return editor.visible(); });
});
this._targetSubscription = target.subscribe(function (newVal) {
_this._infoSubscription && _this._infoSubscription.dispose();
_this._getInfoComputed && _this._getInfoComputed.dispose();
_this._update(newVal, editorsInfo, recreateEditors);
});
this._update(target(), editorsInfo, recreateEditors);
}
ObjectProperties.prototype.update = function (viewModel) {
if (viewModel) {
this._editors().forEach(function (editor) {
editor.update(viewModel);
});
}
};
ObjectProperties.prototype._cleanEditorsSubscriptions = function () {
this._editors().forEach(function (editor) {
for (var name in editor) {
if (ko.isComputed(editor[name])) {
editor[name].dispose();
}
}
});
};
ObjectProperties.prototype.cleanSubscriptions = function () {
this._infoSubscription && this._infoSubscription.dispose();
this._getInfoComputed && this._getInfoComputed.dispose();
this._targetSubscription && this._targetSubscription.dispose();
this._cleanEditorsSubscriptions();
};
ObjectProperties.prototype.cleanEditors = function () {
this._cleanEditorsSubscriptions();
this._editors([]);
};
ObjectProperties.prototype.findEditorByInfo = function (serializationInfo) {
return this._editors().filter(function (editor) { return editor.name === serializationInfo.propertyName && Analytics.Utils.compareEditorInfo(editor.info().editor, serializationInfo.editor); })[0];
};
ObjectProperties.prototype.createEditor = function (modelPropertyInfo) {
var editorType = modelPropertyInfo.editor && modelPropertyInfo.editor.editorType || Widgets.Editor;
return new editorType(modelPropertyInfo, this.level, this._parentDisabled, this._textToSearch);
};
ObjectProperties.prototype.createEditors = function (serializationInfo) {
var _this = this;
var self = this;
return (serializationInfo || [])
.filter(function (info) { return !!info.editor && !_this.findEditorByInfo(info); })
.map(function (info) { return _this.createEditor(info); });
};
ObjectProperties.prototype._createEditors = function (serializationInfo) {
var _this = this;
if (!serializationInfo || serializationInfo.length === 0)
return false;
this.createEditors(serializationInfo).forEach(function (editor) { return _this._editors.push(editor); });
var propertyNames = serializationInfo.map(function (info) { return info.propertyName; });
this._editors.sort(function (a, b) {
return propertyNames.indexOf(a.name) - propertyNames.indexOf(b.name);
});
};
ObjectProperties.prototype._update = function (target, editorsInfo, recreateEditors) {
var _this = this;
if (recreateEditors)
this._editors([]);
var infoSubscription = null;
this._getInfoComputed = ko.computed(function () {
return (editorsInfo && editorsInfo.editors && ko.unwrap(editorsInfo.editors))
|| (target && target["getInfo"] && target["getInfo"]());
});
this._infoSubscription = this._getInfoComputed.subscribe(function (newInfo) {
if (recreateEditors)
_this._editors([]);
_this._createEditors(newInfo);
_this.update(target);
});
this._createEditors(this._getInfoComputed());
this.update(target);
};
ObjectProperties.prototype.getEditors = function () {
return this._editors();
};
return ObjectProperties;
})();
Widgets.ObjectProperties = ObjectProperties;
})(Widgets = Analytics.Widgets || (Analytics.Widgets = {}));
})(Analytics = DevExpress.Analytics || (DevExpress.Analytics = {}));
})(DevExpress || (DevExpress = {}));
var DevExpress;
(function (DevExpress) {
var Analytics;
(function (Analytics) {
var Internal;
(function (Internal) {
var CodeResolver = (function () {
function CodeResolver() {
this._queue = [];
this._done = [];
}
CodeResolver.prototype.done = function (callback) {
this._done.push(callback);
};
CodeResolver.prototype.execute = function (func, time) {
if (time === void 0) { time = 0; }
var deferred = $.Deferred();
if (time) {
var self = this;
this._queue.push(function () {
setTimeout(function () {
deferred.resolve(func());
self._queue.splice(0, 1);
if (self._queue.length !== 0) {
self._queue[0]();
}
else {
for (var i = 0; i < self._done.length; i++) {
self._done[i]();
}
}
}, time);
});
if (this._queue.length === 1) {
this._queue[0]();
}
}
else {
deferr