diff --git a/api/js/etemplate/et2_core_arrayMgr.js b/api/js/etemplate/et2_core_arrayMgr.js index bd030a4a7c..23b197b647 100644 --- a/api/js/etemplate/et2_core_arrayMgr.js +++ b/api/js/etemplate/et2_core_arrayMgr.js @@ -1,3 +1,4 @@ +"use strict"; /** * EGroupware eTemplate2 - JS content array manager * @@ -9,485 +10,414 @@ * @copyright Stylite 2011 * @version $Id$ */ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({__proto__: []} instanceof Array && function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); -/*egw:uses - et2_core_common; - egw_inheritance; - et2_core_phpExpressionCompiler; -*/ + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", {value: true}); /** - * @augments Class + * Manage access to various template customisation arrays passed to etemplate->exec(). + * + * This manages access to content, modifications and readonlys arrays */ -var et2_arrayMgr = (function(){ "use strict"; return Class.extend( -{ - splitIds: true, - - /** - * Constructor - * - * @memberOf et2_arrayMgr - * @param _data - * @param _parentMgr - */ - init: function(_data, _parentMgr) { - if (typeof _parentMgr == "undefined") - { - _parentMgr = null; - } - - // Copy the parent manager which is needed to access relative data when - // being in a relative perspective of the manager - this.parentMgr = _parentMgr; - - // Hold a reference to the data - if (typeof _data == "undefined" || !_data) - { - egw.debug("log", "No data passed to content array manager. Probably a mismatch between template namespaces and data."); - _data = {}; - } - - // Expand sub-arrays that have been shmushed together, so further perspectives work - // Shmushed keys look like: ${row}[info_cat] - // Expanded: ${row}: Object{info_cat: ..value} - if (this.splitIds) - { - // For each index, we need a key: {..} sub array - for(var key in _data) { - // Split up indexes - var indexes = key.replace(/[/g,"[").split('['); - - // Put data in the proper place - if(indexes.length > 1) - { - var value = _data[key]; - var target = _data; - for(var i = 0; i < indexes.length; i++) { - indexes[i] = indexes[i].replace(/]/g,'').replace(']',''); - if(typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) { - target[indexes[i]] = i == indexes.length-1 ? value : {}; - } - target = target[indexes[i]]; - } - delete _data[key]; - } - } - } - - this.data = _data; - - // Holds information about the current perspective - this.perspectiveData = { - "owner": null, - "key": null, - "row": null - }; - }, - - /** - * Returns the root content array manager object - */ - getRoot : function() { - if (this.parentMgr != null) - { - return this.parentMgr.getRoot(); - } - - return this; - }, - -/* getValueForID : function(_id) { - if (typeof this.data[_id] != "undefined") - { - return this.data[_id]; - } - - return null; - },*/ - - /** - * Explodes compound keys (eg IDs) into a list of namespaces - * This uses no internal values, just expands - * - * eg: - * a[b][c] => [a,b,c] - * col_filter[tr_tracker] => [col_filter, tr_tracker] - * - * @param {string} _key - * - * @return {string[]} - */ - explodeKey: function(_key) - { - // Parse the given key by removing the "]"-chars and splitting at "[" - var indexes = [_key]; - - if(typeof _key === "string") - { - _key = _key.replace(/[/g,"[").replace(/]/g,"]"); - indexes = _key.split('['); - } - if (indexes.length > 1) - { - indexes = [indexes.shift(), indexes.join('[')]; - indexes[1] = indexes[1].substring(0,indexes[1].length-1); - var children = indexes[1].split(']['); - if(children.length) - { - indexes = jQuery.merge([indexes[0]], children); - } - } - return indexes; - }, - - /** - * Returns the path to this content array manager perspective as an array - * containing the key values - * - * @param _path is used internally, do not supply it manually. - */ - getPath : function(_path) { - if (typeof _path == "undefined") - { - _path = []; - } - - if (this.perspectiveData.key != null) - { - // prepend components of this.perspectiveData.key to path, can be more then one eg. "nm[rows]" - _path = this.perspectiveData.key.replace(/]/g, '').split('[').concat(_path); - } - - if (this.parentMgr != null) - { - _path = this.parentMgr.getPath(_path); - } - - return _path; - }, - - /** - * Get array entry is the equivalent to the boetemplate get_array function. - * It returns a reference to the (sub) array with the given key. This also works - * for keys using the ETemplate referencing scheme like a[b][c] - * - * @param _key is the string index, may contain sub-indices like a[b] - * @param _referenceInto if true none-existing sub-arrays/-indices get created - * to be returned as reference, else false is returned. Defaults to false - * @param _skipEmpty returns null if _key is not present in this content array. - * Defaults to false. - */ - getEntry : function(_key, _referenceInto, _skipEmpty) { - if (typeof _referenceInto == "undefined") - { - _referenceInto = false; - } - - if (typeof _skipEmpty == "undefined") - { - _skipEmpty = false; - } - - // Parse the given key by removing the "]"-chars and splitting at "[" - var indexes = this.explodeKey(_key); - - var entry = this.data; - for (var i = 0; i < indexes.length; i++) - { - // Abort if the current entry is not an object (associative array) and - // we should descend further into it. - var isObject = typeof entry === 'object'; - if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) - { - return null; - } - - // Check whether the entry actually exists - var idx = indexes[i]; - if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) - { - return null; - } - - entry = entry[idx]; - } - - return entry; - }, - - compiledExpressions: {}, - - /** - * Equivaltent to the boetemplate::expand_name function. - * - * Expands variables inside the given identifier to their values inside the - * content array. - * - * @param {string} _ident Key used to reference into managed array - * @return {*} - */ - expandName : function(_ident) { - // Check whether the identifier refers to an index in the content array - var is_index_in_content = _ident.charAt(0) == '@'; - - // Check whether "$" occurs in the given identifier - var pos_var = _ident.indexOf('$'); - if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))) - { - // Get the content array for the current row - var row = this.perspectiveData.row; - var row_cont = this.data[row] || {}; - // $cont is NOT root but current name-space in old eTemplate - var cont = this.data;//getRoot().data; - var _cont = this.data;// according to a grep only used in ImportExport just twice - - // Check whether the expression has already been compiled - if not, - // try to compile it first. If an error occurs, the identifier - // function is set to null - var proto = this.constructor.prototype; - if (typeof proto.compiledExpressions[_ident] == "undefined") - { - try - { - if(this.perspectiveData.row == null) - { - // No row, compile for only top level content - proto.compiledExpressions[_ident] = et2_compilePHPExpression( - _ident, ["cont","_cont"]); - } - else - { - proto.compiledExpressions[_ident] = et2_compilePHPExpression( - _ident, ["row", "cont", "row_cont", "_cont"]); - } - } - catch(e) - { - proto.compiledExpressions[_ident] = null; - egw.debug("error", "Error while compiling PHP->JS ", e); - } - } - - // Execute the previously compiled expression, if it is not "null" - // because compilation failed. The parameters have to be in the same - // order as defined during compilation. - if (proto.compiledExpressions[_ident]) - { - try - { - if(this.perspectiveData.row == null) - { - // No row, exec with only top level content - _ident = proto.compiledExpressions[_ident](cont,_cont); - } - else - { - _ident = proto.compiledExpressions[_ident](row, cont, row_cont,_cont); - } - } - catch(e) - { - // only log error, as they are no real errors but missing data - egw.debug("log", typeof e == 'object' ? e.message : e); - _ident = null; - } - } - } - - if (is_index_in_content) - { - // If an additional "@" is specified, this means that we have to return - // the entry from the root element - if (_ident.charAt(1) == '@') - { - _ident = this.getRoot().getEntry(_ident.substr(2)); - } - else - { - _ident = this.getEntry(_ident.substr(1)); - } - } - - return _ident; - }, - - parseBoolExpression: function(_expression) { - // If the first char of the expression is a '!' this means, that the value - // is to be negated. - if (_expression.charAt(0) == '!') - { - return !this.parseBoolExpression(_expression.substr(1)); - } - - // Split the expression at a possible "=" - var parts = _expression.split('='); - - // Expand the first value - var val = this.expandName(parts[0]); - - // If a second expression existed, test that one - if (typeof parts[1] != "undefined") - { - // Expand the second value - var checkVal = this.expandName(parts[1]); - - // Values starting with / are treated as regular expression. It is - // checked whether the first value matches the regular expression - if (checkVal.charAt(0) == '/') - { - return (new RegExp(checkVal.substr(1, checkVal.length - 2))) - .test(val) ? true : false; - } - - // Otherwise check for simple equality - return val == checkVal; - } - - return et2_evalBool(val); - }, - - /** - * ? - * - * @param {object} _owner owner object - * @param {(string|null|object)} _root string with key, null for whole data or object with data - * @param {number?} _row key for into the _root for the desired row - */ - openPerspective: function(_owner, _root, _row) - { - // Get the root node - var root = typeof _root == "string" ? this.data[_root] : - (_root == null ? this.data : _root); - if(typeof root == "undefined" && typeof _root == "string") root = this.getEntry(_root); - - // Create a new content array manager with the given root - var constructor = this.isReadOnly ? et2_readonlysArrayMgr : et2_arrayMgr; - var mgr = new constructor(root, this); - - // Set the owner - mgr.perspectiveData.owner = _owner; - - // Set the root key - if (typeof _root == "string") - { - mgr.perspectiveData.key = _root; - } - - // Set _row parameter - if (typeof _row != "undefined") - { - mgr.perspectiveData.row = _row; - } - - return mgr; - } - -});}).call(this); +var et2_arrayMgr = /** @class */ (function () { + /** + * Constructor + * + * @memberOf et2_arrayMgr + * @param _data + * @param _parentMgr + */ + function et2_arrayMgr(_data, _parentMgr) { + if (_data === void 0) { + _data = {}; + } + this.splitIds = true; + // Holds information about the current perspective + this.perspectiveData = { + "owner": null, + "key": null, + "row": null + }; + this.readOnly = false; + if (typeof _parentMgr == "undefined") { + _parentMgr = null; + } + // Copy the parent manager which is needed to access relative data when + // being in a relative perspective of the manager + this._parentMgr = _parentMgr; + // Hold a reference to the data + if (typeof _data == "undefined" || !_data) { + egw.debug("log", "No data passed to content array manager. Probably a mismatch between template namespaces and data."); + _data = {}; + } + // Expand sub-arrays that have been shmushed together, so further perspectives work + // Shmushed keys look like: ${row}[info_cat] + // Expanded: ${row}: Object{info_cat: ..value} + if (this.splitIds) { + // For each index, we need a key: {..} sub array + for (var key in _data) { + // Split up indexes + var indexes = key.replace(/[/g, "[").split('['); + // Put data in the proper place + if (indexes.length > 1) { + var value = _data[key]; + var target = _data; + for (var i = 0; i < indexes.length; i++) { + indexes[i] = indexes[i].replace(/]/g, '').replace(']', ''); + if (typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) { + target[indexes[i]] = i == indexes.length - 1 ? value : {}; + } + target = target[indexes[i]]; + } + delete _data[key]; + } + } + } + this.data = _data; + } + /** + * Returns the root content array manager object + */ + et2_arrayMgr.prototype.getRoot = function () { + if (this._parentMgr != null) { + return this._parentMgr.getRoot(); + } + return this; + }; + et2_arrayMgr.prototype.getParentMgr = function () { + return this._parentMgr; + }; + et2_arrayMgr.prototype.getPerspectiveData = function () { + return this.perspectiveData; + }; + et2_arrayMgr.prototype.setPerspectiveData = function (new_perspective) { + this.perspectiveData = new_perspective; + }; + et2_arrayMgr.prototype.setRow = function (new_row) { + this.perspectiveData.row = new_row; + }; + /** + * Explodes compound keys (eg IDs) into a list of namespaces + * This uses no internal values, just expands + * + * eg: + * a[b][c] => [a,b,c] + * col_filter[tr_tracker] => [col_filter, tr_tracker] + * + * @param {string} _key + * + * @return {string[]} + */ + et2_arrayMgr.prototype.explodeKey = function (_key) { + // Parse the given key by removing the "]"-chars and splitting at "[" + var indexes = [_key]; + if (typeof _key === "string") { + _key = _key.replace(/[/g, "[").replace(/]/g, "]"); + indexes = _key.split('['); + } + if (indexes.length > 1) { + indexes = [indexes.shift(), indexes.join('[')]; + indexes[1] = indexes[1].substring(0, indexes[1].length - 1); + var children = indexes[1].split(']['); + if (children.length) { + indexes = jQuery.merge([indexes[0]], children); + } + } + return indexes; + }; + /** + * Returns the path to this content array manager perspective as an array + * containing the key values + * + * @param _path is used internally, do not supply it manually. + */ + et2_arrayMgr.prototype.getPath = function (_path) { + if (typeof _path == "undefined") { + _path = []; + } + if (this.perspectiveData.key != null) { + // prepend components of this.perspectiveData.key to path, can be more then one eg. "nm[rows]" + _path = this.perspectiveData.key.replace(/]/g, '').split('[').concat(_path); + } + if (this._parentMgr != null) { + _path = this._parentMgr.getPath(_path); + } + return _path; + }; + /** + * Get array entry is the equivalent to the boetemplate get_array function. + * It returns a reference to the (sub) array with the given key. This also works + * for keys using the ETemplate referencing scheme like a[b][c] + * + * @param _key is the string index, may contain sub-indices like a[b] + * @param _referenceInto if true none-existing sub-arrays/-indices get created + * to be returned as reference, else false is returned. Defaults to false + * @param _skipEmpty returns null if _key is not present in this content array. + * Defaults to false. + */ + et2_arrayMgr.prototype.getEntry = function (_key, _referenceInto, _skipEmpty) { + if (typeof _referenceInto == "undefined") { + _referenceInto = false; + } + if (typeof _skipEmpty == "undefined") { + _skipEmpty = false; + } + // Parse the given key by removing the "]"-chars and splitting at "[" + var indexes = this.explodeKey(_key); + var entry = this.data; + for (var i = 0; i < indexes.length; i++) { + // Abort if the current entry is not an object (associative array) and + // we should descend further into it. + var isObject = typeof entry === 'object'; + if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) { + return null; + } + // Check whether the entry actually exists + var idx = indexes[i]; + if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) { + return null; + } + entry = entry[idx]; + } + return entry; + }; + /** + * Equivalent to the boetemplate::expand_name function. + * + * Expands variables inside the given identifier to their values inside the + * content array. + * + * @param {string} _ident Key used to reference into managed array + * @return {*} + */ + et2_arrayMgr.prototype.expandName = function (_ident) { + // Check whether the identifier refers to an index in the content array + var is_index_in_content = _ident.charAt(0) == '@'; + // Check whether "$" occurs in the given identifier + var pos_var = _ident.indexOf('$'); + if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))) { + // Get the content array for the current row + var row = this.perspectiveData.row || ''; + var row_cont = this.data[row] || {}; + // $cont is NOT root but current name-space in old eTemplate + var cont = this.data; //getRoot().data; + var _cont = this.data; // according to a grep only used in ImportExport just twice + // Check whether the expression has already been compiled - if not, + // try to compile it first. If an error occurs, the identifier + // function is set to null + var proto = this.constructor.prototype; + if (typeof proto.compiledExpressions[_ident] == "undefined") { + try { + if (this.perspectiveData.row == null) { + // No row, compile for only top level content + // @ts-ignore + proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["cont", "_cont"]); + } else { + // @ts-ignore + proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["row", "cont", "row_cont", "_cont"]); + } + } catch (e) { + proto.compiledExpressions[_ident] = null; + egw.debug("error", "Error while compiling PHP->JS ", e); + } + } + // Execute the previously compiled expression, if it is not "null" + // because compilation failed. The parameters have to be in the same + // order as defined during compilation. + if (proto.compiledExpressions[_ident]) { + try { + if (this.perspectiveData.row == null) { + // No row, exec with only top level content + _ident = proto.compiledExpressions[_ident](cont, _cont); + } else { + _ident = proto.compiledExpressions[_ident](row, cont, row_cont, _cont); + } + } catch (e) { + // only log error, as they are no real errors but missing data + egw.debug("log", typeof e == 'object' ? e.message : e); + _ident = null; + } + } + } + if (is_index_in_content && _ident) { + // If an additional "@" is specified, this means that we have to return + // the entry from the root element + if (_ident.charAt(1) == '@') { + return this.getRoot().getEntry(_ident.substr(2)); + } else { + return this.getEntry(_ident.substr(1)); + } + } + return _ident; + }; + et2_arrayMgr.prototype.parseBoolExpression = function (_expression) { + // If the first char of the expression is a '!' this means, that the value + // is to be negated. + if (_expression.charAt(0) == '!') { + return !this.parseBoolExpression(_expression.substr(1)); + } + // Split the expression at a possible "=" + var parts = _expression.split('='); + // Expand the first value + var val = '' + this.expandName(parts[0]); + // If a second expression existed, test that one + if (typeof parts[1] != "undefined") { + // Expand the second value + var checkVal = '' + this.expandName(parts[1]); + // Values starting with / are treated as regular expression. It is + // checked whether the first value matches the regular expression + if (checkVal.charAt(0) == '/') { + return (new RegExp(checkVal.substr(1, checkVal.length - 2))) + .test(val); + } + // Otherwise check for simple equality + return val == checkVal; + } + return et2_evalBool(val); + }; + /** + * ? + * + * @param {object} _owner owner object + * @param {(string|null|object)} _root string with key, null for whole data or object with data + * @param {number?} _row key for into the _root for the desired row + */ + et2_arrayMgr.prototype.openPerspective = function (_owner, _root, _row) { + // Get the root node + var root = typeof _root == "string" ? this.data[_root] : + (_root == null ? this.data : _root); + if (typeof root == "undefined" && typeof _root == "string") + root = this.getEntry(_root); + // Create a new content array manager with the given root + var constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr; + var mgr = new constructor(root, this); + // Set the owner + mgr.perspectiveData.owner = _owner; + // Set the root key + if (typeof _root == "string") { + mgr.perspectiveData.key = _root; + } + // Set _row parameter + if (typeof _row != "undefined") { + mgr.perspectiveData.row = _row; + } + return mgr; + }; + return et2_arrayMgr; +}()); +exports.et2_arrayMgr = et2_arrayMgr; /** * @augments et2_arrayMgr */ -var et2_readonlysArrayMgr = (function(){ "use strict"; return et2_arrayMgr.extend( -{ +var et2_readonlysArrayMgr = /** @class */ (function (_super) { + __extends(et2_readonlysArrayMgr, _super); - /** - * @memberOf et2_readonlysArrayMgr - * @param _id - * @param _attr - * @param _parent - * @returns - */ - isReadOnly: function(_id, _attr, _parent) { - var entry = null; + function et2_readonlysArrayMgr() { + return _super !== null && _super.apply(this, arguments) || this; + } - if (_id != null) - { - if(_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0) - { - _id = this.expandName(_id); - } - // readonlys was not namespaced in old eTemplate, therefore if we dont find data - // under current namespace, we look into parent - // (if there is anything namespaced, we will NOT look for parent!) - var mgr = this; - while (mgr.parentMgr && jQuery.isEmptyObject(mgr.data)) - { - mgr = mgr.parentMgr; - } - entry = mgr.getEntry(_id); - } - - // Let the array entry override the read only attribute entry - if (typeof entry != "undefined" && !(typeof entry === 'object')) - { - return entry; - } - - // If the attribute is set, return that - if (typeof _attr != "undefined" && _attr !== null) - { - // Accept 'editable', but otherwise boolean - return this.expandName(_attr) === 'editable' ? 'editable' : et2_evalBool(_attr); - } - - // Otherwise take into accounf whether the parent is readonly - if (typeof _parent != "undefined" && _parent) - { - return true; - } - - // Otherwise return the default value - entry = this.getEntry("__ALL__"); - return entry !== null && (typeof entry != "undefined"); - }, - - /** - * Override parent to handle cont and row_cont. - * - * Normally these should refer to the readonlys data, but that's not - * useful, so we use the owner inside perspective data to expand using content. - * - * @param {string} ident Key for searching into the array. - * @returns {*} - */ - expandName: function(ident) - { - return this.perspectiveData.owner.getArrayMgr('content').expandName(ident); - } -});}).call(this); + /** + * Find out if the given ID is readonly, according to the array data + * + * @memberOf et2_readonlysArrayMgr + * @param _id + * @param _attr + * @param _parent + * @returns + */ + et2_readonlysArrayMgr.prototype.isReadOnly = function (_id, _attr, _parent) { + var entry = null; + if (_id != null) { + if (_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0) { + _id = this.expandName(_id); + } + // readonlys was not namespaced in old eTemplate, therefore if we dont find data + // under current namespace, we look into parent + // (if there is anything namespaced, we will NOT look for parent!) + var mgr = this; + while (mgr.getParentMgr() && jQuery.isEmptyObject(mgr.data)) { + mgr = mgr.getParentMgr(); + } + entry = mgr.getEntry(_id); + } + // Let the array entry override the read only attribute entry + if (typeof entry != "undefined" && !(typeof entry === 'object')) { + return entry; + } + // If the attribute is set, return that + if (typeof _attr != "undefined" && _attr !== null) { + // Accept 'editable', but otherwise boolean + return this.expandName(_attr) === 'editable' ? 'editable' : et2_evalBool(_attr); + } + // Otherwise take into accounf whether the parent is readonly + if (typeof _parent != "undefined" && _parent) { + return true; + } + // Otherwise return the default value + entry = this.getEntry("__ALL__"); + return entry !== null && (typeof entry != "undefined"); + }; + /** + * Override parent to handle cont and row_cont. + * + * Normally these should refer to the readonlys data, but that's not + * useful, so we use the owner inside perspective data to expand using content. + * + * @param {string} ident Key for searching into the array. + * @returns {*} + */ + et2_readonlysArrayMgr.prototype.expandName = function (ident) { + return this.perspectiveData.owner.getArrayMgr('content').expandName(ident); + }; + return et2_readonlysArrayMgr; +}(et2_arrayMgr)); +exports.et2_readonlysArrayMgr = et2_readonlysArrayMgr; /** * Creates a new set of array managers * * @param _owner is the owner object of the array managers - this object (a widget) - * will free the array manager + * will free the array manager * @param _mgrs is the original set of array managers, the array managers are - * inside an associative array as recived from et2_widget::getArrayMgrs() + * inside an associative array as recived from et2_widget::getArrayMgrs() * @param _data is an associative array of new data which will be merged into the - * existing array managers. + * existing array managers. * @param _row is the row for which the array managers will be opened. */ -function et2_arrayMgrs_expand(_owner, _mgrs, _data, _row) -{ - // Create a copy of the given _mgrs associative array - var result = {}; - - // Merge the given data associative array into the existing array managers - for (var key in _mgrs) - { - result[key] = _mgrs[key]; - - if (typeof _data[key] != "undefined") - { - // Open a perspective for the given data row - var rowData = {}; - rowData[_row] = _data[key]; - - result[key] = _mgrs[key].openPerspective(_owner, rowData, _row); - } - } - - // Return the resulting managers object - return result; +function et2_arrayMgrs_expand(_owner, _mgrs, _data, _row) { + // Create a copy of the given _mgrs associative array + var result = {}; + // Merge the given data associative array into the existing array managers + for (var key in _mgrs) { + result[key] = _mgrs[key]; + if (typeof _data[key] != "undefined") { + // Open a perspective for the given data row + var rowData = {}; + rowData[_row] = _data[key]; + result[key] = _mgrs[key].openPerspective(_owner, rowData, _row); + } + } + // Return the resulting managers object + return result; } +//# sourceMappingURL=et2_core_arrayMgr.js.map \ No newline at end of file diff --git a/api/js/etemplate/et2_core_arrayMgr.js.map b/api/js/etemplate/et2_core_arrayMgr.js.map new file mode 100644 index 0000000000..d1927fdb79 --- /dev/null +++ b/api/js/etemplate/et2_core_arrayMgr.js.map @@ -0,0 +1 @@ +{"version":3,"file":"et2_core_arrayMgr.js","sourceRoot":"","sources":["et2_core_arrayMgr.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;AAUH;;;;GAIG;AACH;IAcC;;;;;;OAMG;IACH,sBAAY,KAAiB,EAAE,UAAyB;QAA5C,sBAAA,EAAA,UAAiB;QAnB7B,aAAQ,GAAa,IAAI,CAAC;QAI1B,kDAAkD;QAC3C,oBAAe,GAAoD;YACzE,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;SACX,CAAC;QACM,aAAQ,GAAY,KAAK,CAAC;QAWjC,IAAI,OAAO,UAAU,IAAI,WAAW,EACpC;YACC,UAAU,GAAG,IAAI,CAAC;SAClB;QAED,uEAAuE;QACvE,iDAAiD;QACjD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,+BAA+B;QAC/B,IAAI,OAAO,KAAK,IAAI,WAAW,IAAI,CAAC,KAAK,EACzC;YACC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,qGAAqG,CAAC,CAAC;YACxH,KAAK,GAAG,EAAE,CAAC;SACX;QAED,mFAAmF;QACnF,4CAA4C;QAC5C,8CAA8C;QAC9C,IAAI,IAAI,CAAC,QAAQ,EACjB;YACC,gDAAgD;YAChD,KAAI,IAAI,GAAG,IAAI,KAAK,EAAE;gBACrB,mBAAmB;gBACnB,IAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG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AAY,GAsEtD;AAtEY,sDAAqB;AAwElC;;;;;;;;;;GAUG;AACH,SAAS,oBAAoB,CAAC,MAAmB,EAAE,KAAc,EAAE,KAAc,EAAE,IAAa;IAE/F,qDAAqD;IACrD,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,0EAA0E;IAC1E,KAAK,IAAI,GAAG,IAAI,KAAK,EACrB;QACC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzB,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,WAAW,EACpC;YACC,4CAA4C;YAC5C,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAE3B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;SAChE;KACD;IAED,uCAAuC;IACvC,OAAO,MAAM,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/api/js/etemplate/et2_core_arrayMgr.ts b/api/js/etemplate/et2_core_arrayMgr.ts new file mode 100644 index 0000000000..48618e8fa2 --- /dev/null +++ b/api/js/etemplate/et2_core_arrayMgr.ts @@ -0,0 +1,455 @@ +/** + * EGroupware eTemplate2 - JS content array manager + * + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @package etemplate + * @subpackage api + * @link http://www.egroupware.org + * @author Andreas Stöckel + * @copyright Stylite 2011 + * @version $Id$ + */ + +/*egw:uses + et2_core_common; + egw_inheritance; + et2_core_phpExpressionCompiler; +*/ + +import {et2_widget} from "./et2_core_widget"; + +/** + * Manage access to various template customisation arrays passed to etemplate->exec(). + * + * This manages access to content, modifications and readonlys arrays + */ +export class et2_arrayMgr { + splitIds: boolean = true; + public data: object; + // Holds information about the current perspective + public perspectiveData: { owner: et2_widget; row: number; key: string } = { + "owner": null, + "key": null, + "row": null + }; + compiledExpressions: {}; + private readonly _parentMgr: et2_arrayMgr; + private readOnly: boolean = false; + + /** + * Constructor + * + * @memberOf et2_arrayMgr + * @param _data + * @param _parentMgr + */ + constructor(_data: object = {}, _parentMgr?: et2_arrayMgr) { + if (typeof _parentMgr == "undefined") { + _parentMgr = null; + } + + // Copy the parent manager which is needed to access relative data when + // being in a relative perspective of the manager + this._parentMgr = _parentMgr; + + // Hold a reference to the data + if (typeof _data == "undefined" || !_data) { + egw.debug("log", "No data passed to content array manager. Probably a mismatch between template namespaces and data."); + _data = {}; + } + + // Expand sub-arrays that have been shmushed together, so further perspectives work + // Shmushed keys look like: ${row}[info_cat] + // Expanded: ${row}: Object{info_cat: ..value} + if (this.splitIds) { + // For each index, we need a key: {..} sub array + for (let key in _data) { + // Split up indexes + const indexes = key.replace(/[/g, "[").split('['); + + // Put data in the proper place + if (indexes.length > 1) { + const value = _data[key]; + let target = _data; + for (let i = 0; i < indexes.length; i++) { + indexes[i] = indexes[i].replace(/]/g, '').replace(']', ''); + if (typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) { + target[indexes[i]] = i == indexes.length - 1 ? value : {}; + } + target = target[indexes[i]]; + } + delete _data[key]; + } + } + } + + this.data = _data; + } + + /** + * Returns the root content array manager object + */ + getRoot(): et2_arrayMgr { + if (this._parentMgr != null) { + return this._parentMgr.getRoot(); + } + + return this; + } + + getParentMgr(): et2_arrayMgr { + return this._parentMgr; + } + + getPerspectiveData(): { owner: et2_widget; row: number; key: string } { + return this.perspectiveData; + } + + setPerspectiveData(new_perspective: { owner: et2_widget; row: number; key: string }) { + this.perspectiveData = new_perspective; + } + + setRow(new_row: number) { + this.perspectiveData.row = new_row; + } + + /** + * Explodes compound keys (eg IDs) into a list of namespaces + * This uses no internal values, just expands + * + * eg: + * a[b][c] => [a,b,c] + * col_filter[tr_tracker] => [col_filter, tr_tracker] + * + * @param {string} _key + * + * @return {string[]} + */ + explodeKey(_key: string): string[] { + // Parse the given key by removing the "]"-chars and splitting at "[" + let indexes = [_key]; + + if (typeof _key === "string") { + _key = _key.replace(/[/g, "[").replace(/]/g, "]"); + indexes = _key.split('['); + } + if (indexes.length > 1) { + indexes = [indexes.shift(), indexes.join('[')]; + indexes[1] = indexes[1].substring(0, indexes[1].length - 1); + const children = indexes[1].split(']['); + if (children.length) { + indexes = jQuery.merge([indexes[0]], children); + } + } + return indexes; + } + + /** + * Returns the path to this content array manager perspective as an array + * containing the key values + * + * @param _path is used internally, do not supply it manually. + */ + getPath(_path?: string[]): string[] { + if (typeof _path == "undefined") { + _path = []; + } + + if (this.perspectiveData.key != null) { + // prepend components of this.perspectiveData.key to path, can be more then one eg. "nm[rows]" + _path = this.perspectiveData.key.replace(/]/g, '').split('[').concat(_path); + } + + if (this._parentMgr != null) { + _path = this._parentMgr.getPath(_path); + } + + return _path; + } + + /** + * Get array entry is the equivalent to the boetemplate get_array function. + * It returns a reference to the (sub) array with the given key. This also works + * for keys using the ETemplate referencing scheme like a[b][c] + * + * @param _key is the string index, may contain sub-indices like a[b] + * @param _referenceInto if true none-existing sub-arrays/-indices get created + * to be returned as reference, else false is returned. Defaults to false + * @param _skipEmpty returns null if _key is not present in this content array. + * Defaults to false. + */ + getEntry(_key: string, _referenceInto?: boolean, _skipEmpty?: boolean): string | object { + if (typeof _referenceInto == "undefined") { + _referenceInto = false; + } + + if (typeof _skipEmpty == "undefined") { + _skipEmpty = false; + } + + // Parse the given key by removing the "]"-chars and splitting at "[" + const indexes = this.explodeKey(_key); + + let entry = this.data; + for (let i = 0; i < indexes.length; i++) { + // Abort if the current entry is not an object (associative array) and + // we should descend further into it. + const isObject = typeof entry === 'object'; + if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) { + return null; + } + + // Check whether the entry actually exists + const idx = indexes[i]; + if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) { + return null; + } + + entry = entry[idx]; + } + + return entry; + } + + /** + * Equivalent to the boetemplate::expand_name function. + * + * Expands variables inside the given identifier to their values inside the + * content array. + * + * @param {string} _ident Key used to reference into managed array + * @return {*} + */ + expandName(_ident: string): string | object { + // Check whether the identifier refers to an index in the content array + const is_index_in_content = _ident.charAt(0) == '@'; + + // Check whether "$" occurs in the given identifier + const pos_var = _ident.indexOf('$'); + if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))) { + // Get the content array for the current row + const row = this.perspectiveData.row || ''; + const row_cont = this.data[row] || {}; + // $cont is NOT root but current name-space in old eTemplate + const cont = this.data;//getRoot().data; + const _cont = this.data;// according to a grep only used in ImportExport just twice + + // Check whether the expression has already been compiled - if not, + // try to compile it first. If an error occurs, the identifier + // function is set to null + const proto = this.constructor.prototype; + if (typeof proto.compiledExpressions[_ident] == "undefined") { + try { + if (this.perspectiveData.row == null) { + // No row, compile for only top level content + // @ts-ignore + proto.compiledExpressions[_ident] = et2_compilePHPExpression( + _ident, ["cont", "_cont"]); + } else { + // @ts-ignore + proto.compiledExpressions[_ident] = et2_compilePHPExpression( + _ident, ["row", "cont", "row_cont", "_cont"]); + } + } catch (e) { + proto.compiledExpressions[_ident] = null; + egw.debug("error", "Error while compiling PHP->JS ", e); + } + } + + // Execute the previously compiled expression, if it is not "null" + // because compilation failed. The parameters have to be in the same + // order as defined during compilation. + if (proto.compiledExpressions[_ident]) { + try { + if (this.perspectiveData.row == null) { + // No row, exec with only top level content + _ident = proto.compiledExpressions[_ident](cont, _cont); + } else { + _ident = proto.compiledExpressions[_ident](row, cont, row_cont, _cont); + } + } catch (e) { + // only log error, as they are no real errors but missing data + egw.debug("log", typeof e == 'object' ? e.message : e); + _ident = null; + } + } + } + + if (is_index_in_content && _ident) { + // If an additional "@" is specified, this means that we have to return + // the entry from the root element + if (_ident.charAt(1) == '@') { + return this.getRoot().getEntry(_ident.substr(2)); + } else { + return this.getEntry(_ident.substr(1)); + } + } + + return _ident; + } + + parseBoolExpression(_expression: string) { + // If the first char of the expression is a '!' this means, that the value + // is to be negated. + if (_expression.charAt(0) == '!') { + return !this.parseBoolExpression(_expression.substr(1)); + } + + // Split the expression at a possible "=" + const parts = _expression.split('='); + + // Expand the first value + const val = '' + this.expandName(parts[0]); + + // If a second expression existed, test that one + if (typeof parts[1] != "undefined") { + // Expand the second value + const checkVal = '' + this.expandName(parts[1]); + + // Values starting with / are treated as regular expression. It is + // checked whether the first value matches the regular expression + if (checkVal.charAt(0) == '/') { + return (new RegExp(checkVal.substr(1, checkVal.length - 2))) + .test(val); + } + + // Otherwise check for simple equality + return val == checkVal; + } + + return et2_evalBool(val); + } + + /** + * ? + * + * @param {object} _owner owner object + * @param {(string|null|object)} _root string with key, null for whole data or object with data + * @param {number?} _row key for into the _root for the desired row + */ + openPerspective(_owner: et2_widget, _root: (string | null | object), _row: number | null): et2_arrayMgr { + // Get the root node + let root = typeof _root == "string" ? this.data[_root] : + (_root == null ? this.data : _root); + if (typeof root == "undefined" && typeof _root == "string") root = this.getEntry(_root); + + // Create a new content array manager with the given root + const constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr; + const mgr = new constructor(root, this); + + // Set the owner + mgr.perspectiveData.owner = _owner; + + // Set the root key + if (typeof _root == "string") { + mgr.perspectiveData.key = _root; + } + + // Set _row parameter + if (typeof _row != "undefined") { + mgr.perspectiveData.row = _row; + } + + return mgr; + } + +} + +/** + * @augments et2_arrayMgr + */ +export class et2_readonlysArrayMgr extends et2_arrayMgr { + + /** + * Find out if the given ID is readonly, according to the array data + * + * @memberOf et2_readonlysArrayMgr + * @param _id + * @param _attr + * @param _parent + * @returns + */ + isReadOnly(_id: string, _attr: string, _parent?: et2_arrayMgr): boolean | string { + let entry = null; + + if (_id != null) { + if (_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0) { + _id = this.expandName(_id); + } + // readonlys was not namespaced in old eTemplate, therefore if we dont find data + // under current namespace, we look into parent + // (if there is anything namespaced, we will NOT look for parent!) + let mgr: et2_arrayMgr = this; + while (mgr.getParentMgr() && jQuery.isEmptyObject(mgr.data)) { + mgr = mgr.getParentMgr(); + } + entry = mgr.getEntry(_id); + } + + // Let the array entry override the read only attribute entry + if (typeof entry != "undefined" && !(typeof entry === 'object')) { + return entry; + } + + // If the attribute is set, return that + if (typeof _attr != "undefined" && _attr !== null) { + // Accept 'editable', but otherwise boolean + return this.expandName(_attr) === 'editable' ? 'editable' : et2_evalBool(_attr); + } + + // Otherwise take into accounf whether the parent is readonly + if (typeof _parent != "undefined" && _parent) { + return true; + } + + // Otherwise return the default value + entry = this.getEntry("__ALL__"); + return entry !== null && (typeof entry != "undefined"); + } + + /** + * Override parent to handle cont and row_cont. + * + * Normally these should refer to the readonlys data, but that's not + * useful, so we use the owner inside perspective data to expand using content. + * + * @param {string} ident Key for searching into the array. + * @returns {*} + */ + expandName(ident: string): any { + return this.perspectiveData.owner.getArrayMgr('content').expandName(ident); + } +} + +/** + * Creates a new set of array managers + * + * @param _owner is the owner object of the array managers - this object (a widget) + * will free the array manager + * @param _mgrs is the original set of array managers, the array managers are + * inside an associative array as recived from et2_widget::getArrayMgrs() + * @param _data is an associative array of new data which will be merged into the + * existing array managers. + * @param _row is the row for which the array managers will be opened. + */ +function et2_arrayMgrs_expand(_owner: et2_widget, _mgrs: object, _data: object, _row: number) { + // Create a copy of the given _mgrs associative array + let result = {}; + + // Merge the given data associative array into the existing array managers + for (let key in _mgrs) { + result[key] = _mgrs[key]; + + if (typeof _data[key] != "undefined") { + // Open a perspective for the given data row + let rowData = {}; + rowData[_row] = _data[key]; + + result[key] = _mgrs[key].openPerspective(_owner, rowData, _row); + } + } + + // Return the resulting managers object + return result; +} + diff --git a/api/js/etemplate/et2_widget_box.js b/api/js/etemplate/et2_widget_box.js index 48f43af9b2..bc1d6be2c5 100644 --- a/api/js/etemplate/et2_widget_box.js +++ b/api/js/etemplate/et2_widget_box.js @@ -98,14 +98,14 @@ var et2_box = /** @class */ (function (_super) { var mgrs = this.getArrayMgrs(); for (var name in mgrs) { if (this.getArrayMgr(name).getEntry(childIndex)) { - this.getArrayMgr(name).perspectiveData.row = childIndex; + this.getArrayMgr(name).setRow(childIndex); } } this.createElementFromNode(repeatNode); } // Reset for (var name in this.getArrayMgrs()) { - this.getArrayMgr(name).perspectiveData = currentPerspective; + this.getArrayMgr(name).setPerspectiveData(currentPerspective); } } }; diff --git a/api/js/etemplate/et2_widget_box.js.map b/api/js/etemplate/et2_widget_box.js.map index 89fb32e18f..8535aff63e 100644 --- a/api/js/etemplate/et2_widget_box.js.map +++ b/api/js/etemplate/et2_widget_box.js.map @@ -1 +1 @@ -{"version":3,"file":"et2_widget_box.js","sourceRoot":"","sources":["et2_widget_box.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;AAEH;;;EAGE;AAGF,qDAAoE;AACpE,6DAAqD;AAErD;;;;;;;GAOG;AACH;IAA6B,2BAAc;IAW1C;;;;OAIG;IACH,iBAAY,OAAO,EAAE,MAAsB,EAAE,MAAgB;QAA7D,YAEC,kBAAM,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,SAO9B;QAjBD,qBAAe,GAAY,IAAI,CAAC;QAY/B,KAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC9C,QAAQ,CAAC,MAAM,GAAG,KAAI,CAAC,OAAO,EAAE,CAAC;aACjC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAE7B,KAAI,CAAC,UAAU,CAAC,KAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;IAC9B,CAAC;IAED;;;;;OAKG;IACH,6BAAW,GAAX,UAAY,KAAK;QAChB,IAAG,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,EAC1B;YACC,OAAO,iBAAM,WAAW,YAAC,KAAK,CAAC,CAAC;SAChC;QACD,wBAAwB;QACxB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,KAAK,IAAI,CAAC,GAAC,CAAC,EAA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E,UAAU,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,kBAAkB;QAClB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EACtB;YACC,IAAI,CAAC,KAAK;iBACP,KAAK,CAAE,cAAW,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC;iBACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC5B;QAED,iCAAiC;QACjC,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,KAAK,MAAM;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAC,KAAK,EAAC,MAAM,EAAC,CAAC,CAAC;IACzE,CAAC;IAED,gCAAU,GAAV,UAAW,OAAO;QAEjB,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,IAAI,EAChC;YACC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnB;aAED;YACC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACvB;IACF,CAAC;IAhFe,uBAAW,GAAQ;QAClC,cAAc,EAAE;YACf,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EAAC,uEAAuE;YACnF,IAAI,EAAC,QAAQ;YACb,OAAO,EAAE,OAAO;SAChB;QACD,KAAK,EAAE;YACN,IAAI,EAAE,OAAO;YACb,WAAW,EAAC,oFAAoF;YAChG,IAAI,EAAC,QAAQ;YACb,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SACf;KACD,CAAC;IAmEH,kBAAC;CAAA,AAnFD,CAAiC,OAAO,GAmFvC;AAnFY,kCAAW;AAoFxB,qCAAmB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"et2_widget_box.js","sourceRoot":"","sources":["et2_widget_box.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;A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AAM,EAAC,CAAC,CAAC;IACzE,CAAC;IAED,gCAAU,GAAV,UAAW,OAAO;QAEjB,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,IAAI,EAChC;YACC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnB;aAED;YACC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACvB;IACF,CAAC;IAhFe,uBAAW,GAAQ;QAClC,cAAc,EAAE;YACf,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EAAC,uEAAuE;YACnF,IAAI,EAAC,QAAQ;YACb,OAAO,EAAE,OAAO;SAChB;QACD,KAAK,EAAE;YACN,IAAI,EAAE,OAAO;YACb,WAAW,EAAC,oFAAoF;YAChG,IAAI,EAAC,QAAQ;YACb,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SACf;KACD,CAAC;IAmEH,kBAAC;CAAA,AAnFD,CAAiC,OAAO,GAmFvC;AAnFY,kCAAW;AAoFxB,qCAAmB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/api/js/etemplate/et2_widget_box.ts b/api/js/etemplate/et2_widget_box.ts index df79061fab..13b80f62d2 100644 --- a/api/js/etemplate/et2_widget_box.ts +++ b/api/js/etemplate/et2_widget_box.ts @@ -112,7 +112,7 @@ export class et2_box extends et2_baseWidget implements et2_IDetachedDOM { if(this.getArrayMgr(name).getEntry(childIndex)) { - this.getArrayMgr(name).perspectiveData.row = childIndex; + this.getArrayMgr(name).setRow(childIndex); } } @@ -120,9 +120,8 @@ export class et2_box extends et2_baseWidget implements et2_IDetachedDOM } // Reset - for(var name in this.getArrayMgrs()) - { - this.getArrayMgr(name).perspectiveData = currentPerspective; + for(var name in this.getArrayMgrs()) { + this.getArrayMgr(name).setPerspectiveData(currentPerspective); } } } @@ -184,25 +183,24 @@ export class et2_details extends et2_box }, title: { name: "title", - description:"Set a header title for box and shows it next to toggle button, default is no title", - type:"string", + description: "Set a header title for box and shows it next to toggle button, default is no title", + type: "string", default: "", translate: true } }; - private title : JQuery; - private span : JQuery; - private wrapper : JQuery; + private title: JQuery; + private span: JQuery; + private readonly wrapper: JQuery; - constructor(_parent, _attrs? : WidgetConfig, _child? : object) - { + constructor(_parent, _attrs?: WidgetConfig, _child?: object) { super(_parent, _attrs, _child); this.div = jQuery(document.createElement('div')).addClass('et2_details'); this.title = jQuery(document.createElement('span')) - .addClass('et2_label et2_details_title') - .appendTo(this.div); + .addClass('et2_label et2_details_title') + .appendTo(this.div); this.span = jQuery(document.createElement('span')) .addClass('et2_details_toggle') .appendTo(this.div); @@ -225,19 +223,19 @@ export class et2_details extends et2_box /** * Create widget, set contents, and binds handlers */ - _createWidget() - { - var self = this; + _createWidget() { + const self = this; - this.span.on('click', function (e){ + this.span.on('click', function (e) { self._toggle(); }); //Set header title - if (this.options.title) - { + if (this.options.title) { this.title - .click (function(){self._toggle();}) + .click(function () { + self._toggle(); + }) .text(this.options.title); }