arrayMgr to TypeScript

This commit is contained in:
nathangray 2020-01-22 03:40:55 -07:00
parent 3cd1bd134b
commit e0c32a1899
6 changed files with 868 additions and 484 deletions

View File

@ -1,3 +1,4 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS content array manager * EGroupware eTemplate2 - JS content array manager
* *
@ -9,20 +10,34 @@
* @copyright Stylite 2011 * @copyright Stylite 2011
* @version $Id$ * @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 function __() {
et2_core_common; this.constructor = d;
egw_inheritance; }
et2_core_phpExpressionCompiler;
*/
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( var et2_arrayMgr = /** @class */ (function () {
{
splitIds: true,
/** /**
* Constructor * Constructor
* *
@ -30,42 +45,45 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
* @param _data * @param _data
* @param _parentMgr * @param _parentMgr
*/ */
init: function(_data, _parentMgr) { function et2_arrayMgr(_data, _parentMgr) {
if (typeof _parentMgr == "undefined") 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; _parentMgr = null;
} }
// Copy the parent manager which is needed to access relative data when // Copy the parent manager which is needed to access relative data when
// being in a relative perspective of the manager // being in a relative perspective of the manager
this.parentMgr = _parentMgr; this._parentMgr = _parentMgr;
// Hold a reference to the data // Hold a reference to the data
if (typeof _data == "undefined" || !_data) if (typeof _data == "undefined" || !_data) {
{
egw.debug("log", "No data passed to content array manager. Probably a mismatch between template namespaces and data."); egw.debug("log", "No data passed to content array manager. Probably a mismatch between template namespaces and data.");
_data = {}; _data = {};
} }
// Expand sub-arrays that have been shmushed together, so further perspectives work // Expand sub-arrays that have been shmushed together, so further perspectives work
// Shmushed keys look like: ${row}[info_cat] // Shmushed keys look like: ${row}[info_cat]
// Expanded: ${row}: Object{info_cat: ..value} // Expanded: ${row}: Object{info_cat: ..value}
if (this.splitIds) if (this.splitIds) {
{
// For each index, we need a key: {..} sub array // For each index, we need a key: {..} sub array
for(var key in _data) { for (var key in _data) {
// Split up indexes // Split up indexes
var indexes = key.replace(/[/g,"[").split('['); var indexes = key.replace(/[/g, "[").split('[');
// Put data in the proper place // Put data in the proper place
if(indexes.length > 1) if (indexes.length > 1) {
{
var value = _data[key]; var value = _data[key];
var target = _data; var target = _data;
for(var i = 0; i < indexes.length; i++) { for (var i = 0; i < indexes.length; i++) {
indexes[i] = indexes[i].replace(/&#x5D;/g,'').replace(']',''); indexes[i] = indexes[i].replace(/&#x5D;/g, '').replace(']', '');
if(typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) { if (typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) {
target[indexes[i]] = i == indexes.length-1 ? value : {}; target[indexes[i]] = i == indexes.length - 1 ? value : {};
} }
target = target[indexes[i]]; target = target[indexes[i]];
} }
@ -73,38 +91,30 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
} }
} }
} }
this.data = _data; this.data = _data;
}
// Holds information about the current perspective
this.perspectiveData = {
"owner": null,
"key": null,
"row": null
};
},
/** /**
* Returns the root content array manager object * Returns the root content array manager object
*/ */
getRoot : function() { et2_arrayMgr.prototype.getRoot = function () {
if (this.parentMgr != null) if (this._parentMgr != null) {
{ return this._parentMgr.getRoot();
return this.parentMgr.getRoot();
} }
return this; return this;
}, };
et2_arrayMgr.prototype.getParentMgr = function () {
/* getValueForID : function(_id) { return this._parentMgr;
if (typeof this.data[_id] != "undefined") };
{ et2_arrayMgr.prototype.getPerspectiveData = function () {
return this.data[_id]; return this.perspectiveData;
} };
et2_arrayMgr.prototype.setPerspectiveData = function (new_perspective) {
return null; 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 * Explodes compound keys (eg IDs) into a list of namespaces
* This uses no internal values, just expands * This uses no internal values, just expands
@ -117,55 +127,42 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
* *
* @return {string[]} * @return {string[]}
*/ */
explodeKey: function(_key) et2_arrayMgr.prototype.explodeKey = function (_key) {
{
// Parse the given key by removing the "]"-chars and splitting at "[" // Parse the given key by removing the "]"-chars and splitting at "["
var indexes = [_key]; var indexes = [_key];
if (typeof _key === "string") {
if(typeof _key === "string") _key = _key.replace(/&#x5B;/g, "[").replace(/&#x5D;/g, "]");
{
_key = _key.replace(/&#x5B;/g,"[").replace(/&#x5D;/g,"]");
indexes = _key.split('['); indexes = _key.split('[');
} }
if (indexes.length > 1) if (indexes.length > 1) {
{
indexes = [indexes.shift(), indexes.join('[')]; indexes = [indexes.shift(), indexes.join('[')];
indexes[1] = indexes[1].substring(0,indexes[1].length-1); indexes[1] = indexes[1].substring(0, indexes[1].length - 1);
var children = indexes[1].split(']['); var children = indexes[1].split('][');
if(children.length) if (children.length) {
{
indexes = jQuery.merge([indexes[0]], children); indexes = jQuery.merge([indexes[0]], children);
} }
} }
return indexes; return indexes;
}, };
/** /**
* Returns the path to this content array manager perspective as an array * Returns the path to this content array manager perspective as an array
* containing the key values * containing the key values
* *
* @param _path is used internally, do not supply it manually. * @param _path is used internally, do not supply it manually.
*/ */
getPath : function(_path) { et2_arrayMgr.prototype.getPath = function (_path) {
if (typeof _path == "undefined") if (typeof _path == "undefined") {
{
_path = []; _path = [];
} }
if (this.perspectiveData.key != null) {
if (this.perspectiveData.key != null)
{
// prepend components of this.perspectiveData.key to path, can be more then one eg. "nm[rows]" // 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); _path = this.perspectiveData.key.replace(/]/g, '').split('[').concat(_path);
} }
if (this._parentMgr != null) {
if (this.parentMgr != null) _path = this._parentMgr.getPath(_path);
{
_path = this.parentMgr.getPath(_path);
} }
return _path; return _path;
}, };
/** /**
* Get array entry is the equivalent to the boetemplate get_array function. * 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 * It returns a reference to the (sub) array with the given key. This also works
@ -177,48 +174,34 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
* @param _skipEmpty returns null if _key is not present in this content array. * @param _skipEmpty returns null if _key is not present in this content array.
* Defaults to false. * Defaults to false.
*/ */
getEntry : function(_key, _referenceInto, _skipEmpty) { et2_arrayMgr.prototype.getEntry = function (_key, _referenceInto, _skipEmpty) {
if (typeof _referenceInto == "undefined") if (typeof _referenceInto == "undefined") {
{
_referenceInto = false; _referenceInto = false;
} }
if (typeof _skipEmpty == "undefined") {
if (typeof _skipEmpty == "undefined")
{
_skipEmpty = false; _skipEmpty = false;
} }
// Parse the given key by removing the "]"-chars and splitting at "[" // Parse the given key by removing the "]"-chars and splitting at "["
var indexes = this.explodeKey(_key); var indexes = this.explodeKey(_key);
var entry = this.data; var entry = this.data;
for (var i = 0; i < indexes.length; i++) for (var i = 0; i < indexes.length; i++) {
{
// Abort if the current entry is not an object (associative array) and // Abort if the current entry is not an object (associative array) and
// we should descend further into it. // we should descend further into it.
var isObject = typeof entry === 'object'; var isObject = typeof entry === 'object';
if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) {
{
return null; return null;
} }
// Check whether the entry actually exists // Check whether the entry actually exists
var idx = indexes[i]; var idx = indexes[i];
if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) {
{
return null; return null;
} }
entry = entry[idx]; entry = entry[idx];
} }
return entry; return entry;
}, };
compiledExpressions: {},
/** /**
* Equivaltent to the boetemplate::expand_name function. * Equivalent to the boetemplate::expand_name function.
* *
* Expands variables inside the given identifier to their values inside the * Expands variables inside the given identifier to their values inside the
* content array. * content array.
@ -226,126 +209,91 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
* @param {string} _ident Key used to reference into managed array * @param {string} _ident Key used to reference into managed array
* @return {*} * @return {*}
*/ */
expandName : function(_ident) { et2_arrayMgr.prototype.expandName = function (_ident) {
// Check whether the identifier refers to an index in the content array // Check whether the identifier refers to an index in the content array
var is_index_in_content = _ident.charAt(0) == '@'; var is_index_in_content = _ident.charAt(0) == '@';
// Check whether "$" occurs in the given identifier // Check whether "$" occurs in the given identifier
var pos_var = _ident.indexOf('$'); var pos_var = _ident.indexOf('$');
if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))) if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))) {
{
// Get the content array for the current row // Get the content array for the current row
var row = this.perspectiveData.row; var row = this.perspectiveData.row || '';
var row_cont = this.data[row] || {}; var row_cont = this.data[row] || {};
// $cont is NOT root but current name-space in old eTemplate // $cont is NOT root but current name-space in old eTemplate
var cont = this.data;//getRoot().data; var cont = this.data; //getRoot().data;
var _cont = this.data;// according to a grep only used in ImportExport just twice var _cont = this.data; // according to a grep only used in ImportExport just twice
// Check whether the expression has already been compiled - if not, // Check whether the expression has already been compiled - if not,
// try to compile it first. If an error occurs, the identifier // try to compile it first. If an error occurs, the identifier
// function is set to null // function is set to null
var proto = this.constructor.prototype; var proto = this.constructor.prototype;
if (typeof proto.compiledExpressions[_ident] == "undefined") if (typeof proto.compiledExpressions[_ident] == "undefined") {
{ try {
try if (this.perspectiveData.row == null) {
{
if(this.perspectiveData.row == null)
{
// No row, compile for only top level content // No row, compile for only top level content
proto.compiledExpressions[_ident] = et2_compilePHPExpression( // @ts-ignore
_ident, ["cont","_cont"]); proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["cont", "_cont"]);
} else {
// @ts-ignore
proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["row", "cont", "row_cont", "_cont"]);
} }
else } catch (e) {
{
proto.compiledExpressions[_ident] = et2_compilePHPExpression(
_ident, ["row", "cont", "row_cont", "_cont"]);
}
}
catch(e)
{
proto.compiledExpressions[_ident] = null; proto.compiledExpressions[_ident] = null;
egw.debug("error", "Error while compiling PHP->JS ", e); egw.debug("error", "Error while compiling PHP->JS ", e);
} }
} }
// Execute the previously compiled expression, if it is not "null" // Execute the previously compiled expression, if it is not "null"
// because compilation failed. The parameters have to be in the same // because compilation failed. The parameters have to be in the same
// order as defined during compilation. // order as defined during compilation.
if (proto.compiledExpressions[_ident]) if (proto.compiledExpressions[_ident]) {
{ try {
try if (this.perspectiveData.row == null) {
{
if(this.perspectiveData.row == null)
{
// No row, exec with only top level content // No row, exec with only top level content
_ident = proto.compiledExpressions[_ident](cont,_cont); _ident = proto.compiledExpressions[_ident](cont, _cont);
} else {
_ident = proto.compiledExpressions[_ident](row, cont, row_cont, _cont);
} }
else } catch (e) {
{
_ident = proto.compiledExpressions[_ident](row, cont, row_cont,_cont);
}
}
catch(e)
{
// only log error, as they are no real errors but missing data // only log error, as they are no real errors but missing data
egw.debug("log", typeof e == 'object' ? e.message : e); egw.debug("log", typeof e == 'object' ? e.message : e);
_ident = null; _ident = null;
} }
} }
} }
if (is_index_in_content && _ident) {
if (is_index_in_content)
{
// If an additional "@" is specified, this means that we have to return // If an additional "@" is specified, this means that we have to return
// the entry from the root element // the entry from the root element
if (_ident.charAt(1) == '@') if (_ident.charAt(1) == '@') {
{ return this.getRoot().getEntry(_ident.substr(2));
_ident = this.getRoot().getEntry(_ident.substr(2)); } else {
} return this.getEntry(_ident.substr(1));
else
{
_ident = this.getEntry(_ident.substr(1));
} }
} }
return _ident; return _ident;
}, };
et2_arrayMgr.prototype.parseBoolExpression = function (_expression) {
parseBoolExpression: function(_expression) {
// If the first char of the expression is a '!' this means, that the value // If the first char of the expression is a '!' this means, that the value
// is to be negated. // is to be negated.
if (_expression.charAt(0) == '!') if (_expression.charAt(0) == '!') {
{
return !this.parseBoolExpression(_expression.substr(1)); return !this.parseBoolExpression(_expression.substr(1));
} }
// Split the expression at a possible "=" // Split the expression at a possible "="
var parts = _expression.split('='); var parts = _expression.split('=');
// Expand the first value // Expand the first value
var val = this.expandName(parts[0]); var val = '' + this.expandName(parts[0]);
// If a second expression existed, test that one // If a second expression existed, test that one
if (typeof parts[1] != "undefined") if (typeof parts[1] != "undefined") {
{
// Expand the second value // Expand the second value
var checkVal = this.expandName(parts[1]); var checkVal = '' + this.expandName(parts[1]);
// Values starting with / are treated as regular expression. It is // Values starting with / are treated as regular expression. It is
// checked whether the first value matches the regular expression // checked whether the first value matches the regular expression
if (checkVal.charAt(0) == '/') if (checkVal.charAt(0) == '/') {
{
return (new RegExp(checkVal.substr(1, checkVal.length - 2))) return (new RegExp(checkVal.substr(1, checkVal.length - 2)))
.test(val) ? true : false; .test(val);
} }
// Otherwise check for simple equality // Otherwise check for simple equality
return val == checkVal; return val == checkVal;
} }
return et2_evalBool(val); return et2_evalBool(val);
}, };
/** /**
* ? * ?
* *
@ -353,94 +301,81 @@ var et2_arrayMgr = (function(){ "use strict"; return Class.extend(
* @param {(string|null|object)} _root string with key, null for whole data or object with data * @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 * @param {number?} _row key for into the _root for the desired row
*/ */
openPerspective: function(_owner, _root, _row) et2_arrayMgr.prototype.openPerspective = function (_owner, _root, _row) {
{
// Get the root node // Get the root node
var root = typeof _root == "string" ? this.data[_root] : var root = typeof _root == "string" ? this.data[_root] :
(_root == null ? this.data : _root); (_root == null ? this.data : _root);
if(typeof root == "undefined" && typeof _root == "string") root = this.getEntry(_root); if (typeof root == "undefined" && typeof _root == "string")
root = this.getEntry(_root);
// Create a new content array manager with the given root // Create a new content array manager with the given root
var constructor = this.isReadOnly ? et2_readonlysArrayMgr : et2_arrayMgr; var constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr;
var mgr = new constructor(root, this); var mgr = new constructor(root, this);
// Set the owner // Set the owner
mgr.perspectiveData.owner = _owner; mgr.perspectiveData.owner = _owner;
// Set the root key // Set the root key
if (typeof _root == "string") if (typeof _root == "string") {
{
mgr.perspectiveData.key = _root; mgr.perspectiveData.key = _root;
} }
// Set _row parameter // Set _row parameter
if (typeof _row != "undefined") if (typeof _row != "undefined") {
{
mgr.perspectiveData.row = _row; mgr.perspectiveData.row = _row;
} }
return mgr; return mgr;
} };
return et2_arrayMgr;
});}).call(this); }());
exports.et2_arrayMgr = et2_arrayMgr;
/** /**
* @augments 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);
function et2_readonlysArrayMgr() {
return _super !== null && _super.apply(this, arguments) || this;
}
/** /**
* Find out if the given ID is readonly, according to the array data
*
* @memberOf et2_readonlysArrayMgr * @memberOf et2_readonlysArrayMgr
* @param _id * @param _id
* @param _attr * @param _attr
* @param _parent * @param _parent
* @returns * @returns
*/ */
isReadOnly: function(_id, _attr, _parent) { et2_readonlysArrayMgr.prototype.isReadOnly = function (_id, _attr, _parent) {
var entry = null; var entry = null;
if (_id != null) {
if (_id != null) if (_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0) {
{
if(_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0)
{
_id = this.expandName(_id); _id = this.expandName(_id);
} }
// readonlys was not namespaced in old eTemplate, therefore if we dont find data // readonlys was not namespaced in old eTemplate, therefore if we dont find data
// under current namespace, we look into parent // under current namespace, we look into parent
// (if there is anything namespaced, we will NOT look for parent!) // (if there is anything namespaced, we will NOT look for parent!)
var mgr = this; var mgr = this;
while (mgr.parentMgr && jQuery.isEmptyObject(mgr.data)) while (mgr.getParentMgr() && jQuery.isEmptyObject(mgr.data)) {
{ mgr = mgr.getParentMgr();
mgr = mgr.parentMgr;
} }
entry = mgr.getEntry(_id); entry = mgr.getEntry(_id);
} }
// Let the array entry override the read only attribute entry // Let the array entry override the read only attribute entry
if (typeof entry != "undefined" && !(typeof entry === 'object')) if (typeof entry != "undefined" && !(typeof entry === 'object')) {
{
return entry; return entry;
} }
// If the attribute is set, return that // If the attribute is set, return that
if (typeof _attr != "undefined" && _attr !== null) if (typeof _attr != "undefined" && _attr !== null) {
{
// Accept 'editable', but otherwise boolean // Accept 'editable', but otherwise boolean
return this.expandName(_attr) === 'editable' ? 'editable' : et2_evalBool(_attr); return this.expandName(_attr) === 'editable' ? 'editable' : et2_evalBool(_attr);
} }
// Otherwise take into accounf whether the parent is readonly // Otherwise take into accounf whether the parent is readonly
if (typeof _parent != "undefined" && _parent) if (typeof _parent != "undefined" && _parent) {
{
return true; return true;
} }
// Otherwise return the default value // Otherwise return the default value
entry = this.getEntry("__ALL__"); entry = this.getEntry("__ALL__");
return entry !== null && (typeof entry != "undefined"); return entry !== null && (typeof entry != "undefined");
}, };
/** /**
* Override parent to handle cont and row_cont. * Override parent to handle cont and row_cont.
* *
@ -450,11 +385,12 @@ var et2_readonlysArrayMgr = (function(){ "use strict"; return et2_arrayMgr.exten
* @param {string} ident Key for searching into the array. * @param {string} ident Key for searching into the array.
* @returns {*} * @returns {*}
*/ */
expandName: function(ident) et2_readonlysArrayMgr.prototype.expandName = function (ident) {
{
return this.perspectiveData.owner.getArrayMgr('content').expandName(ident); return this.perspectiveData.owner.getArrayMgr('content').expandName(ident);
} };
});}).call(this); return et2_readonlysArrayMgr;
}(et2_arrayMgr));
exports.et2_readonlysArrayMgr = et2_readonlysArrayMgr;
/** /**
* Creates a new set of array managers * Creates a new set of array managers
@ -467,27 +403,21 @@ var et2_readonlysArrayMgr = (function(){ "use strict"; return et2_arrayMgr.exten
* existing array managers. * existing array managers.
* @param _row is the row for which the array managers will be opened. * @param _row is the row for which the array managers will be opened.
*/ */
function et2_arrayMgrs_expand(_owner, _mgrs, _data, _row) function et2_arrayMgrs_expand(_owner, _mgrs, _data, _row) {
{
// Create a copy of the given _mgrs associative array // Create a copy of the given _mgrs associative array
var result = {}; var result = {};
// Merge the given data associative array into the existing array managers // Merge the given data associative array into the existing array managers
for (var key in _mgrs) for (var key in _mgrs) {
{
result[key] = _mgrs[key]; result[key] = _mgrs[key];
if (typeof _data[key] != "undefined") {
if (typeof _data[key] != "undefined")
{
// Open a perspective for the given data row // Open a perspective for the given data row
var rowData = {}; var rowData = {};
rowData[_row] = _data[key]; rowData[_row] = _data[key];
result[key] = _mgrs[key].openPerspective(_owner, rowData, _row); result[key] = _mgrs[key].openPerspective(_owner, rowData, _row);
} }
} }
// Return the resulting managers object // Return the resulting managers object
return result; return result;
} }
//# sourceMappingURL=et2_core_arrayMgr.js.map

File diff suppressed because one or more lines are too long

View File

@ -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(/&#x5B;/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(/&#x5D;/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(/&#x5B;/g, "[").replace(/&#x5D;/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;
}

View File

@ -98,14 +98,14 @@ var et2_box = /** @class */ (function (_super) {
var mgrs = this.getArrayMgrs(); var mgrs = this.getArrayMgrs();
for (var name in mgrs) { for (var name in mgrs) {
if (this.getArrayMgr(name).getEntry(childIndex)) { if (this.getArrayMgr(name).getEntry(childIndex)) {
this.getArrayMgr(name).perspectiveData.row = childIndex; this.getArrayMgr(name).setRow(childIndex);
} }
} }
this.createElementFromNode(repeatNode); this.createElementFromNode(repeatNode);
} }
// Reset // Reset
for (var name in this.getArrayMgrs()) { for (var name in this.getArrayMgrs()) {
this.getArrayMgr(name).perspectiveData = currentPerspective; this.getArrayMgr(name).setPerspectiveData(currentPerspective);
} }
} }
}; };

View File

@ -1 +1 @@
{"version":3,"file":"et2_widget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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"}

View File

@ -112,7 +112,7 @@ export class et2_box extends et2_baseWidget implements et2_IDetachedDOM
{ {
if(this.getArrayMgr(name).getEntry(childIndex)) 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 // Reset
for(var name in this.getArrayMgrs()) for(var name in this.getArrayMgrs()) {
{ this.getArrayMgr(name).setPerspectiveData(currentPerspective);
this.getArrayMgr(name).perspectiveData = currentPerspective;
} }
} }
} }
@ -184,19 +183,18 @@ export class et2_details extends et2_box
}, },
title: { title: {
name: "title", name: "title",
description:"Set a header title for box and shows it next to toggle button, default is no title", description: "Set a header title for box and shows it next to toggle button, default is no title",
type:"string", type: "string",
default: "", default: "",
translate: true translate: true
} }
}; };
private title : JQuery; private title: JQuery;
private span : JQuery; private span: JQuery;
private wrapper : JQuery; private readonly wrapper: JQuery;
constructor(_parent, _attrs? : WidgetConfig, _child? : object) constructor(_parent, _attrs?: WidgetConfig, _child?: object) {
{
super(_parent, _attrs, _child); super(_parent, _attrs, _child);
this.div = jQuery(document.createElement('div')).addClass('et2_details'); this.div = jQuery(document.createElement('div')).addClass('et2_details');
@ -225,19 +223,19 @@ export class et2_details extends et2_box
/** /**
* Create widget, set contents, and binds handlers * Create widget, set contents, and binds handlers
*/ */
_createWidget() _createWidget() {
{ const self = this;
var self = this;
this.span.on('click', function (e){ this.span.on('click', function (e) {
self._toggle(); self._toggle();
}); });
//Set header title //Set header title
if (this.options.title) if (this.options.title) {
{
this.title this.title
.click (function(){self._toggle();}) .click(function () {
self._toggle();
})
.text(this.options.title); .text(this.options.title);
} }