got et2 mostly working: timesheet.edit renders

This commit is contained in:
Ralf Becker 2021-06-07 17:33:53 +02:00
parent 592b7fb97d
commit f91bca83e1
183 changed files with 11759 additions and 12588 deletions

View File

@ -45,8 +45,8 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
$content = "import './js/jsapi/egw_config.js';\n"; $content = "import './js/jsapi/egw_config.js';\n";
$content .= "import './js/jsapi/egw_links.js';\n\n"; $content .= "import './js/jsapi/egw_links.js';\n\n";
$content .= 'window.egw.set_configs('.$config.", window.egw && window.egw.window !== window);\n"; $content .= 'egw.set_configs('.$config.", window.egw && window.egw.window !== window);\n";
$content .= 'window.egw.set_link_registry('.$link_registry.", undefined, window.egw && window.egw.window !== window);\n"; $content .= 'egw.set_link_registry('.$link_registry.", undefined, window.egw && window.egw.window !== window);\n";
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))

View File

@ -48,7 +48,7 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
exit; exit;
} }
if (empty($_GET['debug'])) $content = "import './js/jsapi/egw_images.js';\n\nwindow.egw.set_images(".$content.", window.egw && window.egw.window !== window);\n"; if (empty($_GET['debug'])) $content = "import './js/jsapi/egw_images.js';\n\negw.set_images(".$content.", egw && egw.window !== window);\n";
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))

View File

@ -6,7 +6,8 @@
* @copyright 2011 by Andreas Stöckel * @copyright 2011 by Andreas Stöckel
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package egw_action * @package egw_action
* @version $Id$ *
* @Todo: @new-js-loader port to TypeScript
*/ */
//Global variable which is used to store the currently active menu so that it //Global variable which is used to store the currently active menu so that it
@ -125,7 +126,7 @@ function _egwSetMenuOnClick(_elements, _onClick)
* The currently available implementation is the "egwDhtmlxMenu.js" which is based * The currently available implementation is the "egwDhtmlxMenu.js" which is based
* upon the dhtmlxmenu component. * upon the dhtmlxmenu component.
*/ */
function egwMenu() export function egwMenu()
{ {
//The "items" variable contains all menu items of the menu //The "items" variable contains all menu items of the menu
this.children = []; this.children = [];
@ -373,7 +374,7 @@ egwMenu.prototype.setGlobalOnClick = function(_onClick)
* Constructor for the egwMenuItem. Each entry in a menu (including seperators) * Constructor for the egwMenuItem. Each entry in a menu (including seperators)
* is represented by a menu item. * is represented by a menu item.
*/ */
function egwMenuItem(_parent, _id) export function egwMenuItem(_parent, _id)
{ {
this.id = _id; this.id = _id;
this.caption = ""; this.caption = "";

View File

@ -1,38 +1,23 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS DOM Widget class * EGroupware eTemplate2 - JS DOM Widget class
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_action_object_impl = exports.et2_DOMWidget = void 0;
/*egw:uses /*egw:uses
et2_core_interfaces; et2_core_interfaces;
et2_core_widget; et2_core_widget;
/api/js/egw_action/egw_action.js; /api/js/egw_action/egw_action.js;
*/ */
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from './et2_core_inheritance';
require("./et2_core_interfaces"); import { et2_IDOMNode } from "./et2_core_interfaces";
require("./et2_core_common"); import { et2_hasChild, et2_no_init } from "./et2_core_common";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_widget } from "./et2_core_widget";
require("../egw_action/egw_action.js"); import '../egw_action/egw_action.js';
import { egw } from "../jsapi/egw_global";
/** /**
* Abstract widget class which can be inserted into the DOM. All widget classes * Abstract widget class which can be inserted into the DOM. All widget classes
* deriving from this class have to care about implementing the "getDOMNode" * deriving from this class have to care about implementing the "getDOMNode"
@ -40,32 +25,29 @@ require("../egw_action/egw_action.js");
* *
* @augments et2_widget * @augments et2_widget
*/ */
var et2_DOMWidget = /** @class */ (function (_super) { export class et2_DOMWidget extends et2_widget {
__extends(et2_DOMWidget, _super);
/** /**
* When the DOMWidget is initialized, it grabs the DOM-Node of the parent * When the DOMWidget is initialized, it grabs the DOM-Node of the parent
* object (if available) and passes it to its own "createDOMNode" function * object (if available) and passes it to its own "createDOMNode" function
* *
* @memberOf et2_DOMWidget * @memberOf et2_DOMWidget
*/ */
function et2_DOMWidget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_DOMWidget._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_DOMWidget._attributes, _child || {}));
_this.parentNode = null; this.parentNode = null;
_this.disabled = false; this.disabled = false;
_this._attachSet = { this._attachSet = {
"node": null, "node": null,
"parent": null "parent": null
}; };
_this._surroundingsMgr = null; this._surroundingsMgr = null;
return _this;
} }
/** /**
* Detatches the node from the DOM and clears all references to the parent * Detatches the node from the DOM and clears all references to the parent
* node or the dom node of this widget. * node or the dom node of this widget.
*/ */
et2_DOMWidget.prototype.destroy = function () { destroy() {
this.detachFromDOM(); this.detachFromDOM();
this.parentNode = null; this.parentNode = null;
this._attachSet = {}; this._attachSet = {};
@ -83,12 +65,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
this._surroundingsMgr.destroy(); this._surroundingsMgr.destroy();
this._surroundingsMgr = null; this._surroundingsMgr = null;
} }
_super.prototype.destroy.call(this); super.destroy();
}; }
/** /**
* Attaches the container node of this widget to the DOM-Tree * Attaches the container node of this widget to the DOM-Tree
*/ */
et2_DOMWidget.prototype.doLoadingFinished = function () { doLoadingFinished() {
// Check whether the parent implements the et2_IDOMNode interface. If // Check whether the parent implements the et2_IDOMNode interface. If
// yes, grab the DOM node and create our own. // yes, grab the DOM node and create our own.
if (this.getParent() && this.getParent().implements(et2_IDOMNode)) { if (this.getParent() && this.getParent().implements(et2_IDOMNode)) {
@ -100,12 +82,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
} }
} }
return true; return true;
}; }
/** /**
* Detaches the widget from the DOM tree, if it had been attached to the * Detaches the widget from the DOM tree, if it had been attached to the
* DOM-Tree using the attachToDOM method. * DOM-Tree using the attachToDOM method.
*/ */
et2_DOMWidget.prototype.detachFromDOM = function () { detachFromDOM() {
if (this._attachSet && this._attachSet.node && this._attachSet.parent) { if (this._attachSet && this._attachSet.node && this._attachSet.parent) {
// Remove the current node from the parent node // Remove the current node from the parent node
try { try {
@ -122,13 +104,13 @@ var et2_DOMWidget = /** @class */ (function (_super) {
return true; return true;
} }
return false; return false;
}; }
/** /**
* Attaches the widget to the DOM tree. Fails if the widget is already * Attaches the widget to the DOM tree. Fails if the widget is already
* attached to the tree or no parent node or no node for this widget is * attached to the tree or no parent node or no node for this widget is
* defined. * defined.
*/ */
et2_DOMWidget.prototype.attachToDOM = function () { attachToDOM() {
// Attach the DOM node of this widget (if existing) to the new parent // Attach the DOM node of this widget (if existing) to the new parent
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node && this.parentNode && if (node && this.parentNode &&
@ -155,7 +137,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
return true; return true;
} }
return false; return false;
}; }
/** /**
* Inserts a child at the given index. * Inserts a child at the given index.
* *
@ -163,8 +145,8 @@ var et2_DOMWidget = /** @class */ (function (_super) {
* of et2_widget * of et2_widget
* @param _idx is the position at which the element should be added. * @param _idx is the position at which the element should be added.
*/ */
et2_DOMWidget.prototype.insertChild = function (_node, _idx) { insertChild(_node, _idx) {
_super.prototype.insertChild.call(this, _node, _idx); super.insertChild(_node, _idx);
if (_node.instanceOf(et2_DOMWidget) && typeof _node.hasOwnProperty('parentNode') && this.getDOMNode(this)) { if (_node.instanceOf(et2_DOMWidget) && typeof _node.hasOwnProperty('parentNode') && this.getDOMNode(this)) {
try { try {
_node.setParentDOMNode(this.getDOMNode(_node)); _node.setParentDOMNode(this.getDOMNode(_node));
@ -174,16 +156,16 @@ var et2_DOMWidget = /** @class */ (function (_super) {
// will probably try again in doLoadingFinished() // will probably try again in doLoadingFinished()
} }
} }
}; }
et2_DOMWidget.prototype.isAttached = function () { isAttached() {
return this.parentNode != null; return this.parentNode != null;
}; }
et2_DOMWidget.prototype.getSurroundings = function () { getSurroundings() {
if (!this._surroundingsMgr) { if (!this._surroundingsMgr) {
this._surroundingsMgr = new et2_surroundingsMgr(this); this._surroundingsMgr = new et2_surroundingsMgr(this);
} }
return this._surroundingsMgr; return this._surroundingsMgr;
}; }
/** /**
* Get data for the tab this widget is on. * Get data for the tab this widget is on.
* *
@ -195,7 +177,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
* *
* @returns {Object|null} Data for tab the widget is on * @returns {Object|null} Data for tab the widget is on
*/ */
et2_DOMWidget.prototype.get_tab_info = function () { get_tab_info() {
var parent = this; var parent = this;
do { do {
parent = parent.getParent(); parent = parent.getParent();
@ -204,7 +186,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
if (parent === this.getRoot()) { if (parent === this.getRoot()) {
return null; return null;
} }
var tabbox = parent; let tabbox = parent;
// Find the tab index // Find the tab index
for (var i = 0; i < tabbox.tabData.length; i++) { for (var i = 0; i < tabbox.tabData.length; i++) {
// Find the tab by DOM heritage // Find the tab by DOM heritage
@ -226,19 +208,19 @@ var et2_DOMWidget = /** @class */ (function (_super) {
} }
} }
// Fallback // Fallback
var fallback = this.getParent(); let fallback = this.getParent();
if (typeof fallback.get_tab_info === 'function') { if (typeof fallback.get_tab_info === 'function') {
return fallback.get_tab_info(); return fallback.get_tab_info();
} }
return null; return null;
}; }
/** /**
* Set the parent DOM node of this element. Takes a wider variety of types * Set the parent DOM node of this element. Takes a wider variety of types
* than setParentDOMNode(), and matches the set_<attribute> naming convention. * than setParentDOMNode(), and matches the set_<attribute> naming convention.
* *
* @param _node String|DOMNode DOM node to contain the widget, or the ID of the DOM node. * @param _node String|DOMNode DOM node to contain the widget, or the ID of the DOM node.
*/ */
et2_DOMWidget.prototype.set_parent_node = function (_node) { set_parent_node(_node) {
if (typeof _node == "string") { if (typeof _node == "string") {
var parent = jQuery('#' + _node); var parent = jQuery('#' + _node);
if (parent.length === 0 && window.parent) { if (parent.length === 0 && window.parent) {
@ -256,14 +238,14 @@ var et2_DOMWidget = /** @class */ (function (_super) {
else { else {
this.setParentDOMNode(_node); this.setParentDOMNode(_node);
} }
}; }
/** /**
* Set the parent DOM node of this element. If another parent node is already * Set the parent DOM node of this element. If another parent node is already
* set, this widget removes itself from the DOM tree * set, this widget removes itself from the DOM tree
* *
* @param _node * @param _node
*/ */
et2_DOMWidget.prototype.setParentDOMNode = function (_node) { setParentDOMNode(_node) {
if (_node != this.parentNode) { if (_node != this.parentNode) {
// Detatch this element from the DOM tree // Detatch this element from the DOM tree
this.detachFromDOM(); this.detachFromDOM();
@ -271,17 +253,17 @@ var et2_DOMWidget = /** @class */ (function (_super) {
// And attatch the element to the DOM tree // And attatch the element to the DOM tree
this.attachToDOM(); this.attachToDOM();
} }
}; }
/** /**
* Returns the parent node. * Returns the parent node.
*/ */
et2_DOMWidget.prototype.getParentDOMNode = function () { getParentDOMNode() {
return this.parentNode; return this.parentNode;
}; }
/** /**
* Returns the index of this element in the DOM tree * Returns the index of this element in the DOM tree
*/ */
et2_DOMWidget.prototype.getDOMIndex = function () { getDOMIndex() {
if (this.getParent()) { if (this.getParent()) {
var idx = 0; var idx = 0;
var children = this.getParent().getChildren(); var children = this.getParent().getChildren();
@ -298,7 +280,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
} }
} }
return -1; return -1;
}; }
/** /**
* Sets the id of the DOM-Node. * Sets the id of the DOM-Node.
* *
@ -306,7 +288,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
* *
* @param {string} _value id to set * @param {string} _value id to set
*/ */
et2_DOMWidget.prototype.set_id = function (_value) { set_id(_value) {
this.id = _value; this.id = _value;
this.dom_id = _value ? this.getInstanceManager().uniqueId + '_' + _value.replace(/\./g, '-') : _value; this.dom_id = _value ? this.getInstanceManager().uniqueId + '_' + _value.replace(/\./g, '-') : _value;
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
@ -318,8 +300,8 @@ var et2_DOMWidget = /** @class */ (function (_super) {
node.removeAttribute("id"); node.removeAttribute("id");
} }
} }
}; }
et2_DOMWidget.prototype.set_disabled = function (_value) { set_disabled(_value) {
var node = this._surroundingsMgr != null ? this._surroundingsMgr.getDOMNode(this.getDOMNode(this)) : this.getDOMNode(this); var node = this._surroundingsMgr != null ? this._surroundingsMgr.getDOMNode(this.getDOMNode(this)) : this.getDOMNode(this);
if (node && this.disabled != _value) { if (node && this.disabled != _value) {
this.disabled = _value; this.disabled = _value;
@ -330,22 +312,22 @@ var et2_DOMWidget = /** @class */ (function (_super) {
jQuery(node).show(); jQuery(node).show();
} }
} }
}; }
et2_DOMWidget.prototype.set_width = function (_value) { set_width(_value) {
this.width = _value; this.width = _value;
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node) { if (node) {
jQuery(node).css("width", _value); jQuery(node).css("width", _value);
} }
}; }
et2_DOMWidget.prototype.set_height = function (_value) { set_height(_value) {
this.height = _value; this.height = _value;
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node) { if (node) {
jQuery(node).css("height", _value); jQuery(node).css("height", _value);
} }
}; }
et2_DOMWidget.prototype.set_class = function (_value) { set_class(_value) {
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node) { if (node) {
if (this["class"]) { if (this["class"]) {
@ -354,15 +336,15 @@ var et2_DOMWidget = /** @class */ (function (_super) {
jQuery(node).addClass(_value); jQuery(node).addClass(_value);
} }
this["class"] = _value; this["class"] = _value;
}; }
et2_DOMWidget.prototype.set_overflow = function (_value) { set_overflow(_value) {
this.overflow = _value; this.overflow = _value;
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node) { if (node) {
jQuery(node).css("overflow", _value); jQuery(node).css("overflow", _value);
} }
}; }
et2_DOMWidget.prototype.set_data = function (_value) { set_data(_value) {
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
if (node && _value) { if (node && _value) {
var pairs = _value.split(/,/g); var pairs = _value.split(/,/g);
@ -371,8 +353,8 @@ var et2_DOMWidget = /** @class */ (function (_super) {
jQuery(node).attr('data-' + name_value[0], name_value[1]); jQuery(node).attr('data-' + name_value[0], name_value[1]);
} }
} }
}; }
et2_DOMWidget.prototype.set_background = function (_value) { set_background(_value) {
var node = this.getDOMNode(this); var node = this.getDOMNode(this);
var values = ''; var values = '';
if (_value && node) { if (_value && node) {
@ -384,7 +366,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
"background-scale": values[3] "background-scale": values[3]
}); });
} }
}; }
/** /**
* Set Actions on the widget * Set Actions on the widget
* *
@ -411,7 +393,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
* @param {object} actions {ID: {attributes..}+} map of egw action information * @param {object} actions {ID: {attributes..}+} map of egw action information
* @see api/src/Etemplate/Widget/Nextmatch.php egw_actions() method * @see api/src/Etemplate/Widget/Nextmatch.php egw_actions() method
*/ */
et2_DOMWidget.prototype.set_actions = function (actions) { set_actions(actions) {
if (this.id == "" || typeof this.id == "undefined") { if (this.id == "" || typeof this.id == "undefined") {
this.egw().debug("warn", "Widget should have an ID if you want actions", this); this.egw().debug("warn", "Widget should have an ID if you want actions", this);
return; return;
@ -438,12 +420,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
this._actionManager.data = { widget: this }; this._actionManager.data = { widget: this };
// Link the actions to the DOM // Link the actions to the DOM
this._link_actions(actions); this._link_actions(actions);
}; }
et2_DOMWidget.prototype.set_default_execute = function (_default_execute) { set_default_execute(_default_execute) {
this.options.default_execute = _default_execute; this.options.default_execute = _default_execute;
if (this._actionManager) if (this._actionManager)
this._actionManager.setDefaultExecute(null, _default_execute); this._actionManager.setDefaultExecute(null, _default_execute);
}; }
/** /**
* Get all action-links / id's of 1.-level actions from a given action object * Get all action-links / id's of 1.-level actions from a given action object
* *
@ -452,20 +434,20 @@ var et2_DOMWidget = /** @class */ (function (_super) {
* @param actions * @param actions
* @returns {Array} * @returns {Array}
*/ */
et2_DOMWidget.prototype._get_action_links = function (actions) { _get_action_links(actions) {
var action_links = []; var action_links = [];
for (var i in actions) { for (var i in actions) {
var action = actions[i]; var action = actions[i];
action_links.push(typeof action.id != 'undefined' ? action.id : i); action_links.push(typeof action.id != 'undefined' ? action.id : i);
} }
return action_links; return action_links;
}; }
/** /**
* Link the actions to the DOM nodes / widget bits. * Link the actions to the DOM nodes / widget bits.
* *
* @param {object} actions {ID: {attributes..}+} map of egw action information * @param {object} actions {ID: {attributes..}+} map of egw action information
*/ */
et2_DOMWidget.prototype._link_actions = function (actions) { _link_actions(actions) {
// Get the top level element for the tree // Get the top level element for the tree
var objectManager = egw_getAppObjectManager(true); var objectManager = egw_getAppObjectManager(true);
var widget_object = objectManager.getObjectById(this.id); var widget_object = objectManager.getObjectById(this.id);
@ -484,8 +466,9 @@ var et2_DOMWidget = /** @class */ (function (_super) {
// 'allowed' for this widget at this time // 'allowed' for this widget at this time
var action_links = this._get_action_links(actions); var action_links = this._get_action_links(actions);
widget_object.updateActionLinks(action_links); widget_object.updateActionLinks(action_links);
}; }
et2_DOMWidget._attributes = { }
et2_DOMWidget._attributes = {
"disabled": { "disabled": {
"name": "Disabled", "name": "Disabled",
"type": "boolean", "type": "boolean",
@ -552,44 +535,39 @@ var et2_DOMWidget = /** @class */ (function (_super) {
default: '', default: '',
description: "Sets background image, left, right and scale on DOM", description: "Sets background image, left, right and scale on DOM",
} }
}; };
return et2_DOMWidget;
}(et2_core_widget_1.et2_widget));
exports.et2_DOMWidget = et2_DOMWidget;
/** /**
* The surroundings manager class allows to append or prepend elements around * The surroundings manager class allows to append or prepend elements around
* an widget node. * an widget node.
*/ */
var et2_surroundingsMgr = /** @class */ (function (_super) { export class et2_surroundingsMgr extends ClassWithAttributes {
__extends(et2_surroundingsMgr, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_surroundingsMgr * @memberOf et2_surroundingsMgr
* @param _widget * @param _widget
*/ */
function et2_surroundingsMgr(_widget) { constructor(_widget) {
var _this = _super.call(this) || this; super();
_this._widgetContainer = null; this._widgetContainer = null;
_this._widgetSurroundings = []; this._widgetSurroundings = [];
_this._widgetPlaceholder = null; this._widgetPlaceholder = null;
_this._widgetNode = null; this._widgetNode = null;
_this._ownPlaceholder = true; this._ownPlaceholder = true;
_this._surroundingsUpdated = false; this._surroundingsUpdated = false;
_this.widget = _widget; this.widget = _widget;
return _this;
} }
et2_surroundingsMgr.prototype.destroy = function () { destroy() {
this._widgetContainer = null; this._widgetContainer = null;
this._widgetSurroundings = null; this._widgetSurroundings = null;
this._widgetPlaceholder = null; this._widgetPlaceholder = null;
this._widgetNode = null; this._widgetNode = null;
}; }
et2_surroundingsMgr.prototype.prependDOMNode = function (_node) { prependDOMNode(_node) {
this._widgetSurroundings.unshift(_node); this._widgetSurroundings.unshift(_node);
this._surroundingsUpdated = true; this._surroundingsUpdated = true;
}; }
et2_surroundingsMgr.prototype.appendDOMNode = function (_node) { appendDOMNode(_node) {
// Append an placeholder first if none is existing yet // Append an placeholder first if none is existing yet
if (this._ownPlaceholder && this._widgetPlaceholder == null) { if (this._ownPlaceholder && this._widgetPlaceholder == null) {
this._widgetPlaceholder = document.createElement("span"); this._widgetPlaceholder = document.createElement("span");
@ -598,8 +576,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
// Append the given node // Append the given node
this._widgetSurroundings.push(_node); this._widgetSurroundings.push(_node);
this._surroundingsUpdated = true; this._surroundingsUpdated = true;
}; }
et2_surroundingsMgr.prototype.insertDOMNode = function (_node) { insertDOMNode(_node) {
if (!this._ownPlaceholder || this._widgetPlaceholder == null) { if (!this._ownPlaceholder || this._widgetPlaceholder == null) {
this.appendDOMNode(_node); this.appendDOMNode(_node);
return; return;
@ -611,8 +589,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
// Delete the reference to the own placeholder // Delete the reference to the own placeholder
this._widgetPlaceholder = null; this._widgetPlaceholder = null;
this._ownPlaceholder = false; this._ownPlaceholder = false;
}; }
et2_surroundingsMgr.prototype.removeDOMNode = function (_node) { removeDOMNode(_node) {
for (var i = 0; this._widgetSurroundings && i < this._widgetSurroundings.length; i++) { for (var i = 0; this._widgetSurroundings && i < this._widgetSurroundings.length; i++) {
if (this._widgetSurroundings[i] == _node) { if (this._widgetSurroundings[i] == _node) {
this._widgetSurroundings.splice(i, 1); this._widgetSurroundings.splice(i, 1);
@ -620,8 +598,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
break; break;
} }
} }
}; }
et2_surroundingsMgr.prototype.setWidgetPlaceholder = function (_node) { setWidgetPlaceholder(_node) {
if (_node != this._widgetPlaceholder) { if (_node != this._widgetPlaceholder) {
if (_node != null && this._ownPlaceholder && this._widgetPlaceholder != null) { if (_node != null && this._ownPlaceholder && this._widgetPlaceholder != null) {
// Delete the current placeholder which was created by the // Delete the current placeholder which was created by the
@ -637,8 +615,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
this._widgetPlaceholder = _node; this._widgetPlaceholder = _node;
this._surroundingsUpdated = true; this._surroundingsUpdated = true;
} }
}; }
et2_surroundingsMgr.prototype._rebuildContainer = function () { _rebuildContainer() {
// Return if there has been no change in the "surroundings-data" // Return if there has been no change in the "surroundings-data"
if (!this._surroundingsUpdated) { if (!this._surroundingsUpdated) {
return false; return false;
@ -679,8 +657,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
} }
this._surroundingsUpdated = false; this._surroundingsUpdated = false;
return true; return true;
}; }
et2_surroundingsMgr.prototype.update = function () { update() {
if (this._surroundingsUpdated) { if (this._surroundingsUpdated) {
var attached = this.widget ? this.widget.isAttached() : false; var attached = this.widget ? this.widget.isAttached() : false;
// Reattach the widget - this will call the "getDOMNode" function // Reattach the widget - this will call the "getDOMNode" function
@ -690,8 +668,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
this.widget.attachToDOM(); this.widget.attachToDOM();
} }
} }
}; }
et2_surroundingsMgr.prototype.getDOMNode = function (_widgetNode) { getDOMNode(_widgetNode) {
// Update the whole widgetContainer if this is not the first time this // Update the whole widgetContainer if this is not the first time this
// function has been called but the widget node has changed. // function has been called but the widget node has changed.
if (this._widgetNode != null && this._widgetNode != _widgetNode) { if (this._widgetNode != null && this._widgetNode != _widgetNode) {
@ -716,12 +694,11 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
} }
// Return the widget container // Return the widget container
return this._widgetContainer; return this._widgetContainer;
}; }
et2_surroundingsMgr.prototype.getWidgetSurroundings = function () { getWidgetSurroundings() {
return this._widgetSurroundings; return this._widgetSurroundings;
}; }
return et2_surroundingsMgr; }
}(et2_core_inheritance_1.ClassWithAttributes));
/** /**
* The egw_action system requires an egwActionObjectInterface Interface implementation * The egw_action system requires an egwActionObjectInterface Interface implementation
* to tie actions to DOM nodes. This one can be used by any widget. * to tie actions to DOM nodes. This one can be used by any widget.
@ -732,8 +709,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
* @param {Object} node * @param {Object} node
* *
*/ */
var et2_action_object_impl = /** @class */ (function () { export class et2_action_object_impl {
function et2_action_object_impl(_widget, _node) { constructor(_widget, _node) {
var widget = _widget; var widget = _widget;
var objectNode = _node; var objectNode = _node;
this.aoi = new egwActionObjectInterface(); this.aoi = new egwActionObjectInterface();
@ -762,10 +739,8 @@ var et2_action_object_impl = /** @class */ (function () {
} }
}; };
} }
et2_action_object_impl.prototype.getAOI = function () { getAOI() {
return this.aoi; return this.aoi;
}; }
return et2_action_object_impl; }
}());
exports.et2_action_object_impl = et2_action_object_impl;
//# sourceMappingURL=et2_core_DOMWidget.js.map //# sourceMappingURL=et2_core_DOMWidget.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
@ -15,11 +15,13 @@
*/ */
import {ClassWithAttributes} from './et2_core_inheritance'; import {ClassWithAttributes} from './et2_core_inheritance';
import './et2_core_interfaces'; import {et2_IDOMNode} from "./et2_core_interfaces";
import './et2_core_common'; import {et2_hasChild, et2_no_init} from "./et2_core_common";
import {et2_widget, WidgetConfig} from "./et2_core_widget"; import {et2_widget, WidgetConfig} from "./et2_core_widget";
import '../egw_action/egw_action.js'; import '../egw_action/egw_action.js';
import {egw} from "../jsapi/egw_global";
// fixing circular dependencies by only importing type
import type {et2_tabbox} from "./et2_widget_tabs";
/** /**
* Abstract widget class which can be inserted into the DOM. All widget classes * Abstract widget class which can be inserted into the DOM. All widget classes
@ -683,7 +685,7 @@ export abstract class et2_DOMWidget extends et2_widget implements et2_IDOMNode
* The surroundings manager class allows to append or prepend elements around * The surroundings manager class allows to append or prepend elements around
* an widget node. * an widget node.
*/ */
class et2_surroundingsMgr extends ClassWithAttributes export class et2_surroundingsMgr extends ClassWithAttributes
{ {
widget: et2_DOMWidget; widget: et2_DOMWidget;
private _widgetContainer: any = null; private _widgetContainer: any = null;

View File

@ -1,40 +1,25 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS content array manager * EGroupware eTemplate2 - JS content array manager
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* */
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
egw_inheritance; egw_inheritance;
et2_core_phpExpressionCompiler; et2_core_phpExpressionCompiler;
*/ */
var __extends = (this && this.__extends) || (function () { import { et2_evalBool } from "./et2_core_common";
var extendStatics = function (d, b) { import { egw } from "../jsapi/egw_global";
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_arrayMgrs_expand = exports.et2_readonlysArrayMgr = exports.et2_arrayMgr = void 0;
/** /**
* Manage access to various template customisation arrays passed to etemplate->exec(). * Manage access to various template customisation arrays passed to etemplate->exec().
* *
* This manages access to content, modifications and readonlys arrays * This manages access to content, modifications and readonlys arrays
*/ */
var et2_arrayMgr = /** @class */ (function () { export class et2_arrayMgr {
/** /**
* Constructor * Constructor
* *
@ -42,8 +27,7 @@ var et2_arrayMgr = /** @class */ (function () {
* @param _data * @param _data
* @param _parentMgr * @param _parentMgr
*/ */
function et2_arrayMgr(_data, _parentMgr) { constructor(_data = {}, _parentMgr) {
if (_data === void 0) { _data = {}; }
this.splitIds = true; this.splitIds = true;
// Holds information about the current perspective // Holds information about the current perspective
this.perspectiveData = { this.perspectiveData = {
@ -68,14 +52,14 @@ var et2_arrayMgr = /** @class */ (function () {
// 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 (let key in _data) {
// Split up indexes // Split up indexes
var indexes = key.replace(/&#x5B;/g, "[").split('['); const indexes = key.replace(/&#x5B;/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]; const value = _data[key];
var target = _data; let target = _data;
for (var i = 0; i < indexes.length; i++) { for (let 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 : {};
@ -91,24 +75,24 @@ var et2_arrayMgr = /** @class */ (function () {
/** /**
* Returns the root content array manager object * Returns the root content array manager object
*/ */
et2_arrayMgr.prototype.getRoot = function () { getRoot() {
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 () { getParentMgr() {
return this._parentMgr; return this._parentMgr;
}; }
et2_arrayMgr.prototype.getPerspectiveData = function () { getPerspectiveData() {
return this.perspectiveData; return this.perspectiveData;
}; }
et2_arrayMgr.prototype.setPerspectiveData = function (new_perspective) { setPerspectiveData(new_perspective) {
this.perspectiveData = new_perspective; this.perspectiveData = new_perspective;
}; }
et2_arrayMgr.prototype.setRow = function (new_row) { setRow(new_row) {
this.perspectiveData.row = 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
@ -121,11 +105,11 @@ var et2_arrayMgr = /** @class */ (function () {
* *
* @return {string[]} * @return {string[]}
*/ */
et2_arrayMgr.prototype.explodeKey = function (_key) { explodeKey(_key) {
if (!_key || typeof _key == 'string' && _key.trim() === "") if (!_key || typeof _key == 'string' && _key.trim() === "")
return []; return [];
// 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]; let 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('[');
@ -133,20 +117,20 @@ var et2_arrayMgr = /** @class */ (function () {
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(']['); const 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.
*/ */
et2_arrayMgr.prototype.getPath = function (_path) { getPath(_path) {
if (typeof _path == "undefined") { if (typeof _path == "undefined") {
_path = []; _path = [];
} }
@ -158,7 +142,7 @@ var et2_arrayMgr = /** @class */ (function () {
_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
@ -170,7 +154,7 @@ var et2_arrayMgr = /** @class */ (function () {
* @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.
*/ */
et2_arrayMgr.prototype.getEntry = function (_key, _referenceInto, _skipEmpty) { getEntry(_key, _referenceInto, _skipEmpty) {
if (typeof _referenceInto == "undefined") { if (typeof _referenceInto == "undefined") {
_referenceInto = false; _referenceInto = false;
} }
@ -178,26 +162,26 @@ var et2_arrayMgr = /** @class */ (function () {
_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); const indexes = this.explodeKey(_key);
if (indexes.length == 0 && _skipEmpty) if (indexes.length == 0 && _skipEmpty)
return null; return null;
var entry = this.data; let entry = this.data;
for (var i = 0; i < indexes.length; i++) { for (let 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'; const 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]; const 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;
}; }
/** /**
* Equivalent to the boetemplate::expand_name function. * Equivalent to the boetemplate::expand_name function.
* *
@ -207,20 +191,20 @@ var et2_arrayMgr = /** @class */ (function () {
* @param {string} _ident Key used to reference into managed array * @param {string} _ident Key used to reference into managed array
* @return {*} * @return {*}
*/ */
et2_arrayMgr.prototype.expandName = function (_ident) { expandName(_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) == '@'; const 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('$'); const 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\}?/))
// Avoid messing with regex in validators // Avoid messing with regex in validators
&& pos_var !== _ident.indexOf("$/")) { && pos_var !== _ident.indexOf("$/")) {
// Get the content array for the current row // Get the content array for the current row
var row = typeof this.perspectiveData.row == 'number' ? this.perspectiveData.row : ''; const row = typeof this.perspectiveData.row == 'number' ? this.perspectiveData.row : '';
var row_cont = this.data[row] || {}; const 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; const cont = this.data; //getRoot().data;
var _cont = this.data; // according to a grep only used in ImportExport just twice const _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
@ -272,22 +256,22 @@ var et2_arrayMgr = /** @class */ (function () {
} }
} }
return _ident; return _ident;
}; }
et2_arrayMgr.prototype.parseBoolExpression = function (_expression) { parseBoolExpression(_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('='); const parts = _expression.split('=');
// Expand the first value // Expand the first value
var val = this.expandName(parts[0]); let val = this.expandName(parts[0]);
val = (typeof val == "undefined" || val === null) ? '' : '' + val; val = (typeof val == "undefined" || val === null) ? '' : '' + val;
// 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]); const 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) == '/') {
@ -298,7 +282,7 @@ var et2_arrayMgr = /** @class */ (function () {
return val == checkVal; return val == checkVal;
} }
return et2_evalBool(val); return et2_evalBool(val);
}; }
/** /**
* ? * ?
* *
@ -306,15 +290,15 @@ var et2_arrayMgr = /** @class */ (function () {
* @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
*/ */
et2_arrayMgr.prototype.openPerspective = function (_owner, _root, _row) { openPerspective(_owner, _root, _row) {
// Get the root node // Get the root node
var root = typeof _root == "string" ? this.data[_root] : let root = typeof _root == "string" ? this.data[_root] :
(_root == null ? this.data : _root); (_root == null ? this.data : _root);
if (typeof root == "undefined" && typeof _root == "string") if (typeof root == "undefined" && typeof _root == "string")
root = this.getEntry(_root); 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.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr; const constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr;
var mgr = new constructor(root, this); const 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
@ -326,20 +310,16 @@ var et2_arrayMgr = /** @class */ (function () {
mgr.perspectiveData.row = _row; mgr.perspectiveData.row = _row;
} }
return mgr; return mgr;
}; }
et2_arrayMgr.compiledExpressions = {}; }
return et2_arrayMgr; et2_arrayMgr.compiledExpressions = {};
}());
exports.et2_arrayMgr = et2_arrayMgr;
/** /**
* @augments et2_arrayMgr * @augments et2_arrayMgr
*/ */
var et2_readonlysArrayMgr = /** @class */ (function (_super) { export class et2_readonlysArrayMgr extends et2_arrayMgr {
__extends(et2_readonlysArrayMgr, _super); constructor() {
function et2_readonlysArrayMgr() { super(...arguments);
var _this = _super !== null && _super.apply(this, arguments) || this; this.readOnly = true;
_this.readOnly = true;
return _this;
} }
/** /**
* Find out if the given ID is readonly, according to the array data * Find out if the given ID is readonly, according to the array data
@ -350,8 +330,8 @@ var et2_readonlysArrayMgr = /** @class */ (function (_super) {
* @param _parent * @param _parent
* @returns * @returns
*/ */
et2_readonlysArrayMgr.prototype.isReadOnly = function (_id, _attr, _parent) { isReadOnly(_id, _attr, _parent) {
var entry = null; let 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);
@ -359,7 +339,7 @@ var et2_readonlysArrayMgr = /** @class */ (function (_super) {
// 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; let mgr = this;
while (mgr.getParentMgr() && jQuery.isEmptyObject(mgr.data)) { while (mgr.getParentMgr() && jQuery.isEmptyObject(mgr.data)) {
mgr = mgr.getParentMgr(); mgr = mgr.getParentMgr();
} }
@ -381,7 +361,7 @@ var et2_readonlysArrayMgr = /** @class */ (function (_super) {
// 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.
* *
@ -391,12 +371,10 @@ var et2_readonlysArrayMgr = /** @class */ (function (_super) {
* @param {string} ident Key for searching into the array. * @param {string} ident Key for searching into the array.
* @returns {*} * @returns {*}
*/ */
et2_readonlysArrayMgr.prototype.expandName = function (ident) { expandName(ident) {
return this.perspectiveData.owner.getArrayMgr('content').expandName(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 * Creates a new set of array managers
* *
@ -408,15 +386,15 @@ exports.et2_readonlysArrayMgr = et2_readonlysArrayMgr;
* 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) { export 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 = {}; let 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 (let 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 = {}; let 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);
} }
@ -424,5 +402,4 @@ function et2_arrayMgrs_expand(_owner, _mgrs, _data, _row) {
// Return the resulting managers object // Return the resulting managers object
return result; return result;
} }
exports.et2_arrayMgrs_expand = et2_arrayMgrs_expand;
//# sourceMappingURL=et2_core_arrayMgr.js.map //# sourceMappingURL=et2_core_arrayMgr.js.map

View File

@ -4,9 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* */
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
@ -14,7 +14,9 @@
et2_core_phpExpressionCompiler; et2_core_phpExpressionCompiler;
*/ */
import {et2_widget} from "./et2_core_widget"; import {et2_evalBool} from "./et2_core_common";
import type {et2_widget} from "./et2_core_widget";
import {egw} from "../jsapi/egw_global";
/** /**
* Manage access to various template customisation arrays passed to etemplate->exec(). * Manage access to various template customisation arrays passed to etemplate->exec().

View File

@ -1,38 +1,16 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Widget base class * EGroupware eTemplate2 - JS Widget base class
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
var __extends = (this && this.__extends) || (function () { import { et2_DOMWidget } from './et2_core_DOMWidget';
var extendStatics = function (d, b) { import { ClassWithAttributes } from "./et2_core_inheritance";
extendStatics = Object.setPrototypeOf || import { et2_register_widget } from "./et2_core_widget";
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || import { et2_no_init } from "./et2_core_common";
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_container = exports.et2_baseWidget = void 0;
/*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js;
lib/tooltip;
et2_core_DOMWidget;
*/
require("./et2_core_interfaces");
require("./et2_core_common");
var et2_core_DOMWidget_1 = require("./et2_core_DOMWidget");
var et2_core_inheritance_1 = require("./et2_core_inheritance");
var et2_core_widget_1 = require("./et2_core_widget");
/** /**
* Class which manages the DOM node itself. The simpleWidget class is derrived * Class which manages the DOM node itself. The simpleWidget class is derrived
* from et2_DOMWidget and implements the getDOMNode function. A setDOMNode * from et2_DOMWidget and implements the getDOMNode function. A setDOMNode
@ -40,27 +18,24 @@ var et2_core_widget_1 = require("./et2_core_widget");
* *
* @augments et2_DOMWidget * @augments et2_DOMWidget
*/ */
var et2_baseWidget = /** @class */ (function (_super) { export class et2_baseWidget extends et2_DOMWidget {
__extends(et2_baseWidget, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_baseWidget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_baseWidget._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_baseWidget._attributes, _child || {}));
_this.align = 'left'; this.align = 'left';
_this.node = null; this.node = null;
_this.statustext = ''; this.statustext = '';
_this._messageDiv = null; this._messageDiv = null;
_this._tooltipElem = null; this._tooltipElem = null;
return _this;
} }
et2_baseWidget.prototype.destroy = function () { destroy() {
_super.prototype.destroy.call(this); super.destroy();
this.node = null; this.node = null;
this._messageDiv = null; this._messageDiv = null;
}; }
/** /**
* The setMessage function can be used to attach a small message box to the * The setMessage function can be used to attach a small message box to the
* widget. This is e.g. used to display validation errors or success messages * widget. This is e.g. used to display validation errors or success messages
@ -74,7 +49,7 @@ var et2_baseWidget = /** @class */ (function (_super) {
* @param _prepend if set, the message is displayed behind the widget node * @param _prepend if set, the message is displayed behind the widget node
* instead of before. Defaults to false. * instead of before. Defaults to false.
*/ */
et2_baseWidget.prototype.showMessage = function (_text, _type, _floating, _prepend) { showMessage(_text, _type, _floating, _prepend) {
// Preset the parameters // Preset the parameters
if (typeof _type == "undefined") { if (typeof _type == "undefined") {
_type = "hint"; _type = "hint";
@ -103,7 +78,7 @@ var et2_baseWidget = /** @class */ (function (_super) {
surr.appendDOMNode(this._messageDiv[0]); surr.appendDOMNode(this._messageDiv[0]);
} }
surr.update(); surr.update();
}; }
/** /**
* The hideMessage function can be used to hide a previously shown message. * The hideMessage function can be used to hide a previously shown message.
* *
@ -112,7 +87,7 @@ var et2_baseWidget = /** @class */ (function (_super) {
* @param _noUpdate is used internally to prevent an update of the surroundings * @param _noUpdate is used internally to prevent an update of the surroundings
* manager. * manager.
*/ */
et2_baseWidget.prototype.hideMessage = function (_fade, _noUpdate) { hideMessage(_fade, _noUpdate) {
if (typeof _fade == "undefined") { if (typeof _fade == "undefined") {
_fade = true; _fade = true;
} }
@ -141,8 +116,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
_done(); _done();
} }
} }
}; }
et2_baseWidget.prototype.detachFromDOM = function () { detachFromDOM() {
// Detach this node from the tooltip node // Detach this node from the tooltip node
if (this._tooltipElem) { if (this._tooltipElem) {
this.egw().tooltipUnbind(this._tooltipElem); this.egw().tooltipUnbind(this._tooltipElem);
@ -152,10 +127,10 @@ var et2_baseWidget = /** @class */ (function (_super) {
if (this.node) { if (this.node) {
jQuery(this.node).unbind("click.et2_baseWidget"); jQuery(this.node).unbind("click.et2_baseWidget");
} }
return _super.prototype.detachFromDOM.call(this); return super.detachFromDOM();
}; }
et2_baseWidget.prototype.attachToDOM = function () { attachToDOM() {
var ret = _super.prototype.attachToDOM.call(this); let ret = super.attachToDOM();
// Add the binding for the click handler // Add the binding for the click handler
if (this.node) { if (this.node) {
jQuery(this.node).bind("click.et2_baseWidget", this, function (e) { jQuery(this.node).bind("click.et2_baseWidget", this, function (e) {
@ -167,8 +142,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
// Update the statustext // Update the statustext
this.set_statustext(this.statustext); this.set_statustext(this.statustext);
return ret; return ret;
}; }
et2_baseWidget.prototype.setDOMNode = function (_node) { setDOMNode(_node) {
if (_node != this.node) { if (_node != this.node) {
// Deatch the old node from the DOM // Deatch the old node from the DOM
this.detachFromDOM(); this.detachFromDOM();
@ -178,20 +153,20 @@ var et2_baseWidget = /** @class */ (function (_super) {
return this.attachToDOM(); return this.attachToDOM();
} }
return false; return false;
}; }
et2_baseWidget.prototype.getDOMNode = function (_sender) { getDOMNode(_sender) {
return this.node; return this.node;
}; }
et2_baseWidget.prototype.getTooltipElement = function () { getTooltipElement() {
return this.getDOMNode(this); return this.getDOMNode(this);
}; }
/** /**
* Click handler calling custom handler set via onclick attribute to this.onclick * Click handler calling custom handler set via onclick attribute to this.onclick
* *
* @param _ev * @param _ev
* @returns * @returns
*/ */
et2_baseWidget.prototype.click = function (_ev) { click(_ev) {
if (typeof this.onclick == 'function') { if (typeof this.onclick == 'function') {
// Make sure function gets a reference to the widget, splice it in as 2. argument if not // Make sure function gets a reference to the widget, splice it in as 2. argument if not
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
@ -200,8 +175,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
return this.onclick.apply(this, args); return this.onclick.apply(this, args);
} }
return true; return true;
}; }
et2_baseWidget.prototype.set_statustext = function (_value) { set_statustext(_value) {
// Tooltip should not be shown in mobile view // Tooltip should not be shown in mobile view
if (egwIsMobile()) if (egwIsMobile())
return; return;
@ -223,14 +198,15 @@ var et2_baseWidget = /** @class */ (function (_super) {
this._tooltipElem = elem; this._tooltipElem = elem;
} }
} }
}; }
et2_baseWidget.prototype.set_align = function (_value) { set_align(_value) {
this.align = _value; this.align = _value;
}; }
et2_baseWidget.prototype.get_align = function () { get_align() {
return this.align; return this.align;
}; }
et2_baseWidget._attributes = { }
et2_baseWidget._attributes = {
"statustext": { "statustext": {
"name": "Tooltip", "name": "Tooltip",
"type": "string", "type": "string",
@ -255,34 +231,28 @@ var et2_baseWidget = /** @class */ (function (_super) {
"default": et2_no_init, "default": et2_no_init,
"description": "JS code which is executed when the element is clicked." "description": "JS code which is executed when the element is clicked."
} }
}; };
return et2_baseWidget;
}(et2_core_DOMWidget_1.et2_DOMWidget));
exports.et2_baseWidget = et2_baseWidget;
/** /**
* Simple container object * Simple container object
* *
* There is no tag to put this in a template. By convention we only make one of these per etemplate, * There is no tag to put this in a template. By convention we only make one of these per etemplate,
* and it's the top level object. * and it's the top level object.
*/ */
var et2_container = /** @class */ (function (_super) { export class et2_container extends et2_baseWidget {
__extends(et2_container, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_container(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_container._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_container._attributes, _child || {}));
_this.setDOMNode(document.createElement("div")); this.setDOMNode(document.createElement("div"));
return _this;
} }
/** /**
* The destroy function destroys all children of the widget, removes itself * The destroy function destroys all children of the widget, removes itself
* from the parents children list. * from the parents children list.
* Overriden to not try to remove self from parent, as that's not possible. * Overriden to not try to remove self from parent, as that's not possible.
*/ */
et2_container.prototype.destroy = function () { destroy() {
// Call the destructor of all children // Call the destructor of all children
for (var i = this._children.length - 1; i >= 0; i--) { for (var i = this._children.length - 1; i >= 0; i--) {
this._children[i].destroy(); this._children[i].destroy();
@ -293,31 +263,31 @@ var et2_container = /** @class */ (function (_super) {
this._mgrs[key].destroy(); this._mgrs[key].destroy();
} }
} }
}; }
/** /**
* Searches for a DOM widget by id in the tree, descending into the child levels. * Searches for a DOM widget by id in the tree, descending into the child levels.
* *
* @param _id is the id you're searching for * @param _id is the id you're searching for
*/ */
et2_container.prototype.getDOMWidgetById = function (_id) { getDOMWidgetById(_id) {
var widget = this.getWidgetById(_id); let widget = this.getWidgetById(_id);
if (widget && widget.instanceOf(et2_core_DOMWidget_1.et2_DOMWidget)) { if (widget && widget.instanceOf(et2_DOMWidget)) {
return widget; return widget;
} }
return null; return null;
}; }
/** /**
* Searches for a Value widget by id in the tree, descending into the child levels. * Searches for a Value widget by id in the tree, descending into the child levels.
* *
* @param _id is the id you're searching for * @param _id is the id you're searching for
*/ */
et2_container.prototype.getInputWidgetById = function (_id) { getInputWidgetById(_id) {
var widget = this.getWidgetById(_id); let widget = this.getWidgetById(_id);
if (widget && widget.instanceOf(et2_valueWidget)) { if (widget && widget.instanceOf(et2_valueWidget)) {
return widget; return widget;
} }
return null; return null;
}; }
/** /**
* Set the value for a child widget, specified by the given ID * Set the value for a child widget, specified by the given ID
* *
@ -328,8 +298,8 @@ var et2_container = /** @class */ (function (_super) {
* *
* @throws Error If the widget cannot be found or it does not have a set_value() function * @throws Error If the widget cannot be found or it does not have a set_value() function
*/ */
et2_container.prototype.setValueById = function (id, value) { setValueById(id, value) {
var widget = this.getWidgetById(id); let widget = this.getWidgetById(id);
if (!widget) if (!widget)
throw 'Could not find widget ' + id; throw 'Could not find widget ' + id;
// Don't care about what class it is, just that it has the function // Don't care about what class it is, just that it has the function
@ -339,7 +309,7 @@ var et2_container = /** @class */ (function (_super) {
} }
// @ts-ignore // @ts-ignore
return widget.set_value(value); return widget.set_value(value);
}; }
/** /**
* Get the current value of a child widget, specified by the given ID * Get the current value of a child widget, specified by the given ID
* *
@ -348,8 +318,8 @@ var et2_container = /** @class */ (function (_super) {
* @param id string The ID you're searching for * @param id string The ID you're searching for
* @throws Error If the widget cannot be found or it does not have a set_value() function * @throws Error If the widget cannot be found or it does not have a set_value() function
*/ */
et2_container.prototype.getValueById = function (id) { getValueById(id) {
var widget = this.getWidgetById(id); let widget = this.getWidgetById(id);
if (!widget) if (!widget)
throw 'Could not find widget ' + id; throw 'Could not find widget ' + id;
// Don't care about what class it is, just that it has the function // Don't care about what class it is, just that it has the function
@ -359,15 +329,15 @@ var et2_container = /** @class */ (function (_super) {
} }
// @ts-ignore // @ts-ignore
return widget.get_value(); return widget.get_value();
}; }
/** /**
* Set the value for a child widget, specified by the given ID * Set the value for a child widget, specified by the given ID
* *
* @param id string The ID you're searching for * @param id string The ID you're searching for
* @throws Error If the widget cannot be found or it does not have a set_value() function * @throws Error If the widget cannot be found or it does not have a set_value() function
*/ */
et2_container.prototype.setDisabledById = function (id, value) { setDisabledById(id, value) {
var widget = this.getWidgetById(id); let widget = this.getWidgetById(id);
if (!widget) if (!widget)
throw 'Could not find widget ' + id; throw 'Could not find widget ' + id;
// Don't care about what class it is, just that it has the function // Don't care about what class it is, just that it has the function
@ -377,39 +347,35 @@ var et2_container = /** @class */ (function (_super) {
} }
// @ts-ignore // @ts-ignore
return widget.set_disabled(value); return widget.set_disabled(value);
}; }
return et2_container; }
}(et2_baseWidget));
exports.et2_container = et2_container;
// Register widget for attributes, but not for any xml tags // Register widget for attributes, but not for any xml tags
et2_core_widget_1.et2_register_widget(et2_container, []); et2_register_widget(et2_container, []);
/** /**
* Container object for not-yet supported widgets * Container object for not-yet supported widgets
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
var et2_placeholder = /** @class */ (function (_super) { export class et2_placeholder extends et2_baseWidget {
__extends(et2_placeholder, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_placeholder(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_placeholder._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_placeholder._attributes, _child || {}));
_this.visible = false; this.visible = false;
_this.attrNodes = {}; this.attrNodes = {};
// Create the placeholder div // Create the placeholder div
_this.placeDiv = jQuery(document.createElement("span")) this.placeDiv = jQuery(document.createElement("span"))
.addClass("et2_placeholder"); .addClass("et2_placeholder");
var headerNode = jQuery(document.createElement("span")) var headerNode = jQuery(document.createElement("span"))
.text(_this.getType() || "") .text(this.getType() || "")
.addClass("et2_caption") .addClass("et2_caption")
.appendTo(_this.placeDiv); .appendTo(this.placeDiv);
var attrsCntr = jQuery(document.createElement("span")) var attrsCntr = jQuery(document.createElement("span"))
.appendTo(_this.placeDiv) .appendTo(this.placeDiv)
.hide(); .hide();
headerNode.click(_this, function (e) { headerNode.click(this, function (e) {
e.data.visible = !e.data.visible; e.data.visible = !e.data.visible;
if (e.data.visible) { if (e.data.visible) {
attrsCntr.show(); attrsCntr.show();
@ -418,30 +384,28 @@ var et2_placeholder = /** @class */ (function (_super) {
attrsCntr.hide(); attrsCntr.hide();
} }
}); });
for (var key in _this.options) { for (var key in this.options) {
if (typeof _this.options[key] != "undefined") { if (typeof this.options[key] != "undefined") {
if (typeof _this.attrNodes[key] == "undefined") { if (typeof this.attrNodes[key] == "undefined") {
_this.attrNodes[key] = jQuery(document.createElement("span")) this.attrNodes[key] = jQuery(document.createElement("span"))
.addClass("et2_attr"); .addClass("et2_attr");
attrsCntr.append(_this.attrNodes[key]); attrsCntr.append(this.attrNodes[key]);
} }
_this.attrNodes[key].text(key + "=" + _this.options[key]); this.attrNodes[key].text(key + "=" + this.options[key]);
} }
} }
_this.setDOMNode(_this.placeDiv[0]); this.setDOMNode(this.placeDiv[0]);
return _this;
} }
et2_placeholder.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value"); _attrs.push("value");
}; }
et2_placeholder.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.placeDiv[0]]; return [this.placeDiv[0]];
}; }
et2_placeholder.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
this.placeDiv = jQuery(_nodes[0]); this.placeDiv = jQuery(_nodes[0]);
}; }
return et2_placeholder; }
}(et2_baseWidget));
// Register widget, but no tags // Register widget, but no tags
et2_core_widget_1.et2_register_widget(et2_placeholder, []); et2_register_widget(et2_placeholder, ['placeholder', 'placeholder_ro']);
//# sourceMappingURL=et2_core_baseWidget.js.map //# sourceMappingURL=et2_core_baseWidget.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
@ -14,11 +14,14 @@
et2_core_DOMWidget; et2_core_DOMWidget;
*/ */
import './et2_core_interfaces'; import {et2_IAligned, et2_IDetachedDOM} from "./et2_core_interfaces";
import './et2_core_common';
import {et2_DOMWidget} from './et2_core_DOMWidget'; import {et2_DOMWidget} from './et2_core_DOMWidget';
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget";
import {et2_no_init} from "./et2_core_common";
// fixing circular dependencies by only importing type
import type {et2_inputWidget} from "./et2_core_inputWidget";
import type {et2_valueWidget} from "./et2_core_valueWidget";
/** /**
* Class which manages the DOM node itself. The simpleWidget class is derrived * Class which manages the DOM node itself. The simpleWidget class is derrived
@ -467,7 +470,7 @@ et2_register_widget(et2_container, []);
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
class et2_placeholder extends et2_baseWidget implements et2_IDetachedDOM export class et2_placeholder extends et2_baseWidget implements et2_IDetachedDOM
{ {
/** /**
* he attrNodes object will hold the DOM nodes which represent the * he attrNodes object will hold the DOM nodes which represent the
@ -546,4 +549,4 @@ class et2_placeholder extends et2_baseWidget implements et2_IDetachedDOM
} }
} }
// Register widget, but no tags // Register widget, but no tags
et2_register_widget(et2_placeholder, []); et2_register_widget(et2_placeholder, ['placeholder', 'placeholder_ro']);

View File

@ -4,10 +4,11 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
*/ */
import { app, egw } from "../jsapi/egw_global";
/** /**
* IE Fix for array.indexOf * IE Fix for array.indexOf
*/ */
@ -23,13 +24,13 @@ if (typeof Array.prototype.indexOf == "undefined") {
/** /**
* Array with all types supported by the et2_checkType function. * Array with all types supported by the et2_checkType function.
*/ */
var et2_validTypes = ["boolean", "string", "rawstring", "html", "float", "integer", "any", "js", "dimension"]; export var et2_validTypes = ["boolean", "string", "rawstring", "html", "float", "integer", "any", "js", "dimension"];
/** /**
* Object whith default values for the above types. Do not specify array or * Object whith default values for the above types. Do not specify array or
* objects inside the et2_typeDefaults object, as this instance will be shared * objects inside the et2_typeDefaults object, as this instance will be shared
* between all users of it. * between all users of it.
*/ */
var et2_typeDefaults = { export var et2_typeDefaults = {
"boolean": false, "boolean": false,
"string": "", "string": "",
"rawstring": "", "rawstring": "",
@ -40,7 +41,7 @@ var et2_typeDefaults = {
"any": null, "any": null,
"dimension": "auto" "dimension": "auto"
}; };
function et2_evalBool(_val) { export function et2_evalBool(_val) {
if (typeof _val == "string") { if (typeof _val == "string") {
if (_val == "false" || _val == "0") { if (_val == "false" || _val == "0") {
return false; return false;
@ -53,7 +54,7 @@ function et2_evalBool(_val) {
* @param variable number of arguments to contact * @param variable number of arguments to contact
* @returns string * @returns string
*/ */
function et2_form_name(_cname, _name) { export function et2_form_name(_cname, _name) {
var parts = []; var parts = [];
for (var i = 0; i < arguments.length; ++i) { for (var i = 0; i < arguments.length; ++i) {
var name = arguments[i]; var name = arguments[i];
@ -75,7 +76,7 @@ function et2_form_name(_cname, _name) {
* @param string _attr attribute name * @param string _attr attribute name
* @param object _widget * @param object _widget
*/ */
function et2_checkType(_val, _type, _attr, _widget) { export function et2_checkType(_val, _type, _attr, _widget) {
if (typeof _attr == "undefined") { if (typeof _attr == "undefined") {
_attr = null; _attr = null;
} }
@ -206,7 +207,7 @@ function et2_checkType(_val, _type, _attr, _widget) {
* If et2_no_init is set as default value, the initAttributes function will not * If et2_no_init is set as default value, the initAttributes function will not
* try to initialize the attribute with the default value. * try to initialize the attribute with the default value.
*/ */
var et2_no_init = new Object(); export const et2_no_init = new Object();
/** /**
* Validates the given attribute with the given id. The validation checks for * Validates the given attribute with the given id. The validation checks for
* the existance of a human name, a description, a type and a default value. * the existance of a human name, a description, a type and a default value.
@ -214,7 +215,7 @@ var et2_no_init = new Object();
* empty string, the type defaults to any and the default to the corresponding * empty string, the type defaults to any and the default to the corresponding
* type default. * type default.
*/ */
function et2_validateAttrib(_id, _attrib) { export function et2_validateAttrib(_id, _attrib) {
// Default ignore to false. // Default ignore to false.
if (typeof _attrib["ignore"] == "undefined") { if (typeof _attrib["ignore"] == "undefined") {
_attrib["ignore"] = false; _attrib["ignore"] = false;
@ -250,7 +251,7 @@ function et2_validateAttrib(_id, _attrib) {
/** /**
* Equivalent to the PHP array_values function * Equivalent to the PHP array_values function
*/ */
function et2_arrayValues(_arr) { export function et2_arrayValues(_arr) {
var result = []; var result = [];
for (var key in _arr) { for (var key in _arr) {
// @ts-ignore we check key is an integer // @ts-ignore we check key is an integer
@ -263,14 +264,14 @@ function et2_arrayValues(_arr) {
/** /**
* Equivalent to the PHP array_keys function * Equivalent to the PHP array_keys function
*/ */
function et2_arrayKeys(_arr) { export function et2_arrayKeys(_arr) {
var result = []; var result = [];
for (var key in _arr) { for (var key in _arr) {
result.push(key); result.push(key);
} }
return result; return result;
} }
function et2_arrayIntKeys(_arr) { export function et2_arrayIntKeys(_arr) {
var result = []; var result = [];
for (var key in _arr) { for (var key in _arr) {
result.push(parseInt(key)); result.push(parseInt(key));
@ -281,7 +282,7 @@ function et2_arrayIntKeys(_arr) {
* Equivalent to the PHP substr function, partly take from phpjs, licensed under * Equivalent to the PHP substr function, partly take from phpjs, licensed under
* the GPL. * the GPL.
*/ */
function et2_substr(str, start, len) { export function et2_substr(str, start, len) {
var end = str.length; var end = str.length;
if (start < 0) { if (start < 0) {
start += end; start += end;
@ -306,7 +307,7 @@ function et2_substr(str, start, len) {
* @param string _enclosure='"' * @param string _enclosure='"'
* @return array * @return array
*/ */
function et2_csvSplit(_str, _num, _delimiter, _enclosure) { export function et2_csvSplit(_str, _num, _delimiter, _enclosure) {
// Default the parameters // Default the parameters
if (typeof _str == "undefined" || _str == null) { if (typeof _str == "undefined" || _str == null) {
_str = ""; _str = "";
@ -353,7 +354,7 @@ function et2_csvSplit(_str, _num, _delimiter, _enclosure) {
/** /**
* Parses the given string and returns an array marking parts which are URLs * Parses the given string and returns an array marking parts which are URLs
*/ */
function et2_activateLinks(_content) { export function et2_activateLinks(_content) {
var _match = false; var _match = false;
var arr = []; var arr = [];
function _splitPush(_matches, _proc) { function _splitPush(_matches, _proc) {
@ -427,7 +428,7 @@ function et2_activateLinks(_content) {
/** /**
* Inserts the structure generated by et2_activateLinks into the given DOM-Node * Inserts the structure generated by et2_activateLinks into the given DOM-Node
*/ */
function et2_insertLinkText(_text, _node, _target) { export function et2_insertLinkText(_text, _node, _target) {
if (!_node) { if (!_node) {
egw.debug("warn", "et2_insertLinkText called without node", _text, _node, _target); egw.debug("warn", "et2_insertLinkText called without node", _text, _node, _target);
return; return;
@ -476,7 +477,7 @@ function et2_insertLinkText(_text, _node, _target) {
/** /**
* Creates a copy of the given object (non recursive) * Creates a copy of the given object (non recursive)
*/ */
function et2_cloneObject(_obj) { export function et2_cloneObject(_obj) {
var result = {}; var result = {};
for (var key in _obj) { for (var key in _obj) {
result[key] = _obj[key]; result[key] = _obj[key];
@ -487,7 +488,7 @@ function et2_cloneObject(_obj) {
* Returns true if the given array of nodes or their children contains the given * Returns true if the given array of nodes or their children contains the given
* child node. * child node.
*/ */
function et2_hasChild(_nodes, _child) { export function et2_hasChild(_nodes, _child) {
for (var i = 0; i < _nodes.length; i++) { for (var i = 0; i < _nodes.length; i++) {
if (_nodes[i] == _child) { if (_nodes[i] == _child) {
return true; return true;
@ -510,7 +511,7 @@ function et2_hasChild(_nodes, _child) {
/** /**
* Returns an "range" object with the given top position and height * Returns an "range" object with the given top position and height
*/ */
function et2_range(_top, _height) { export function et2_range(_top, _height) {
return { return {
"top": _top, "top": _top,
"bottom": _top + _height "bottom": _top + _height
@ -519,7 +520,7 @@ function et2_range(_top, _height) {
/** /**
* Returns an "area" object with the given top- and bottom position * Returns an "area" object with the given top- and bottom position
*/ */
function et2_bounds(_top, _bottom) { export function et2_bounds(_top, _bottom) {
return { return {
"top": _top, "top": _top,
"bottom": _bottom "bottom": _bottom
@ -528,14 +529,14 @@ function et2_bounds(_top, _bottom) {
/** /**
* Returns whether two range objects intersect each other * Returns whether two range objects intersect each other
*/ */
function et2_rangeIntersect(_ar1, _ar2) { export function et2_rangeIntersect(_ar1, _ar2) {
return !(_ar1.bottom < _ar2.top || _ar1.top > _ar2.bottom); return !(_ar1.bottom < _ar2.top || _ar1.top > _ar2.bottom);
} }
/** /**
* Returns whether two ranges intersect (result = 0) or their relative position * Returns whether two ranges intersect (result = 0) or their relative position
* to each other (used to do a binary search inside a list of sorted range objects). * to each other (used to do a binary search inside a list of sorted range objects).
*/ */
function et2_rangeIntersectDir(_ar1, _ar2) { export function et2_rangeIntersectDir(_ar1, _ar2) {
if (_ar1.bottom < _ar2.top) { if (_ar1.bottom < _ar2.top) {
return -1; return -1;
} }
@ -547,13 +548,13 @@ function et2_rangeIntersectDir(_ar1, _ar2) {
/** /**
* Returns whether two ranges are equal. * Returns whether two ranges are equal.
*/ */
function et2_rangeEqual(_ar1, _ar2) { export function et2_rangeEqual(_ar1, _ar2) {
return _ar1.top === _ar2.top && _ar1.bottom === _ar2.bottom; return _ar1.top === _ar2.top && _ar1.bottom === _ar2.bottom;
} }
/** /**
* Substracts _ar2 from _ar1, returns an array of new ranges. * Substracts _ar2 from _ar1, returns an array of new ranges.
*/ */
function et2_rangeSubstract(_ar1, _ar2) { export function et2_rangeSubstract(_ar1, _ar2) {
// Per default return the complete _ar1 range // Per default return the complete _ar1 range
var res = [_ar1]; var res = [_ar1];
// Check whether there is an intersection between the given ranges // Check whether there is an intersection between the given ranges
@ -575,7 +576,7 @@ function et2_rangeSubstract(_ar1, _ar2) {
* @param {string} _str * @param {string} _str
* @returns {string} * @returns {string}
*/ */
function html_entity_decode(_str) { export function html_entity_decode(_str) {
return _str && _str.indexOf('&') != -1 ? jQuery('<span>' + _str + '</span>').text() : _str; return _str && _str.indexOf('&') != -1 ? jQuery('<span>' + _str + '</span>').text() : _str;
} }
//# sourceMappingURL=et2_core_common.js.map //# sourceMappingURL=et2_core_common.js.map

View File

@ -4,11 +4,13 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
*/ */
import {app, egw} from "../jsapi/egw_global";
/** /**
* IE Fix for array.indexOf * IE Fix for array.indexOf
*/ */
@ -27,14 +29,14 @@ if (typeof Array.prototype.indexOf == "undefined")
/** /**
* Array with all types supported by the et2_checkType function. * Array with all types supported by the et2_checkType function.
*/ */
var et2_validTypes = ["boolean", "string", "rawstring", "html", "float", "integer", "any", "js", "dimension"]; export var et2_validTypes = ["boolean", "string", "rawstring", "html", "float", "integer", "any", "js", "dimension"];
/** /**
* Object whith default values for the above types. Do not specify array or * Object whith default values for the above types. Do not specify array or
* objects inside the et2_typeDefaults object, as this instance will be shared * objects inside the et2_typeDefaults object, as this instance will be shared
* between all users of it. * between all users of it.
*/ */
var et2_typeDefaults : object = { export var et2_typeDefaults : object = {
"boolean": false, "boolean": false,
"string": "", "string": "",
"rawstring": "", // no html-entity decoding "rawstring": "", // no html-entity decoding
@ -46,7 +48,7 @@ var et2_typeDefaults : object = {
"dimension": "auto" "dimension": "auto"
}; };
function et2_evalBool(_val) export function et2_evalBool(_val)
{ {
if (typeof _val == "string") if (typeof _val == "string")
{ {
@ -64,7 +66,7 @@ function et2_evalBool(_val)
* @param variable number of arguments to contact * @param variable number of arguments to contact
* @returns string * @returns string
*/ */
function et2_form_name(_cname,_name) export function et2_form_name(_cname,_name)
{ {
var parts = []; var parts = [];
for(var i=0; i < arguments.length; ++i) for(var i=0; i < arguments.length; ++i)
@ -89,7 +91,7 @@ function et2_form_name(_cname,_name)
* @param string _attr attribute name * @param string _attr attribute name
* @param object _widget * @param object _widget
*/ */
function et2_checkType(_val, _type, _attr, _widget) export function et2_checkType(_val, _type, _attr, _widget)
{ {
if (typeof _attr == "undefined") if (typeof _attr == "undefined")
{ {
@ -273,7 +275,7 @@ function et2_checkType(_val, _type, _attr, _widget)
* If et2_no_init is set as default value, the initAttributes function will not * If et2_no_init is set as default value, the initAttributes function will not
* try to initialize the attribute with the default value. * try to initialize the attribute with the default value.
*/ */
const et2_no_init = new Object(); export const et2_no_init = new Object();
/** /**
* Validates the given attribute with the given id. The validation checks for * Validates the given attribute with the given id. The validation checks for
@ -282,7 +284,7 @@ const et2_no_init = new Object();
* empty string, the type defaults to any and the default to the corresponding * empty string, the type defaults to any and the default to the corresponding
* type default. * type default.
*/ */
function et2_validateAttrib(_id, _attrib) export function et2_validateAttrib(_id, _attrib)
{ {
// Default ignore to false. // Default ignore to false.
if (typeof _attrib["ignore"] == "undefined") if (typeof _attrib["ignore"] == "undefined")
@ -333,7 +335,7 @@ function et2_validateAttrib(_id, _attrib)
/** /**
* Equivalent to the PHP array_values function * Equivalent to the PHP array_values function
*/ */
function et2_arrayValues(_arr) export function et2_arrayValues(_arr)
{ {
var result = []; var result = [];
for (var key in _arr) for (var key in _arr)
@ -351,7 +353,7 @@ function et2_arrayValues(_arr)
/** /**
* Equivalent to the PHP array_keys function * Equivalent to the PHP array_keys function
*/ */
function et2_arrayKeys(_arr) export function et2_arrayKeys(_arr)
{ {
var result = []; var result = [];
for (var key in _arr) for (var key in _arr)
@ -362,7 +364,7 @@ function et2_arrayKeys(_arr)
return result; return result;
} }
function et2_arrayIntKeys(_arr) export function et2_arrayIntKeys(_arr)
{ {
var result = []; var result = [];
for (var key in _arr) for (var key in _arr)
@ -378,7 +380,7 @@ function et2_arrayIntKeys(_arr)
* Equivalent to the PHP substr function, partly take from phpjs, licensed under * Equivalent to the PHP substr function, partly take from phpjs, licensed under
* the GPL. * the GPL.
*/ */
function et2_substr (str, start, len) { export function et2_substr (str, start, len) {
var end = str.length; var end = str.length;
if (start < 0) if (start < 0)
@ -407,7 +409,7 @@ function et2_substr (str, start, len) {
* @param string _enclosure='"' * @param string _enclosure='"'
* @return array * @return array
*/ */
function et2_csvSplit(_str : string, _num? : number, _delimiter? : string, _enclosure? : string) export function et2_csvSplit(_str : string, _num? : number, _delimiter? : string, _enclosure? : string)
{ {
// Default the parameters // Default the parameters
if (typeof _str == "undefined" || _str == null) if (typeof _str == "undefined" || _str == null)
@ -474,7 +476,7 @@ function et2_csvSplit(_str : string, _num? : number, _delimiter? : string, _encl
/** /**
* Parses the given string and returns an array marking parts which are URLs * Parses the given string and returns an array marking parts which are URLs
*/ */
function et2_activateLinks(_content) export function et2_activateLinks(_content)
{ {
var _match = false; var _match = false;
var arr = []; var arr = [];
@ -572,7 +574,7 @@ function et2_activateLinks(_content)
/** /**
* Inserts the structure generated by et2_activateLinks into the given DOM-Node * Inserts the structure generated by et2_activateLinks into the given DOM-Node
*/ */
function et2_insertLinkText(_text, _node, _target) export function et2_insertLinkText(_text, _node, _target)
{ {
if(!_node) if(!_node)
{ {
@ -640,7 +642,7 @@ function et2_insertLinkText(_text, _node, _target)
/** /**
* Creates a copy of the given object (non recursive) * Creates a copy of the given object (non recursive)
*/ */
function et2_cloneObject(_obj) export function et2_cloneObject(_obj)
{ {
var result = {}; var result = {};
@ -656,7 +658,7 @@ function et2_cloneObject(_obj)
* Returns true if the given array of nodes or their children contains the given * Returns true if the given array of nodes or their children contains the given
* child node. * child node.
*/ */
function et2_hasChild(_nodes, _child) export function et2_hasChild(_nodes, _child)
{ {
for (var i = 0; i < _nodes.length; i++) for (var i = 0; i < _nodes.length; i++)
{ {
@ -689,7 +691,7 @@ function et2_hasChild(_nodes, _child)
/** /**
* Returns an "range" object with the given top position and height * Returns an "range" object with the given top position and height
*/ */
function et2_range(_top, _height) export function et2_range(_top, _height)
{ {
return { return {
"top": _top, "top": _top,
@ -700,7 +702,7 @@ function et2_range(_top, _height)
/** /**
* Returns an "area" object with the given top- and bottom position * Returns an "area" object with the given top- and bottom position
*/ */
function et2_bounds(_top, _bottom) export function et2_bounds(_top, _bottom)
{ {
return { return {
"top": _top, "top": _top,
@ -711,7 +713,7 @@ function et2_bounds(_top, _bottom)
/** /**
* Returns whether two range objects intersect each other * Returns whether two range objects intersect each other
*/ */
function et2_rangeIntersect(_ar1, _ar2) export function et2_rangeIntersect(_ar1, _ar2)
{ {
return ! (_ar1.bottom < _ar2.top || _ar1.top > _ar2.bottom); return ! (_ar1.bottom < _ar2.top || _ar1.top > _ar2.bottom);
} }
@ -720,7 +722,7 @@ function et2_rangeIntersect(_ar1, _ar2)
* Returns whether two ranges intersect (result = 0) or their relative position * Returns whether two ranges intersect (result = 0) or their relative position
* to each other (used to do a binary search inside a list of sorted range objects). * to each other (used to do a binary search inside a list of sorted range objects).
*/ */
function et2_rangeIntersectDir(_ar1, _ar2) export function et2_rangeIntersectDir(_ar1, _ar2)
{ {
if (_ar1.bottom < _ar2.top) if (_ar1.bottom < _ar2.top)
{ {
@ -736,7 +738,7 @@ function et2_rangeIntersectDir(_ar1, _ar2)
/** /**
* Returns whether two ranges are equal. * Returns whether two ranges are equal.
*/ */
function et2_rangeEqual(_ar1, _ar2) export function et2_rangeEqual(_ar1, _ar2)
{ {
return _ar1.top === _ar2.top && _ar1.bottom === _ar2.bottom; return _ar1.top === _ar2.top && _ar1.bottom === _ar2.bottom;
} }
@ -744,7 +746,7 @@ function et2_rangeEqual(_ar1, _ar2)
/** /**
* Substracts _ar2 from _ar1, returns an array of new ranges. * Substracts _ar2 from _ar1, returns an array of new ranges.
*/ */
function et2_rangeSubstract(_ar1, _ar2) export function et2_rangeSubstract(_ar1, _ar2)
{ {
// Per default return the complete _ar1 range // Per default return the complete _ar1 range
var res = [_ar1]; var res = [_ar1];
@ -774,7 +776,7 @@ function et2_rangeSubstract(_ar1, _ar2)
* @param {string} _str * @param {string} _str
* @returns {string} * @returns {string}
*/ */
function html_entity_decode(_str) export function html_entity_decode(_str)
{ {
return _str && _str.indexOf('&') != -1 ? jQuery('<span>'+_str+'</span>').text() : _str; return _str && _str.indexOf('&') != -1 ? jQuery('<span>'+_str+'</span>').text() : _str;
} }

View File

@ -1,33 +1,19 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Widget base class * EGroupware eTemplate2 - JS Widget base class
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_editableWidget = void 0;
/*egw:uses /*egw:uses
et2_core_inputWidget; et2_core_inputWidget;
*/ */
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_no_init } from "./et2_core_common";
import { egw } from "../jsapi/egw_global";
/** /**
* et2_editableWidget derives from et2_inputWidget and adds the ability to start * et2_editableWidget derives from et2_inputWidget and adds the ability to start
* readonly, then turn editable on double-click. If we decide to do this with * readonly, then turn editable on double-click. If we decide to do this with
@ -35,42 +21,39 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_editableWidget = /** @class */ (function (_super) { export class et2_editableWidget extends et2_inputWidget {
__extends(et2_editableWidget, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_editableWidget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this = this;
// 'Editable' really should be boolean for everything else to work // 'Editable' really should be boolean for everything else to work
if (_attrs.readonly && typeof _attrs.readonly === 'string') { if (_attrs.readonly && typeof _attrs.readonly === 'string') {
_attrs.readonly = true; _attrs.readonly = true;
var toggle_readonly = _attrs.toggle_readonly; var toggle_readonly = _attrs.toggle_readonly;
} }
// Call the inherited constructor // Call the inherited constructor
_this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_editableWidget._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_editableWidget._attributes, _child || {}));
if (typeof toggle_readonly != 'undefined') if (typeof toggle_readonly != 'undefined')
_this._toggle_readonly = toggle_readonly; this._toggle_readonly = toggle_readonly;
return _this;
} }
et2_editableWidget.prototype.destroy = function () { destroy() {
var node = this.getInputNode(); let node = this.getInputNode();
if (node) { if (node) {
jQuery(node).off('.et2_editableWidget'); jQuery(node).off('.et2_editableWidget');
} }
_super.prototype.destroy.call(this); super.destroy();
}; }
/** /**
* Load the validation errors from the server * Load the validation errors from the server
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_editableWidget.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
}; }
et2_editableWidget.prototype.attachToDOM = function () { attachToDOM() {
var res = _super.prototype.attachToDOM.call(this); let res = super.attachToDOM();
var node = this.getDOMNode(); let node = this.getDOMNode();
if (node && this._toggle_readonly) { if (node && this._toggle_readonly) {
jQuery(node) jQuery(node)
.off('.et2_editableWidget') .off('.et2_editableWidget')
@ -83,10 +66,10 @@ var et2_editableWidget = /** @class */ (function (_super) {
jQuery(node).addClass('et2_editable_readonly'); jQuery(node).addClass('et2_editable_readonly');
} }
return res; return res;
}; }
et2_editableWidget.prototype.detatchFromDOM = function () { detatchFromDOM() {
_super.prototype.detatchFromDOM.call(this); super.detatchFromDOM();
}; }
/** /**
* Handle double click * Handle double click
* *
@ -94,7 +77,7 @@ var et2_editableWidget = /** @class */ (function (_super) {
* *
* @param {DOMNode} _node * @param {DOMNode} _node
*/ */
et2_editableWidget.prototype.dblclick = function (_node) { dblclick(_node) {
// Turn off readonly // Turn off readonly
this.set_readonly(false); this.set_readonly(false);
jQuery('body').on("click.et2_editableWidget", this, function (e) { jQuery('body').on("click.et2_editableWidget", this, function (e) {
@ -104,14 +87,14 @@ var et2_editableWidget = /** @class */ (function (_super) {
e.data.focusout.call(e.data, this); e.data.focusout.call(e.data, this);
} }
}); });
}; }
/** /**
* User clicked somewhere else, save and turn back to readonly * User clicked somewhere else, save and turn back to readonly
* *
* @param {DOMNode} _node Body node * @param {DOMNode} _node Body node
* @returns {et2_core_editableWidgetet2_editableWidget.et2_core_editableWidgetAnonym$0@call;getInstanceManager@call;submit} * @returns {et2_core_editableWidgetet2_editableWidget.et2_core_editableWidgetAnonym$0@call;getInstanceManager@call;submit}
*/ */
et2_editableWidget.prototype.focusout = function (_node) { focusout(_node) {
var value = this.get_value(); var value = this.get_value();
var oldValue = this._oldValue; var oldValue = this._oldValue;
// Change back to readonly // Change back to readonly
@ -132,7 +115,7 @@ var et2_editableWidget = /** @class */ (function (_super) {
this.set_value(value); this.set_value(value);
return this.getInstanceManager().submit(); return this.getInstanceManager().submit();
} }
}; }
/** /**
* Called whenever the template gets submitted. * Called whenever the template gets submitted.
* If we have a save_callback, we call that before the submit (no check on * If we have a save_callback, we call that before the submit (no check on
@ -141,7 +124,7 @@ var et2_editableWidget = /** @class */ (function (_super) {
* @param _values contains the values which will be sent to the server. * @param _values contains the values which will be sent to the server.
* Listeners may change these values before they get submitted. * Listeners may change these values before they get submitted.
*/ */
et2_editableWidget.prototype.submit = function (_values) { submit(_values) {
if (this.options.readonly) { if (this.options.readonly) {
// Not currently editing, just continue on // Not currently editing, just continue on
return true; return true;
@ -157,8 +140,9 @@ var et2_editableWidget = /** @class */ (function (_super) {
}, this, true, this).sendRequest(); }, this, true, this).sendRequest();
} }
return true; return true;
}; }
et2_editableWidget._attributes = { }
et2_editableWidget._attributes = {
readonly: { readonly: {
name: "readonly", name: "readonly",
type: "string", type: "string",
@ -189,8 +173,5 @@ var et2_editableWidget = /** @class */ (function (_super) {
description: "Set height for widget while in edit mode", description: "Set height for widget while in edit mode",
type: "string" type: "string"
} }
}; };
return et2_editableWidget;
}(et2_core_inputWidget_1.et2_inputWidget));
exports.et2_editableWidget = et2_editableWidget;
//# sourceMappingURL=et2_core_editableWidget.js.map //# sourceMappingURL=et2_core_editableWidget.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
*/ */
@ -15,6 +15,9 @@
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {WidgetConfig} from "./et2_core_widget"; import {WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_no_init} from "./et2_core_common";
import {egw} from "../jsapi/egw_global";
import {et2_ISubmitListener} from "./et2_core_interfaces";
/** /**
* et2_editableWidget derives from et2_inputWidget and adds the ability to start * et2_editableWidget derives from et2_inputWidget and adds the ability to start

View File

@ -1,4 +1,3 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS code for implementing inheritance with attributes * EGroupware eTemplate2 - JS code for implementing inheritance with attributes
* *
@ -8,16 +7,13 @@
* @link: https://www.egroupware.org * @link: https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClassWithAttributes = void 0;
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
*/ */
require("../jsapi/egw_global"); import { egw } from "../jsapi/egw_global";
require("et2_core_common"); import { et2_checkType, et2_no_init, et2_validateAttrib } from "./et2_core_common";
var ClassWithAttributes = /** @class */ (function () { import { et2_implements_registry } from "./et2_core_interfaces";
function ClassWithAttributes() { export class ClassWithAttributes {
}
/** /**
* Returns the value of the given attribute. If the property does not * Returns the value of the given attribute. If the property does not
* exist, an error message is issued. * exist, an error message is issued.
@ -25,7 +21,7 @@ var ClassWithAttributes = /** @class */ (function () {
* @param {string} _name * @param {string} _name
* @return {*} * @return {*}
*/ */
ClassWithAttributes.prototype.getAttribute = function (_name) { getAttribute(_name) {
if (typeof this.attributes[_name] != "undefined" && if (typeof this.attributes[_name] != "undefined" &&
!this.attributes[_name].ignore) { !this.attributes[_name].ignore) {
if (typeof this["get_" + _name] == "function") { if (typeof this["get_" + _name] == "function") {
@ -38,7 +34,7 @@ var ClassWithAttributes = /** @class */ (function () {
else { else {
egw.debug("error", this, "Attribute '" + _name + "' does not exist!"); egw.debug("error", this, "Attribute '" + _name + "' does not exist!");
} }
}; }
/** /**
* The setAttribute function sets the attribute with the given name to * The setAttribute function sets the attribute with the given name to
* the given value. _override defines, whether this[_name] will be set, * the given value. _override defines, whether this[_name] will be set,
@ -49,7 +45,7 @@ var ClassWithAttributes = /** @class */ (function () {
* @param {*} _value * @param {*} _value
* @param {boolean} _override * @param {boolean} _override
*/ */
ClassWithAttributes.prototype.setAttribute = function (_name, _value, _override) { setAttribute(_name, _value, _override) {
if (typeof this.attributes[_name] != "undefined") { if (typeof this.attributes[_name] != "undefined") {
if (!this.attributes[_name].ignore) { if (!this.attributes[_name].ignore) {
if (typeof _override == "undefined") { if (typeof _override == "undefined") {
@ -67,7 +63,7 @@ var ClassWithAttributes = /** @class */ (function () {
else { else {
egw.debug("warn", this, "Attribute '" + _name + "' does not exist!"); egw.debug("warn", this, "Attribute '" + _name + "' does not exist!");
} }
}; }
/** /**
* generateAttributeSet sanitizes the given associative array of attributes * generateAttributeSet sanitizes the given associative array of attributes
* (by passing each entry to "et2_checkType" and checking for existance of * (by passing each entry to "et2_checkType" and checking for existance of
@ -75,7 +71,7 @@ var ClassWithAttributes = /** @class */ (function () {
* *
* @param {object} _attrs is the associative array containing the attributes. * @param {object} _attrs is the associative array containing the attributes.
*/ */
ClassWithAttributes.generateAttributeSet = function (widget, _attrs) { static generateAttributeSet(widget, _attrs) {
// Sanity check and validation // Sanity check and validation
for (var key in _attrs) { for (var key in _attrs) {
if (typeof widget[key] != "undefined") { if (typeof widget[key] != "undefined") {
@ -101,7 +97,7 @@ var ClassWithAttributes = /** @class */ (function () {
} }
} }
return _attrs; return _attrs;
}; }
/** /**
* The initAttributes function sets the attributes to their default * The initAttributes function sets the attributes to their default
* values. The attributes are not overwritten, which means, that the * values. The attributes are not overwritten, which means, that the
@ -110,27 +106,27 @@ var ClassWithAttributes = /** @class */ (function () {
* *
* @param {object} _attrs is the associative array containing the attributes. * @param {object} _attrs is the associative array containing the attributes.
*/ */
ClassWithAttributes.prototype.initAttributes = function (_attrs) { initAttributes(_attrs) {
for (var key in _attrs) { for (var key in _attrs) {
if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) { if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) {
this.setAttribute(key, _attrs[key], false); this.setAttribute(key, _attrs[key], false);
} }
} }
}; }
ClassWithAttributes.buildAttributes = function (class_prototype) { static buildAttributes(class_prototype) {
var class_tree = []; let class_tree = [];
var attributes = {}; let attributes = {};
var n = 0; let n = 0;
do { do {
n++; n++;
class_tree.push(class_prototype); class_tree.push(class_prototype);
class_prototype = Object.getPrototypeOf(class_prototype); class_prototype = Object.getPrototypeOf(class_prototype);
} while (class_prototype !== ClassWithAttributes && n < 50); } while (class_prototype !== ClassWithAttributes && n < 50);
for (var i = class_tree.length - 1; i >= 0; i--) { for (let i = class_tree.length - 1; i >= 0; i--) {
attributes = ClassWithAttributes.extendAttributes(attributes, class_tree[i]._attributes); attributes = ClassWithAttributes.extendAttributes(attributes, class_tree[i]._attributes);
} }
return attributes; return attributes;
}; }
/** /**
* Extend current _attributes with the one from the parent class * Extend current _attributes with the one from the parent class
* *
@ -139,7 +135,7 @@ var ClassWithAttributes = /** @class */ (function () {
* @param _attributes * @param _attributes
* @param _parent * @param _parent
*/ */
ClassWithAttributes.extendAttributes = function (_parent, _attributes) { static extendAttributes(_parent, _attributes) {
function _copyMerge(_new, _old) { function _copyMerge(_new, _old) {
var result = {}; var result = {};
// Copy the new object // Copy the new object
@ -172,7 +168,7 @@ var ClassWithAttributes = /** @class */ (function () {
et2_validateAttrib(key, attributes[key]); et2_validateAttrib(key, attributes[key]);
} }
return attributes; return attributes;
}; }
/** /**
* The implements function can be used to check whether the object * The implements function can be used to check whether the object
* implements the given interface. * implements the given interface.
@ -183,25 +179,23 @@ var ClassWithAttributes = /** @class */ (function () {
* *
* @param _iface name of interface to check * @param _iface name of interface to check
*/ */
ClassWithAttributes.prototype.implements = function (_iface_name) { implements(_iface_name) {
if (typeof window['implements_' + _iface_name] === 'function' && if (typeof et2_implements_registry[_iface_name] === 'function' &&
window['implements_' + _iface_name](this)) { et2_implements_registry[_iface_name](this)) {
return true; return true;
} }
return false; return false;
}; }
/** /**
* Check if object is an instance of a class or implements an interface (specified by the interfaces name) * Check if object is an instance of a class or implements an interface (specified by the interfaces name)
* *
* @param _class_or_interfacename class(-name) or string with name of interface * @param _class_or_interfacename class(-name) or string with name of interface
*/ */
ClassWithAttributes.prototype.instanceOf = function (_class_or_interfacename) { instanceOf(_class_or_interfacename) {
if (typeof _class_or_interfacename === 'string') { if (typeof _class_or_interfacename === 'string') {
return this.implements(_class_or_interfacename); return this.implements(_class_or_interfacename);
} }
return this instanceof _class_or_interfacename; return this instanceof _class_or_interfacename;
}; }
return ClassWithAttributes; }
}());
exports.ClassWithAttributes = ClassWithAttributes;
//# sourceMappingURL=et2_core_inheritance.js.map //# sourceMappingURL=et2_core_inheritance.js.map

View File

@ -12,8 +12,9 @@
et2_core_common; et2_core_common;
*/ */
import '../jsapi/egw_global'; import {egw} from "../jsapi/egw_global";
import 'et2_core_common'; import {et2_checkType, et2_no_init, et2_validateAttrib} from "./et2_core_common";
import {et2_implements_registry} from "./et2_core_interfaces";
export class ClassWithAttributes export class ClassWithAttributes
{ {
@ -245,8 +246,8 @@ export class ClassWithAttributes
*/ */
implements (_iface_name : string) implements (_iface_name : string)
{ {
if (typeof window['implements_'+_iface_name] === 'function' && if (typeof et2_implements_registry[_iface_name] === 'function' &&
window['implements_'+_iface_name](this)) et2_implements_registry[_iface_name](this))
{ {
return true return true
} }

View File

@ -1,79 +1,61 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Widget base class * EGroupware eTemplate2 - JS Widget base class
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_inputWidget = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_interfaces; et2_core_interfaces;
et2_core_valueWidget; et2_core_valueWidget;
*/ */
require("./et2_core_common"); import { et2_no_init } from "./et2_core_common";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from './et2_core_valueWidget';
import { et2_compileLegacyJS } from "./et2_core_legacyJSFunctions";
/** /**
* et2_inputWidget derrives from et2_simpleWidget and implements the IInput * et2_inputWidget derrives from et2_simpleWidget and implements the IInput
* interface. When derriving from this class, call setDOMNode with an input * interface. When derriving from this class, call setDOMNode with an input
* DOMNode. * DOMNode.
*/ */
var et2_inputWidget = /** @class */ (function (_super) { export class et2_inputWidget extends et2_valueWidget {
__extends(et2_inputWidget, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_inputWidget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_inputWidget._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_inputWidget._attributes, _child || {}));
// mark value as not initialised, so set_value can determine if it is necessary to trigger change event // mark value as not initialised, so set_value can determine if it is necessary to trigger change event
_this._oldValue = et2_no_init; this._oldValue = et2_no_init;
_this._labelContainer = null; this._labelContainer = null;
return _this;
} }
et2_inputWidget.prototype.destroy = function () { destroy() {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
jQuery(node).unbind("change.et2_inputWidget"); jQuery(node).unbind("change.et2_inputWidget");
jQuery(node).unbind("focus"); jQuery(node).unbind("focus");
} }
_super.prototype.destroy.call(this); super.destroy();
this._labelContainer = null; this._labelContainer = null;
}; }
/** /**
* Make sure dirty flag is properly set * Make sure dirty flag is properly set
*/ */
et2_inputWidget.prototype.doLoadingFinished = function () { doLoadingFinished() {
var result = _super.prototype.doLoadingFinished.call(this); let result = super.doLoadingFinished();
this.resetDirty(); this.resetDirty();
return result; return result;
}; }
/** /**
* Load the validation errors from the server * Load the validation errors from the server
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_inputWidget.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
// Check whether an validation error entry exists // Check whether an validation error entry exists
if (this.id && this.getArrayMgr("validation_errors")) { if (this.id && this.getArrayMgr("validation_errors")) {
var val = this.getArrayMgr("validation_errors").getEntry(this.id); var val = this.getArrayMgr("validation_errors").getEntry(this.id);
@ -81,8 +63,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
_attrs["validation_error"] = val; _attrs["validation_error"] = val;
} }
} }
}; }
et2_inputWidget.prototype.attachToDOM = function () { attachToDOM() {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
jQuery(node) jQuery(node)
@ -94,17 +76,17 @@ var et2_inputWidget = /** @class */ (function (_super) {
e.data.focus.call(e.data, this); e.data.focus.call(e.data, this);
}); });
} }
return _super.prototype.attachToDOM.call(this); return super.attachToDOM();
// jQuery(this.getInputNode()).attr("novalidate","novalidate"); // Stop browser from getting involved // jQuery(this.getInputNode()).attr("novalidate","novalidate"); // Stop browser from getting involved
// jQuery(this.getInputNode()).validator(); // jQuery(this.getInputNode()).validator();
}; }
et2_inputWidget.prototype.detatchFromDOM = function () { detatchFromDOM() {
// if(this.getInputNode()) { // if(this.getInputNode()) {
// jQuery(this.getInputNode()).data("validator").destroy(); // jQuery(this.getInputNode()).data("validator").destroy();
// } // }
_super.prototype.detachFromDOM.call(this); super.detachFromDOM();
}; }
et2_inputWidget.prototype.change = function (_node, _widget, _value) { change(_node, _widget, _value) {
var messages = []; var messages = [];
var valid = this.isValid(messages); var valid = this.isValid(messages);
// Passing false will clear any set messages // Passing false will clear any set messages
@ -122,8 +104,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
} }
} }
return valid; return valid;
}; }
et2_inputWidget.prototype.focus = function (_node) { focus(_node) {
if (typeof this.options.onfocus == 'function') { if (typeof this.options.onfocus == 'function') {
// Make sure function gets a reference to the widget // Make sure function gets a reference to the widget
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
@ -131,7 +113,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
args.push(this); args.push(this);
return this.options.onfocus.apply(this, args); return this.options.onfocus.apply(this, args);
} }
}; }
/** /**
* Set value of widget and trigger for real changes a change event * Set value of widget and trigger for real changes a change event
* *
@ -139,7 +121,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
* *
* @param {string} _value value to set * @param {string} _value value to set
*/ */
et2_inputWidget.prototype.set_value = function (_value) { set_value(_value) {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
jQuery(node).val(_value); jQuery(node).val(_value);
@ -148,8 +130,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
} }
} }
this._oldValue = _value; this._oldValue = _value;
}; }
et2_inputWidget.prototype.set_id = function (_value) { set_id(_value) {
this.id = _value; this.id = _value;
this.dom_id = _value && this.getInstanceManager() ? this.getInstanceManager().uniqueId + '_' + this.id : _value; this.dom_id = _value && this.getInstanceManager() ? this.getInstanceManager().uniqueId + '_' + this.id : _value;
// Set the id of the _input_ node (in contrast to the default // Set the id of the _input_ node (in contrast to the default
@ -166,8 +148,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
node.removeAttribute("name"); node.removeAttribute("name");
} }
} }
}; }
et2_inputWidget.prototype.set_needed = function (_value) { set_needed(_value) {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
if (_value && !this.options.readonly) { if (_value && !this.options.readonly) {
@ -177,8 +159,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
node.removeAttribute("required"); node.removeAttribute("required");
} }
} }
}; }
et2_inputWidget.prototype.set_validation_error = function (_value) { set_validation_error(_value) {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
if (_value === false) { if (_value === false) {
@ -189,7 +171,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
this.showMessage(_value, "validation_error"); this.showMessage(_value, "validation_error");
jQuery(node).addClass("invalid"); jQuery(node).addClass("invalid");
// If on a tab, switch to that tab so user can see it // If on a tab, switch to that tab so user can see it
var widget = this; let widget = this;
while (widget.getParent() && widget.getType() != 'tabbox') { while (widget.getParent() && widget.getType() != 'tabbox') {
widget = widget.getParent(); widget = widget.getParent();
} }
@ -197,31 +179,31 @@ var et2_inputWidget = /** @class */ (function (_super) {
widget.activateTab(this); widget.activateTab(this);
} }
} }
}; }
/** /**
* Set tab index * Set tab index
* *
* @param {number} index * @param {number} index
*/ */
et2_inputWidget.prototype.set_tabindex = function (index) { set_tabindex(index) {
jQuery(this.getInputNode()).attr("tabindex", index); jQuery(this.getInputNode()).attr("tabindex", index);
}; }
et2_inputWidget.prototype.getInputNode = function () { getInputNode() {
return this.node; return this.node;
}; }
et2_inputWidget.prototype.get_value = function () { get_value() {
return this.getValue(); return this.getValue();
}; }
et2_inputWidget.prototype.getValue = function () { getValue() {
var node = this.getInputNode(); var node = this.getInputNode();
if (node) { if (node) {
var val = jQuery(node).val(); var val = jQuery(node).val();
return val; return val;
} }
return this._oldValue; return this._oldValue;
}; }
et2_inputWidget.prototype.isDirty = function () { isDirty() {
var value = this.getValue(); let value = this.getValue();
if (typeof value !== typeof this._oldValue) { if (typeof value !== typeof this._oldValue) {
return true; return true;
} }
@ -234,7 +216,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
this._oldValue.length !== value.length) { this._oldValue.length !== value.length) {
return true; return true;
} }
for (var key in this._oldValue) { for (let key in this._oldValue) {
if (this._oldValue[key] !== value[key]) if (this._oldValue[key] !== value[key])
return true; return true;
} }
@ -242,11 +224,11 @@ var et2_inputWidget = /** @class */ (function (_super) {
default: default:
return this._oldValue != value; return this._oldValue != value;
} }
}; }
et2_inputWidget.prototype.resetDirty = function () { resetDirty() {
this._oldValue = this.getValue(); this._oldValue = this.getValue();
}; }
et2_inputWidget.prototype.isValid = function (messages) { isValid(messages) {
var ok = true; var ok = true;
// Check for required // Check for required
if (this.options && this.options.needed && !this.options.readonly && !this.disabled && if (this.options && this.options.needed && !this.options.readonly && !this.disabled &&
@ -255,7 +237,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
ok = false; ok = false;
} }
return ok; return ok;
}; }
/** /**
* Called whenever the template gets submitted. We return false if the widget * Called whenever the template gets submitted. We return false if the widget
* is not valid, which cancels the submission. * is not valid, which cancels the submission.
@ -263,14 +245,15 @@ var et2_inputWidget = /** @class */ (function (_super) {
* @param _values contains the values which will be sent to the server. * @param _values contains the values which will be sent to the server.
* Listeners may change these values before they get submitted. * Listeners may change these values before they get submitted.
*/ */
et2_inputWidget.prototype.submit = function (_values) { submit(_values) {
var messages = []; var messages = [];
var valid = this.isValid(messages); var valid = this.isValid(messages);
// Passing false will clear any set messages // Passing false will clear any set messages
this.set_validation_error(valid ? false : messages); this.set_validation_error(valid ? false : messages);
return valid; return valid;
}; }
et2_inputWidget._attributes = { }
et2_inputWidget._attributes = {
"needed": { "needed": {
"name": "Required", "name": "Required",
"default": false, "default": false,
@ -307,8 +290,5 @@ var et2_inputWidget = /** @class */ (function (_super) {
"default": false, "default": false,
description: "Does NOT allow user to enter data, just displays existing data" description: "Does NOT allow user to enter data, just displays existing data"
} }
}; };
return et2_inputWidget;
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_inputWidget = et2_inputWidget;
//# sourceMappingURL=et2_core_inputWidget.js.map //# sourceMappingURL=et2_core_inputWidget.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
@ -14,18 +14,24 @@
et2_core_valueWidget; et2_core_valueWidget;
*/ */
import './et2_core_common'; import {et2_no_init} from "./et2_core_common";
import { ClassWithAttributes } from "./et2_core_inheritance"; import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_widget, et2_createWidget, et2_register_widget, WidgetConfig } from "./et2_core_widget"; import { et2_widget, WidgetConfig } from "./et2_core_widget";
import { et2_DOMWidget } from './et2_core_DOMWidget'
import { et2_valueWidget } from './et2_core_valueWidget' import { et2_valueWidget } from './et2_core_valueWidget'
import {et2_IInput, et2_ISubmitListener} from "./et2_core_interfaces";
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
// fixing circular dependencies by only importing the type (not in compiled .js)
import type {et2_tabbox} from "./et2_widget_tabs";
export interface et2_input {
getInputNode() : HTMLInputElement|HTMLElement;
}
/** /**
* et2_inputWidget derrives from et2_simpleWidget and implements the IInput * et2_inputWidget derrives from et2_simpleWidget and implements the IInput
* interface. When derriving from this class, call setDOMNode with an input * interface. When derriving from this class, call setDOMNode with an input
* DOMNode. * DOMNode.
*/ */
export class et2_inputWidget extends et2_valueWidget implements et2_IInput, et2_ISubmitListener export class et2_inputWidget extends et2_valueWidget implements et2_IInput, et2_ISubmitListener, et2_input
{ {
static readonly _attributes : any = { static readonly _attributes : any = {
"needed": { "needed": {

View File

@ -4,53 +4,58 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
export var et2_implements_registry = {};
/** /**
* Checks if an object / et2_widget implements given methods * Checks if an object / et2_widget implements given methods
* *
* @param obj * @param obj
* @param methods * @param methods
*/ */
function implements_methods(obj, methods) { export function implements_methods(obj, methods) {
for (var i = 0; i < methods.length; ++i) { for (let i = 0; i < methods.length; ++i) {
if (typeof obj[methods[i]] !== 'function') { if (typeof obj[methods[i]] !== 'function') {
return false; return false;
} }
} }
return true; return true;
} }
var et2_IDOMNode = "et2_IDOMNode"; export const et2_IDOMNode = "et2_IDOMNode";
function implements_et2_IDOMNode(obj) { et2_implements_registry.et2_IDOMNode = function (obj) {
return implements_methods(obj, ["getDOMNode"]); return implements_methods(obj, ["getDOMNode"]);
} };
var et2_IInput = "et2_IInput"; export const et2_IInputNode = "et2_IInputNode";
function implements_et2_IInput(obj) { et2_implements_registry.et2_IInputNode = function (obj) {
return implements_methods(obj, ["getInputNode"]);
};
export const et2_IInput = "et2_IInput";
et2_implements_registry.et2_IInput = function (obj) {
return implements_methods(obj, ["getValue", "isDirty", "resetDirty", "isValid"]); return implements_methods(obj, ["getValue", "isDirty", "resetDirty", "isValid"]);
} };
var et2_IResizeable = "et2_IResizeable"; export const et2_IResizeable = "et2_IResizeable";
function implements_et2_IResizeable(obj) { et2_implements_registry.et2_IResizeable = function (obj) {
return implements_methods(obj, ["resize"]); return implements_methods(obj, ["resize"]);
} };
var et2_IAligned = "et2_IAligned"; export const et2_IAligned = "et2_IAligned";
function implements_et2_IAligned(obj) { et2_implements_registry.et2_IAligned = function (obj) {
return implements_methods(obj, ["get_align"]); return implements_methods(obj, ["get_align"]);
} };
var et2_ISubmitListener = "et2_ISubmitListener"; export const et2_ISubmitListener = "et2_ISubmitListener";
function implements_et2_ISubmitListener(obj) { et2_implements_registry.et2_ISubmitListener = function (obj) {
return implements_methods(obj, ["submit"]); return implements_methods(obj, ["submit"]);
} };
var et2_IDetachedDOM = "et2_IDetachedDOM"; export const et2_IDetachedDOM = "et2_IDetachedDOM";
function implements_et2_IDetachedDOM(obj) { et2_implements_registry.et2_IDetachedDOM = function (obj) {
return implements_methods(obj, ["getDetachedAttributes", "getDetachedNodes", "setDetachedAttributes"]); return implements_methods(obj, ["getDetachedAttributes", "getDetachedNodes", "setDetachedAttributes"]);
} };
var et2_IPrint = "et2_IPrint"; export const et2_IPrint = "et2_IPrint";
function implements_et2_IPrint(obj) { et2_implements_registry.et2_IPrint = function (obj) {
return implements_methods(obj, ["beforePrint", "afterPrint"]); return implements_methods(obj, ["beforePrint", "afterPrint"]);
} };
var et2_IExposable = "et2_IExposable"; export const et2_IExposable = "et2_IExposable";
function implements_et2_IExposable(obj) { et2_implements_registry.et2_IExposable = function (obj) {
return implements_methods(obj, ["getMedia"]); return implements_methods(obj, ["getMedia"]);
} };
//# sourceMappingURL=et2_core_interfaces.js.map //# sourceMappingURL=et2_core_interfaces.js.map

View File

@ -4,17 +4,22 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
// fixing circular dependencies
import type {et2_widget} from "./et2_core_widget";
export var et2_implements_registry : any = {};
/** /**
* Checks if an object / et2_widget implements given methods * Checks if an object / et2_widget implements given methods
* *
* @param obj * @param obj
* @param methods * @param methods
*/ */
function implements_methods(obj : et2_widget, methods : string[]) : boolean export function implements_methods(obj : et2_widget, methods : string[]) : boolean
{ {
for(let i=0; i < methods.length; ++i) for(let i=0; i < methods.length; ++i)
{ {
@ -29,7 +34,7 @@ function implements_methods(obj : et2_widget, methods : string[]) : boolean
/** /**
* Interface for all widget classes, which are based on a DOM node. * Interface for all widget classes, which are based on a DOM node.
*/ */
interface et2_IDOMNode export interface et2_IDOMNode
{ {
/** /**
* Returns the DOM-Node of the current widget. The return value has to be * Returns the DOM-Node of the current widget. The return value has to be
@ -49,16 +54,29 @@ interface et2_IDOMNode
*/ */
getDOMNode(_sender? : et2_widget) : HTMLElement getDOMNode(_sender? : et2_widget) : HTMLElement
} }
var et2_IDOMNode = "et2_IDOMNode"; export const et2_IDOMNode = "et2_IDOMNode";
function implements_et2_IDOMNode(obj : et2_widget) et2_implements_registry.et2_IDOMNode = function(obj : et2_widget)
{ {
return implements_methods(obj, ["getDOMNode"]); return implements_methods(obj, ["getDOMNode"]);
} }
/**
* Interface for all et2_inputWidgets
*/
export interface et2_IInputNode
{
getInputNode(_sender? : et2_widget) : HTMLInputElement|HTMLElement
}
export const et2_IInputNode = "et2_IInputNode";
et2_implements_registry.et2_IInputNode = function(obj : et2_widget)
{
return implements_methods(obj, ["getInputNode"]);
}
/** /**
* Interface for all widgets which support returning a value * Interface for all widgets which support returning a value
*/ */
interface et2_IInput export interface et2_IInput
{ {
/** /**
* getValue has to return the value of the input widget * getValue has to return the value of the input widget
@ -92,8 +110,8 @@ interface et2_IInput
*/ */
isValid(messages) : boolean isValid(messages) : boolean
} }
var et2_IInput = "et2_IInput"; export const et2_IInput = "et2_IInput";
function implements_et2_IInput(obj : et2_widget) et2_implements_registry.et2_IInput = function(obj : et2_widget)
{ {
return implements_methods(obj, ["getValue", "isDirty", "resetDirty", "isValid"]); return implements_methods(obj, ["getValue", "isDirty", "resetDirty", "isValid"]);
} }
@ -101,15 +119,15 @@ function implements_et2_IInput(obj : et2_widget)
/** /**
* Interface for widgets which should be automatically resized * Interface for widgets which should be automatically resized
*/ */
interface et2_IResizeable export interface et2_IResizeable
{ {
/** /**
* Called whenever the window is resized * Called whenever the window is resized
*/ */
resize(number) : void resize(number) : void
} }
var et2_IResizeable = "et2_IResizeable"; export const et2_IResizeable = "et2_IResizeable";
function implements_et2_IResizeable(obj : et2_widget) et2_implements_registry.et2_IResizeable = function(obj : et2_widget)
{ {
return implements_methods(obj, ["resize"]); return implements_methods(obj, ["resize"]);
} }
@ -117,12 +135,12 @@ function implements_et2_IResizeable(obj : et2_widget)
/** /**
* Interface for widgets which have the align attribute * Interface for widgets which have the align attribute
*/ */
interface et2_IAligned export interface et2_IAligned
{ {
get_align() : string get_align() : string
} }
var et2_IAligned = "et2_IAligned"; export const et2_IAligned = "et2_IAligned";
function implements_et2_IAligned(obj : et2_widget) et2_implements_registry.et2_IAligned = function(obj : et2_widget)
{ {
return implements_methods(obj, ["get_align"]); return implements_methods(obj, ["get_align"]);
} }
@ -131,7 +149,7 @@ function implements_et2_IAligned(obj : et2_widget)
* Interface for widgets which want to e.g. perform clientside validation before * Interface for widgets which want to e.g. perform clientside validation before
* the form is submitted. * the form is submitted.
*/ */
interface et2_ISubmitListener export interface et2_ISubmitListener
{ {
/** /**
* Called whenever the template gets submitted. Return false if you want to * Called whenever the template gets submitted. Return false if you want to
@ -142,8 +160,8 @@ interface et2_ISubmitListener
*/ */
submit(_values) : void submit(_values) : void
} }
var et2_ISubmitListener = "et2_ISubmitListener"; export const et2_ISubmitListener = "et2_ISubmitListener";
function implements_et2_ISubmitListener(obj : et2_widget) et2_implements_registry.et2_ISubmitListener = function(obj : et2_widget)
{ {
return implements_methods(obj, ["submit"]); return implements_methods(obj, ["submit"]);
} }
@ -153,7 +171,7 @@ function implements_et2_ISubmitListener(obj : et2_widget)
* is used in grid lists, when only a single row gets really stored in the widget * is used in grid lists, when only a single row gets really stored in the widget
* tree and this instance has to work on multiple copies of the DOM-Tree elements. * tree and this instance has to work on multiple copies of the DOM-Tree elements.
*/ */
interface et2_IDetachedDOM export interface et2_IDetachedDOM
{ {
/** /**
* Creates a list of attributes which can be set when working in the * Creates a list of attributes which can be set when working in the
@ -182,8 +200,8 @@ interface et2_IDetachedDOM
*/ */
setDetachedAttributes(_nodes : HTMLElement[], _values : object, _data?) : void setDetachedAttributes(_nodes : HTMLElement[], _values : object, _data?) : void
} }
var et2_IDetachedDOM = "et2_IDetachedDOM"; export const et2_IDetachedDOM = "et2_IDetachedDOM";
function implements_et2_IDetachedDOM(obj : et2_widget) et2_implements_registry.et2_IDetachedDOM = function(obj : et2_widget)
{ {
return implements_methods(obj, ["getDetachedAttributes", "getDetachedNodes", "setDetachedAttributes"]); return implements_methods(obj, ["getDetachedAttributes", "getDetachedNodes", "setDetachedAttributes"]);
} }
@ -191,7 +209,7 @@ function implements_et2_IDetachedDOM(obj : et2_widget)
/** /**
* Interface for widgets that need to do something special before printing * Interface for widgets that need to do something special before printing
*/ */
interface et2_IPrint export interface et2_IPrint
{ {
/** /**
* Set up for printing * Set up for printing
@ -206,8 +224,8 @@ interface et2_IPrint
*/ */
afterPrint() : void afterPrint() : void
} }
var et2_IPrint = "et2_IPrint"; export const et2_IPrint = "et2_IPrint";
function implements_et2_IPrint(obj : et2_widget) et2_implements_registry.et2_IPrint = function(obj : et2_widget)
{ {
return implements_methods(obj, ["beforePrint", "afterPrint"]); return implements_methods(obj, ["beforePrint", "afterPrint"]);
} }
@ -215,7 +233,7 @@ function implements_et2_IPrint(obj : et2_widget)
/** /**
* Interface all exposed widget must support in order to getMedia for the blueimp Gallery. * Interface all exposed widget must support in order to getMedia for the blueimp Gallery.
*/ */
interface et2_IExposable export interface et2_IExposable
{ {
/** /**
* get media an array of media objects to pass to blueimp Gallery * get media an array of media objects to pass to blueimp Gallery
@ -223,8 +241,8 @@ interface et2_IExposable
*/ */
getMedia(_attrs) : void; getMedia(_attrs) : void;
} }
var et2_IExposable = "et2_IExposable"; export const et2_IExposable = "et2_IExposable";
function implements_et2_IExposable(obj : et2_widget) et2_implements_registry.et2_IExposable = function(obj : et2_widget)
{ {
return implements_methods(obj, ["getMedia"]); return implements_methods(obj, ["getMedia"]);
} }

View File

@ -4,129 +4,44 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-13 * @copyright EGroupware GmbH 2011-21
* @version $Id: et2_core_phpExpressionCompiler.js 38256 2012-03-05 13:07:38Z igel457 $
*/ */
/*egw:uses /*egw:uses
et2_interfaces; et2_interfaces;
et2_core_common; et2_core_common;
*/ */
import { egw } from "../jsapi/egw_global";
(function() import { et2_IDOMNode } from "./et2_core_interfaces";
{ export function et2_compileLegacyJS(_code, _widget, _context) {
"use strict";
/**
* Resolve javascript pseudo functions in onclick or onchange:
* - egw::link('$l','$p') calls egw.link($l,$p)
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
* - egw::lang('Message ...') translate the message, calls egw.lang()
* - confirm('message') translates 'message' and adds a '?' if not present
* - window.open() replaces it with egw_openWindowCentered2()
* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
*
* @param {string} _val onclick, onchange, ... action
* @param {et2_widget} widget
* @ToDo replace xajax_doXMLHTTP with egw.json()
* @ToDo replace (common) cases of confirm with new dialog, idea: calling function supplys function to call after confirm
* @ToDo template::styles(name) inserts the styles of a named template
* @return string
*/
function js_pseudo_funcs(_val,widget)
{
if (_val.indexOf('egw::link(') != -1)
{
_val = _val.replace(/egw::link\(/g,'egw.link(');
}
if (_val.indexOf('form::name(') != -1)
{
// et2_form_name doesn't care about ][, just [
var _cname = widget.getPath() ? widget.getPath().join("[") : false;
_val = _val.replace(/form::name\(/g, "'"+widget.getRoot()._inst.uniqueId+"_'+"+(_cname ? "et2_form_name('"+_cname+"'," : '('));
}
if (_val.indexOf('egw::lang(') != -1)
{
_val = _val.replace(/egw::lang\(/g,'egw.lang(');
}
// ToDo: inserts the styles of a named template
/*if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
{
$tpl = $matches[1] == $this->name ? $this : new etemplate($matches[1]);
$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$on);
}*/
// translate messages in confirm()
if (_val.indexOf('confirm(') != -1)
{
_val = _val.replace(/confirm\((['"])(.*?)(\?)?['"]\)/,"confirm(egw.lang($1$2$1)+'$3')"); // add ? if not there, saves extra phrase
}
// replace window.open() with EGw's egw_openWindowCentered2()
if (_val.indexOf('window.open(') != -1)
{
_val = _val.replace(/window.open\('(.*)','(.*)','dependent=yes,width=([^,]*),height=([^,]*),scrollbars=yes,status=(.*)'\)/,
"egw_openWindowCentered2('$1', '$2', $3, $4, '$5')");
}
// replace xajax calls to code in widgets, with the "etemplate" handler,
// this allows to call widgets with the current app, otherwise everyone would need etemplate run rights
if (_val.indexOf("xajax_doXMLHTTP('etemplate.") != -1)
{
_val = _val.replace(/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/,
"xajax_doXMLHTTP('"+egw.getAppName()+".$1.etemplate'");
}
if (_val.indexOf('this.form.submit()') != -1)
{
_val = _val.replace('this.form.submit()','widget.getInstanceManager().submit()');
}
return _val;
}
this.et2_compileLegacyJS = function(_code, _widget, _context) {
// Replace the javascript pseudo-functions // Replace the javascript pseudo-functions
_code = js_pseudo_funcs(_code,_widget); _code = js_pseudo_funcs(_code, _widget);
// Check whether _code is simply "1" -- if yes replace it accordingly // Check whether _code is simply "1" -- if yes replace it accordingly
if (_code === '1') if (_code === '1') {
{
_code = 'widget.getInstanceManager().submit(); return false;'; _code = 'widget.getInstanceManager().submit(); return false;';
} }
// Check whether some pseudo-variables still reside inside of the code, // Check whether some pseudo-variables still reside inside of the code,
// if yes, replace them. // if yes, replace them.
if (_code.indexOf("$") >= 0 || _code.indexOf("@") >= 0) if (_code.indexOf("$") >= 0 || _code.indexOf("@") >= 0) {
{
// Get the content array manager for the widget // Get the content array manager for the widget
var mgr = _widget.getArrayMgr("content"); var mgr = _widget.getArrayMgr("content");
if (mgr) if (mgr) {
{
_code = mgr.expandName(_code); _code = mgr.expandName(_code);
} }
} }
// Context is the context in which the function will run. Set context to // Context is the context in which the function will run. Set context to
// null as a default, so that it's possible to find bugs where "this" is // null as a default, so that it's possible to find bugs where "this" is
// accessed in the code, but not properly set. // accessed in the code, but not properly set.
var context = _context ? _context : null; var context = _context ? _context : null;
// Check whether the given widget implements the "et2_IDOMNode" // Check whether the given widget implements the "et2_IDOMNode"
// interface // interface
if (!context && _widget.implements(et2_IDOMNode)) if (!context && _widget.implements(et2_IDOMNode)) {
{
context = _widget.getDOMNode(); context = _widget.getDOMNode();
} }
// Check to see if it's referring to an existing function with no arguments specified. // Check to see if it's referring to an existing function with no arguments specified.
// If so, bind context & use it directly // If so, bind context & use it directly
if(_code.indexOf("(") === -1) if (_code.indexOf("(") === -1) {
{
var parts = _code.split("."); var parts = _code.split(".");
var existing_func = parts.pop(); var existing_func = parts.pop();
var parent = _widget.egw().window; var parent = _widget.egw().window;
@ -143,49 +58,92 @@
return parent[existing_func]; return parent[existing_func];
} }
} }
// Generate the function itself, if it fails, log the error message and // Generate the function itself, if it fails, log the error message and
// return a function which always returns false // return a function which always returns false
try { try {
// Code is app.appname.function, add the arguments so it can be executed // Code is app.appname.function, add the arguments so it can be executed
if (typeof _code == 'string' && _code.indexOf('app') == 0 && _code.split('.').length >= 3 && _code.indexOf('(') == -1) if (typeof _code == 'string' && _code.indexOf('app') == 0 && _code.split('.').length >= 3 && _code.indexOf('(') == -1) {
{
const parts = _code.split('.'); const parts = _code.split('.');
const app = _widget.getInstanceManager().app_obj; const app = _widget.getInstanceManager().app_obj;
// check if we need to load the object // check if we need to load the object
if (parts.length === 3 && typeof app[parts[1]] === 'undefined') if (parts.length === 3 && typeof app[parts[1]] === 'undefined') {
{ return function (ev, widget) {
return function (ev, widget)
{
return egw.applyFunc(_code, [ev, widget]); return egw.applyFunc(_code, [ev, widget]);
} };
} }
// Code is app.appname.function, add the arguments so it can be executed // Code is app.appname.function, add the arguments so it can be executed
_code += '(ev,widget)'; _code += '(ev,widget)';
} }
// use app object from etemplate2, which might be private and not just window.app // use app object from etemplate2, which might be private and not just window.app
_code = _code.replace(/(window\.)?app\./, 'widget.getInstanceManager().app_obj.'); _code = _code.replace(/(window\.)?app\./, 'widget.getInstanceManager().app_obj.');
var func = new Function('ev', 'widget', _code); var func = new Function('ev', 'widget', _code);
} catch(e) {
_widget.egw().debug('error', 'Error while compiling JS code ', _code);
return (function() {return false;});
} }
catch (e) {
_widget.egw().debug('error', 'Error while compiling JS code ', _code);
return (function () { return false; });
}
// Execute the code and return its results, pass the egw instance and // Execute the code and return its results, pass the egw instance and
// the widget // the widget
return function(ev) { return function (ev) {
// Dump the executed code for debugging // Dump the executed code for debugging
egw.debug('log', 'Executing legacy JS code: ', _code); egw.debug('log', 'Executing legacy JS code: ', _code);
if (arguments && arguments.length > 2) {
if(arguments && arguments.length > 2)
{
egw.debug('warn', 'Legacy JS code only supports 2 arguments (event and widget)', _code, arguments); egw.debug('warn', 'Legacy JS code only supports 2 arguments (event and widget)', _code, arguments);
} }
// Return the result of the called function // Return the result of the called function
return func.call(context, ev, _widget); return func.call(context, ev, _widget);
}; };
}; }
/**
}).call(window); * Resolve javascript pseudo functions in onclick or onchange:
* - egw::link('$l','$p') calls egw.link($l,$p)
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
* - egw::lang('Message ...') translate the message, calls egw.lang()
* - confirm('message') translates 'message' and adds a '?' if not present
* - window.open() replaces it with egw_openWindowCentered2()
* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
*
* @param {string} _val onclick, onchange, ... action
* @param {et2_widget} widget
* @ToDo replace xajax_doXMLHTTP with egw.json()
* @ToDo replace (common) cases of confirm with new dialog, idea: calling function supplys function to call after confirm
* @ToDo template::styles(name) inserts the styles of a named template
* @return string
*/
function js_pseudo_funcs(_val, widget) {
if (_val.indexOf('egw::link(') != -1) {
_val = _val.replace(/egw::link\(/g, 'egw.link(');
}
if (_val.indexOf('form::name(') != -1) {
// et2_form_name doesn't care about ][, just [
var _cname = widget.getPath() ? widget.getPath().join("[") : false;
_val = _val.replace(/form::name\(/g, "'" + widget.getRoot()._inst.uniqueId + "_'+" + (_cname ? "et2_form_name('" + _cname + "'," : '('));
}
if (_val.indexOf('egw::lang(') != -1) {
_val = _val.replace(/egw::lang\(/g, 'egw.lang(');
}
// ToDo: inserts the styles of a named template
/*if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
{
$tpl = $matches[1] == $this->name ? $this : new etemplate($matches[1]);
$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$on);
}*/
// translate messages in confirm()
if (_val.indexOf('confirm(') != -1) {
_val = _val.replace(/confirm\((['"])(.*?)(\?)?['"]\)/, "confirm(egw.lang($1$2$1)+'$3')"); // add ? if not there, saves extra phrase
}
// replace window.open() with EGw's egw_openWindowCentered2()
if (_val.indexOf('window.open(') != -1) {
_val = _val.replace(/window.open\('(.*)','(.*)','dependent=yes,width=([^,]*),height=([^,]*),scrollbars=yes,status=(.*)'\)/, "egw_openWindowCentered2('$1', '$2', $3, $4, '$5')");
}
// replace xajax calls to code in widgets, with the "etemplate" handler,
// this allows to call widgets with the current app, otherwise everyone would need etemplate run rights
if (_val.indexOf("xajax_doXMLHTTP('etemplate.") != -1) {
_val = _val.replace(/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/, "xajax_doXMLHTTP('" + egw.getAppName() + ".$1.etemplate'");
}
if (_val.indexOf('this.form.submit()') != -1) {
_val = _val.replace('this.form.submit()', 'widget.getInstanceManager().submit()');
}
return _val;
}
//# sourceMappingURL=et2_core_legacyJSFunctions.js.map

View File

@ -0,0 +1,188 @@
/**
* EGroupware eTemplate2 - Execution layer for legacy event code
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link https://www.egroupware.org
* @author Andreas Stöckel
* @copyright EGroupware GmbH 2011-21
*/
/*egw:uses
et2_interfaces;
et2_core_common;
*/
import {egw} from "../jsapi/egw_global";
import {et2_IDOMNode} from "./et2_core_interfaces";
export function et2_compileLegacyJS(_code, _widget, _context)
{
// Replace the javascript pseudo-functions
_code = js_pseudo_funcs(_code,_widget);
// Check whether _code is simply "1" -- if yes replace it accordingly
if (_code === '1')
{
_code = 'widget.getInstanceManager().submit(); return false;';
}
// Check whether some pseudo-variables still reside inside of the code,
// if yes, replace them.
if (_code.indexOf("$") >= 0 || _code.indexOf("@") >= 0)
{
// Get the content array manager for the widget
var mgr = _widget.getArrayMgr("content");
if (mgr)
{
_code = mgr.expandName(_code);
}
}
// Context is the context in which the function will run. Set context to
// null as a default, so that it's possible to find bugs where "this" is
// accessed in the code, but not properly set.
var context = _context ? _context : null;
// Check whether the given widget implements the "et2_IDOMNode"
// interface
if (!context && _widget.implements(et2_IDOMNode))
{
context = _widget.getDOMNode();
}
// Check to see if it's referring to an existing function with no arguments specified.
// If so, bind context & use it directly
if(_code.indexOf("(") === -1)
{
var parts = _code.split(".");
var existing_func = parts.pop();
var parent = _widget.egw().window;
for (var i = 0; i < parts.length; ++i) {
if (typeof parent[parts[i]] !== "undefined") {
parent = parent[parts[i]];
}
// Nope
else {
break;
}
}
if (typeof parent[existing_func] === "function") {
return parent[existing_func];
}
}
// Generate the function itself, if it fails, log the error message and
// return a function which always returns false
try {
// Code is app.appname.function, add the arguments so it can be executed
if (typeof _code == 'string' && _code.indexOf('app') == 0 && _code.split('.').length >= 3 && _code.indexOf('(') == -1)
{
const parts = _code.split('.');
const app = _widget.getInstanceManager().app_obj;
// check if we need to load the object
if (parts.length === 3 && typeof app[parts[1]] === 'undefined')
{
return function (ev, widget)
{
return egw.applyFunc(_code, [ev, widget]);
}
}
// Code is app.appname.function, add the arguments so it can be executed
_code += '(ev,widget)';
}
// use app object from etemplate2, which might be private and not just window.app
_code = _code.replace(/(window\.)?app\./, 'widget.getInstanceManager().app_obj.');
var func = new Function('ev', 'widget', _code);
} catch(e) {
_widget.egw().debug('error', 'Error while compiling JS code ', _code);
return (function() {return false;});
}
// Execute the code and return its results, pass the egw instance and
// the widget
return function(ev) {
// Dump the executed code for debugging
egw.debug('log', 'Executing legacy JS code: ', _code);
if(arguments && arguments.length > 2)
{
egw.debug('warn', 'Legacy JS code only supports 2 arguments (event and widget)', _code, arguments);
}
// Return the result of the called function
return func.call(context, ev, _widget);
};
}
/**
* Resolve javascript pseudo functions in onclick or onchange:
* - egw::link('$l','$p') calls egw.link($l,$p)
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
* - egw::lang('Message ...') translate the message, calls egw.lang()
* - confirm('message') translates 'message' and adds a '?' if not present
* - window.open() replaces it with egw_openWindowCentered2()
* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
*
* @param {string} _val onclick, onchange, ... action
* @param {et2_widget} widget
* @ToDo replace xajax_doXMLHTTP with egw.json()
* @ToDo replace (common) cases of confirm with new dialog, idea: calling function supplys function to call after confirm
* @ToDo template::styles(name) inserts the styles of a named template
* @return string
*/
function js_pseudo_funcs(_val,widget)
{
if (_val.indexOf('egw::link(') != -1)
{
_val = _val.replace(/egw::link\(/g,'egw.link(');
}
if (_val.indexOf('form::name(') != -1)
{
// et2_form_name doesn't care about ][, just [
var _cname = widget.getPath() ? widget.getPath().join("[") : false;
_val = _val.replace(/form::name\(/g, "'"+widget.getRoot()._inst.uniqueId+"_'+"+(_cname ? "et2_form_name('"+_cname+"'," : '('));
}
if (_val.indexOf('egw::lang(') != -1)
{
_val = _val.replace(/egw::lang\(/g,'egw.lang(');
}
// ToDo: inserts the styles of a named template
/*if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
{
$tpl = $matches[1] == $this->name ? $this : new etemplate($matches[1]);
$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$on);
}*/
// translate messages in confirm()
if (_val.indexOf('confirm(') != -1)
{
_val = _val.replace(/confirm\((['"])(.*?)(\?)?['"]\)/,"confirm(egw.lang($1$2$1)+'$3')"); // add ? if not there, saves extra phrase
}
// replace window.open() with EGw's egw_openWindowCentered2()
if (_val.indexOf('window.open(') != -1)
{
_val = _val.replace(/window.open\('(.*)','(.*)','dependent=yes,width=([^,]*),height=([^,]*),scrollbars=yes,status=(.*)'\)/,
"egw_openWindowCentered2('$1', '$2', $3, $4, '$5')");
}
// replace xajax calls to code in widgets, with the "etemplate" handler,
// this allows to call widgets with the current app, otherwise everyone would need etemplate run rights
if (_val.indexOf("xajax_doXMLHTTP('etemplate.") != -1)
{
_val = _val.replace(/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/,
"xajax_doXMLHTTP('"+egw.getAppName()+".$1.etemplate'");
}
if (_val.indexOf('this.form.submit()') != -1)
{
_val = _val.replace('this.form.submit()','widget.getInstanceManager().submit()');
}
return _val;
}

View File

@ -4,400 +4,15 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
*/ */
import { egw } from "../jsapi/egw_global";
(function() /**
{
"use strict";
var STATE_DEFAULT = 0;
var STATE_ESCAPED = 1;
var STATE_CURLY_BRACE_OPEN = 2;
var STATE_EXPECT_CURLY_BRACE_CLOSE = 3;
var STATE_EXPECT_RECT_BRACE_CLOSE = 4;
var STATE_EXPR_BEGIN = 5;
var STATE_EXPR_END = 6;
function _throwParserErr(_p, _err)
{
throw("Syntax error while parsing '" + _p.expr + "' at " +
_p.pos + ", " + _err);
}
function _php_parseDoubleQuoteString(_p, _tree)
{
// Extract all PHP variables from the string
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length)
{
// Read the current char and then increment the parser position by
// one
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
case STATE_CURLY_BRACE_OPEN:
switch (c)
{
case '\\':
state = STATE_ESCAPED;
break;
case '$':
// check for '$$' as used in placeholder syntax, it is NOT expanded and returned as is
if (_p.expr.charAt(_p.pos) == "$" && state == STATE_DEFAULT)
{
_p.pos++;
str += '$$';
break;
}
// check for '$' as last char, as in PHP "test$" === 'test$', $ as last char is NOT expanded
if (_p.pos == _p.expr.length)
{
str += '$';
break;
}
// check for regular expression "/ $/"
if (_p.expr.charAt(_p.pos) == '/' && _p.expr.charAt(0) == '/')
{
str += '$';
break;
}
if (str)
{
_tree.push(str); str = "";
}
// Support for the ${[expr] sytax
if (_p.expr.charAt(_p.pos) == "{" && state != STATE_CURLY_BRACE_OPEN)
{
state = STATE_CURLY_BRACE_OPEN;
_p.pos++;
}
if (state == STATE_CURLY_BRACE_OPEN)
{
_tree.push(_php_parseVariable(_p));
state = STATE_EXPECT_CURLY_BRACE_CLOSE;
}
else
{
_tree.push(_php_parseVariable(_p));
}
break;
case '{':
state = STATE_CURLY_BRACE_OPEN;
break;
default:
if (state == STATE_CURLY_BRACE_OPEN)
{
str += '{';
state = STATE_DEFAULT;
}
str += c;
}
break;
case STATE_ESCAPED:
str += c;
break;
case STATE_EXPECT_CURLY_BRACE_CLOSE:
// When returning from the variableEx parser,
// the current char must be a "}"
if (c != "}")
{
_throwParserErr(_p, "expected '}', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
// Throw an error when reaching the end of the string but expecting
// "}"
if (state == STATE_EXPECT_CURLY_BRACE_CLOSE)
{
_throwParserErr(_p, "unexpected end of string, expected '}'");
}
// Push the last part of the string onto the syntax tree
if (state == STATE_CURLY_BRACE_OPEN)
{
str += "{";
}
if (str)
{
_tree.push(str);
}
}
// Regular expression which matches on PHP variable identifiers (without the $)
var PHP_VAR_PREG = /^([A-Za-z0-9_]+)/;
function _php_parseVariableName(_p)
{
// Extract the variable name form the expression
var vname = PHP_VAR_PREG.exec(_p.expr.substr(_p.pos));
if (vname)
{
// Increment the parser position by the length of vname
_p.pos += vname[0].length;
return {"variable": vname[0], "accessExpressions": []};
}
_throwParserErr(_p, "expected variable identifier.");
}
function _php_parseVariable(_p)
{
// Parse the first variable
var variable = _php_parseVariableName(_p);
// Parse all following variable access identifiers
var state = STATE_DEFAULT;
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
switch (c)
{
case "[":
// Parse the expression inside the rect brace
variable.accessExpressions.push(_php_parseExpression(_p));
state = STATE_EXPECT_RECT_BRACE_CLOSE;
break;
default:
_p.pos--;
return variable;
}
break;
case STATE_EXPECT_RECT_BRACE_CLOSE:
if (c != "]")
{
_throwParserErr(_p, " expected ']', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
return variable;
}
/**
* Reads a string delimited by the char _delim or the regExp _delim from the
* current parser context and returns it.
*
* @param {object} _p parser contect
* @param {string} _delim delimiter
* @return {string} string read (or throws an exception)
*/
function _php_readString(_p, _delim)
{
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
if (c == "\\")
{
state = STATE_ESCAPED;
}
else if (c === _delim || (typeof _delim != "string" && _delim.test(c)))
{
return str;
}
else
{
str += c;
}
break;
case STATE_ESCAPED:
str += c;
state = STATE_DEFAULT;
break;
}
}
_throwParserErr(_p, "unexpected end of string while parsing string!");
}
function _php_parseExpression(_p)
{
var state = STATE_EXPR_BEGIN;
var result = null;
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_EXPR_BEGIN:
switch(c)
{
// Skip whitespace
case " ": case "\n": case "\r": case "\t":
break;
case "\"":
result = [];
var p = _php_parser(_php_readString(_p, "\""));
_php_parseDoubleQuoteString(p, result);
state = STATE_EXPR_END;
break;
case "\'":
var result = _php_readString(_p, "'");
state = STATE_EXPR_END;
break;
case "$":
var result = _php_parseVariable(_p);
state = STATE_EXPR_END;
break;
default:
_p.pos--;
var result = _php_readString(_p, /[^A-Za-z0-9_#]/);
if (!result)
{
_throwParserErr(_p, "unexpected char " + c);
}
_p.pos--;
state = STATE_EXPR_END;
break;
}
break;
case STATE_EXPR_END:
switch(c)
{
// Skip whitespace
case " ": case "\n": case "\r": case "\t":
break;
default:
_p.pos--;
return result;
}
}
}
_throwParserErr(_p, "unexpected end of string while parsing access expressions!");
}
function _php_parser(_expr)
{
return {
expr: _expr,
pos: 0
};
}
function _throwCompilerErr(_err)
{
throw("PHP to JS compiler error, " + _err);
}
function _php_compileVariable(_vars, _variable)
{
if (_vars.indexOf(_variable.variable) >= 0)
{
// Attach a "_" to the variable name as PHP variable names may start
// with numeric values
var result = "_" + _variable.variable;
// Create the access functions
for (var i = 0; i < _variable.accessExpressions.length; i++)
{
result += "[" +
_php_compileString(_vars, _variable.accessExpressions[i]) +
"]";
}
return '(typeof _'+_variable.variable+' != "undefined" && typeof '+result + '!="undefined" && ' + result + ' != null ? ' + result + ':"")';
}
_throwCompilerErr("Variable $" + _variable.variable + " is not defined.");
}
function _php_compileString(_vars, _string)
{
if (!(_string instanceof Array))
{
_string = [_string];
}
var parts = [];
var hasString = false;
for (var i = 0; i < _string.length; i++)
{
var part = _string[i];
if (typeof part == "string")
{
hasString = true;
// Escape all "'" and "\" chars and add the string to the parts array
parts.push("'" + part.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'");
}
else
{
parts.push(_php_compileVariable(_vars, part));
}
}
if (!hasString) // Force the result to be of the type string
{
parts.push('""');
}
return parts.join(" + ");
}
function _php_compileJSCode(_vars, _tree)
{
// Each tree starts with a "string"
return "return " + _php_compileString(_vars, _tree) + ";";
}
/**
* Function which compiles the given PHP string to a JS function which can be * Function which compiles the given PHP string to a JS function which can be
* easily executed. * easily executed.
* *
@ -406,49 +21,315 @@
* The parameters have to be passed to the resulting JS function in the same * The parameters have to be passed to the resulting JS function in the same
* order. * order.
*/ */
this.et2_compilePHPExpression = function(_expr, _vars) export function et2_compilePHPExpression(_expr, _vars) {
{ if (typeof _vars == "undefined") {
if (typeof _vars == "undefined")
{
_vars = []; _vars = [];
} }
try { try {
// Initialize the parser object and create the syntax tree for the given // Initialize the parser object and create the syntax tree for the given
// expression // expression
var parser = _php_parser(_expr); var parser = _php_parser(_expr);
var syntaxTree = []; var syntaxTree = [];
// Parse the given expression as if it was a double quoted string // Parse the given expression as if it was a double quoted string
_php_parseDoubleQuoteString(parser, syntaxTree); _php_parseDoubleQuoteString(parser, syntaxTree);
// Transform the generated syntaxTree into a JS string // Transform the generated syntaxTree into a JS string
var js = _php_compileJSCode(_vars, syntaxTree); var js = _php_compileJSCode(_vars, syntaxTree);
// Log the successfull compiling // Log the successfull compiling
egw.debug("log", "Compiled PHP " + _expr + " --> " + js); egw.debug("log", "Compiled PHP " + _expr + " --> " + js);
} }
catch(e) { catch (e) {
// if expression does NOT compile use it literally and log a warning, but not stop execution // if expression does NOT compile use it literally and log a warning, but not stop execution
egw.debug("warn", "Error compiling PHP "+_expr+" --> using it literally ("+ egw.debug("warn", "Error compiling PHP " + _expr + " --> using it literally (" +
(typeof e == 'string' ? e : e.message)+")!"); (typeof e == 'string' ? e : e.message) + ")!");
return function(){ return _expr; }; return function () { return _expr; };
} }
// Prepate the attributes for the function constuctor // Prepate the attributes for the function constuctor
var attrs = []; var attrs = [];
for (var i = 0; i < _vars.length; i++) for (var i = 0; i < _vars.length; i++) {
{
attrs.push("_" + _vars[i]); attrs.push("_" + _vars[i]);
} }
attrs.push(js); attrs.push(js);
// Create the function and return it // Create the function and return it
return (Function.apply(Function, attrs)); return (Function.apply(Function, attrs));
}
const STATE_DEFAULT = 0;
const STATE_ESCAPED = 1;
const STATE_CURLY_BRACE_OPEN = 2;
const STATE_EXPECT_CURLY_BRACE_CLOSE = 3;
const STATE_EXPECT_RECT_BRACE_CLOSE = 4;
const STATE_EXPR_BEGIN = 5;
const STATE_EXPR_END = 6;
function _throwParserErr(_p, _err) {
throw ("Syntax error while parsing '" + _p.expr + "' at " +
_p.pos + ", " + _err);
}
function _php_parseDoubleQuoteString(_p, _tree) {
// Extract all PHP variables from the string
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length) {
// Read the current char and then increment the parser position by
// one
var c = _p.expr.charAt(_p.pos++);
switch (state) {
case STATE_DEFAULT:
case STATE_CURLY_BRACE_OPEN:
switch (c) {
case '\\':
state = STATE_ESCAPED;
break;
case '$':
// check for '$$' as used in placeholder syntax, it is NOT expanded and returned as is
if (_p.expr.charAt(_p.pos) == "$" && state == STATE_DEFAULT) {
_p.pos++;
str += '$$';
break;
}
// check for '$' as last char, as in PHP "test$" === 'test$', $ as last char is NOT expanded
if (_p.pos == _p.expr.length) {
str += '$';
break;
}
// check for regular expression "/ $/"
if (_p.expr.charAt(_p.pos) == '/' && _p.expr.charAt(0) == '/') {
str += '$';
break;
}
if (str) {
_tree.push(str);
str = "";
}
// Support for the ${[expr] sytax
if (_p.expr.charAt(_p.pos) == "{" && state != STATE_CURLY_BRACE_OPEN) {
state = STATE_CURLY_BRACE_OPEN;
_p.pos++;
}
if (state == STATE_CURLY_BRACE_OPEN) {
_tree.push(_php_parseVariable(_p));
state = STATE_EXPECT_CURLY_BRACE_CLOSE;
}
else {
_tree.push(_php_parseVariable(_p));
}
break;
case '{':
state = STATE_CURLY_BRACE_OPEN;
break;
default:
if (state == STATE_CURLY_BRACE_OPEN) {
str += '{';
state = STATE_DEFAULT;
}
str += c;
}
break;
case STATE_ESCAPED:
str += c;
break;
case STATE_EXPECT_CURLY_BRACE_CLOSE:
// When returning from the variableEx parser,
// the current char must be a "}"
if (c != "}") {
_throwParserErr(_p, "expected '}', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
// Throw an error when reaching the end of the string but expecting
// "}"
if (state == STATE_EXPECT_CURLY_BRACE_CLOSE) {
_throwParserErr(_p, "unexpected end of string, expected '}'");
}
// Push the last part of the string onto the syntax tree
if (state == STATE_CURLY_BRACE_OPEN) {
str += "{";
}
if (str) {
_tree.push(str);
}
}
// Regular expression which matches on PHP variable identifiers (without the $)
var PHP_VAR_PREG = /^([A-Za-z0-9_]+)/;
function _php_parseVariableName(_p) {
// Extract the variable name form the expression
var vname = PHP_VAR_PREG.exec(_p.expr.substr(_p.pos));
if (vname) {
// Increment the parser position by the length of vname
_p.pos += vname[0].length;
return { "variable": vname[0], "accessExpressions": [] };
}
_throwParserErr(_p, "expected variable identifier.");
}
function _php_parseVariable(_p) {
// Parse the first variable
var variable = _php_parseVariableName(_p);
// Parse all following variable access identifiers
var state = STATE_DEFAULT;
while (_p.pos < _p.expr.length) {
var c = _p.expr.charAt(_p.pos++);
switch (state) {
case STATE_DEFAULT:
switch (c) {
case "[":
// Parse the expression inside the rect brace
variable.accessExpressions.push(_php_parseExpression(_p));
state = STATE_EXPECT_RECT_BRACE_CLOSE;
break;
default:
_p.pos--;
return variable;
}
break;
case STATE_EXPECT_RECT_BRACE_CLOSE:
if (c != "]") {
_throwParserErr(_p, " expected ']', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
return variable;
}
/**
* Reads a string delimited by the char _delim or the regExp _delim from the
* current parser context and returns it.
*
* @param {object} _p parser contect
* @param {string} _delim delimiter
* @return {string} string read (or throws an exception)
*/
function _php_readString(_p, _delim) {
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length) {
var c = _p.expr.charAt(_p.pos++);
switch (state) {
case STATE_DEFAULT:
if (c == "\\") {
state = STATE_ESCAPED;
}
else if (c === _delim || (typeof _delim != "string" && _delim.test(c))) {
return str;
}
else {
str += c;
}
break;
case STATE_ESCAPED:
str += c;
state = STATE_DEFAULT;
break;
}
}
_throwParserErr(_p, "unexpected end of string while parsing string!");
}
function _php_parseExpression(_p) {
var state = STATE_EXPR_BEGIN;
var result = null;
while (_p.pos < _p.expr.length) {
var c = _p.expr.charAt(_p.pos++);
switch (state) {
case STATE_EXPR_BEGIN:
switch (c) {
// Skip whitespace
case " ":
case "\n":
case "\r":
case "\t":
break;
case "\"":
result = [];
var p = _php_parser(_php_readString(_p, "\""));
_php_parseDoubleQuoteString(p, result);
state = STATE_EXPR_END;
break;
case "\'":
result = _php_readString(_p, "'");
state = STATE_EXPR_END;
break;
case "$":
result = _php_parseVariable(_p);
state = STATE_EXPR_END;
break;
default:
_p.pos--;
result = _php_readString(_p, /[^A-Za-z0-9_#]/);
if (!result) {
_throwParserErr(_p, "unexpected char " + c);
}
_p.pos--;
state = STATE_EXPR_END;
break;
}
break;
case STATE_EXPR_END:
switch (c) {
// Skip whitespace
case " ":
case "\n":
case "\r":
case "\t":
break;
default:
_p.pos--;
return result;
}
}
}
_throwParserErr(_p, "unexpected end of string while parsing access expressions!");
}
function _php_parser(_expr) {
return {
expr: _expr,
pos: 0
}; };
}
}).call(window); function _throwCompilerErr(_err) {
throw ("PHP to JS compiler error, " + _err);
}
function _php_compileVariable(_vars, _variable) {
if (_vars.indexOf(_variable.variable) >= 0) {
// Attach a "_" to the variable name as PHP variable names may start
// with numeric values
var result = "_" + _variable.variable;
// Create the access functions
for (var i = 0; i < _variable.accessExpressions.length; i++) {
result += "[" +
_php_compileString(_vars, _variable.accessExpressions[i]) +
"]";
}
return '(typeof _' + _variable.variable + ' != "undefined" && typeof ' + result + '!="undefined" && ' + result + ' != null ? ' + result + ':"")';
}
_throwCompilerErr("Variable $" + _variable.variable + " is not defined.");
}
function _php_compileString(_vars, _string) {
if (!(_string instanceof Array)) {
_string = [_string];
}
var parts = [];
var hasString = false;
for (var i = 0; i < _string.length; i++) {
var part = _string[i];
if (typeof part == "string") {
hasString = true;
// Escape all "'" and "\" chars and add the string to the parts array
parts.push("'" + part.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'");
}
else {
parts.push(_php_compileVariable(_vars, part));
}
}
if (!hasString) // Force the result to be of the type string
{
parts.push('""');
}
return parts.join(" + ");
}
function _php_compileJSCode(_vars, _tree) {
// Each tree starts with a "string"
return "return " + _php_compileString(_vars, _tree) + ";";
}
// Include this code in in order to test the above code // Include this code in in order to test the above code
/*(function () { /*(function () {
var row = 10; var row = 10;
@ -469,4 +350,4 @@
test("\\\\", "\\"); test("\\\\", "\\");
test("", ""); test("", "");
})();*/ })();*/
//# sourceMappingURL=et2_core_phpExpressionCompiler.js.map

View File

@ -0,0 +1,467 @@
/**
* EGroupware eTemplate2 - A simple PHP expression parser written in JS
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link https://www.egroupware.org
* @author Andreas Stöckel
* @copyright EGroupware GmbH 2011-2021
*/
/*egw:uses
et2_core_common;
*/
import {egw} from "../jsapi/egw_global";
/**
* Function which compiles the given PHP string to a JS function which can be
* easily executed.
*
* @param _expr is the PHP string expression
* @param _vars is an array with variable names (without the PHP $).
* The parameters have to be passed to the resulting JS function in the same
* order.
*/
export function et2_compilePHPExpression(_expr, _vars)
{
if (typeof _vars == "undefined")
{
_vars = [];
}
try {
// Initialize the parser object and create the syntax tree for the given
// expression
var parser = _php_parser(_expr);
var syntaxTree = [];
// Parse the given expression as if it was a double quoted string
_php_parseDoubleQuoteString(parser, syntaxTree);
// Transform the generated syntaxTree into a JS string
var js = _php_compileJSCode(_vars, syntaxTree);
// Log the successfull compiling
egw.debug("log", "Compiled PHP " + _expr + " --> " + js);
}
catch(e) {
// if expression does NOT compile use it literally and log a warning, but not stop execution
egw.debug("warn", "Error compiling PHP "+_expr+" --> using it literally ("+
(typeof e == 'string' ? e : e.message)+")!");
return function(){ return _expr; };
}
// Prepate the attributes for the function constuctor
var attrs = [];
for (var i = 0; i < _vars.length; i++)
{
attrs.push("_" + _vars[i]);
}
attrs.push(js);
// Create the function and return it
return (Function.apply(Function, attrs));
}
const STATE_DEFAULT = 0;
const STATE_ESCAPED = 1;
const STATE_CURLY_BRACE_OPEN = 2;
const STATE_EXPECT_CURLY_BRACE_CLOSE = 3;
const STATE_EXPECT_RECT_BRACE_CLOSE = 4;
const STATE_EXPR_BEGIN = 5;
const STATE_EXPR_END = 6;
function _throwParserErr(_p, _err)
{
throw("Syntax error while parsing '" + _p.expr + "' at " +
_p.pos + ", " + _err);
}
function _php_parseDoubleQuoteString(_p, _tree)
{
// Extract all PHP variables from the string
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length)
{
// Read the current char and then increment the parser position by
// one
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
case STATE_CURLY_BRACE_OPEN:
switch (c)
{
case '\\':
state = STATE_ESCAPED;
break;
case '$':
// check for '$$' as used in placeholder syntax, it is NOT expanded and returned as is
if (_p.expr.charAt(_p.pos) == "$" && state == STATE_DEFAULT)
{
_p.pos++;
str += '$$';
break;
}
// check for '$' as last char, as in PHP "test$" === 'test$', $ as last char is NOT expanded
if (_p.pos == _p.expr.length)
{
str += '$';
break;
}
// check for regular expression "/ $/"
if (_p.expr.charAt(_p.pos) == '/' && _p.expr.charAt(0) == '/')
{
str += '$';
break;
}
if (str)
{
_tree.push(str); str = "";
}
// Support for the ${[expr] sytax
if (_p.expr.charAt(_p.pos) == "{" && state != STATE_CURLY_BRACE_OPEN)
{
state = STATE_CURLY_BRACE_OPEN;
_p.pos++;
}
if (state == STATE_CURLY_BRACE_OPEN)
{
_tree.push(_php_parseVariable(_p));
state = STATE_EXPECT_CURLY_BRACE_CLOSE;
}
else
{
_tree.push(_php_parseVariable(_p));
}
break;
case '{':
state = STATE_CURLY_BRACE_OPEN;
break;
default:
if (state == STATE_CURLY_BRACE_OPEN)
{
str += '{';
state = STATE_DEFAULT;
}
str += c;
}
break;
case STATE_ESCAPED:
str += c;
break;
case STATE_EXPECT_CURLY_BRACE_CLOSE:
// When returning from the variableEx parser,
// the current char must be a "}"
if (c != "}")
{
_throwParserErr(_p, "expected '}', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
// Throw an error when reaching the end of the string but expecting
// "}"
if (state == STATE_EXPECT_CURLY_BRACE_CLOSE)
{
_throwParserErr(_p, "unexpected end of string, expected '}'");
}
// Push the last part of the string onto the syntax tree
if (state == STATE_CURLY_BRACE_OPEN)
{
str += "{";
}
if (str)
{
_tree.push(str);
}
}
// Regular expression which matches on PHP variable identifiers (without the $)
var PHP_VAR_PREG = /^([A-Za-z0-9_]+)/;
function _php_parseVariableName(_p)
{
// Extract the variable name form the expression
var vname = PHP_VAR_PREG.exec(_p.expr.substr(_p.pos));
if (vname)
{
// Increment the parser position by the length of vname
_p.pos += vname[0].length;
return {"variable": vname[0], "accessExpressions": []};
}
_throwParserErr(_p, "expected variable identifier.");
}
function _php_parseVariable(_p)
{
// Parse the first variable
var variable = _php_parseVariableName(_p);
// Parse all following variable access identifiers
var state = STATE_DEFAULT;
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
switch (c)
{
case "[":
// Parse the expression inside the rect brace
variable.accessExpressions.push(_php_parseExpression(_p));
state = STATE_EXPECT_RECT_BRACE_CLOSE;
break;
default:
_p.pos--;
return variable;
}
break;
case STATE_EXPECT_RECT_BRACE_CLOSE:
if (c != "]")
{
_throwParserErr(_p, " expected ']', but got " + c);
}
state = STATE_DEFAULT;
break;
}
}
return variable;
}
/**
* Reads a string delimited by the char _delim or the regExp _delim from the
* current parser context and returns it.
*
* @param {object} _p parser contect
* @param {string} _delim delimiter
* @return {string} string read (or throws an exception)
*/
function _php_readString(_p, _delim)
{
var state = STATE_DEFAULT;
var str = "";
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_DEFAULT:
if (c == "\\")
{
state = STATE_ESCAPED;
}
else if (c === _delim || (typeof _delim != "string" && _delim.test(c)))
{
return str;
}
else
{
str += c;
}
break;
case STATE_ESCAPED:
str += c;
state = STATE_DEFAULT;
break;
}
}
_throwParserErr(_p, "unexpected end of string while parsing string!");
}
function _php_parseExpression(_p)
{
var state = STATE_EXPR_BEGIN;
var result : any = null;
while (_p.pos < _p.expr.length)
{
var c = _p.expr.charAt(_p.pos++);
switch (state)
{
case STATE_EXPR_BEGIN:
switch(c)
{
// Skip whitespace
case " ": case "\n": case "\r": case "\t":
break;
case "\"":
result = [];
var p = _php_parser(_php_readString(_p, "\""));
_php_parseDoubleQuoteString(p, result);
state = STATE_EXPR_END;
break;
case "\'":
result = _php_readString(_p, "'");
state = STATE_EXPR_END;
break;
case "$":
result = _php_parseVariable(_p);
state = STATE_EXPR_END;
break;
default:
_p.pos--;
result = _php_readString(_p, /[^A-Za-z0-9_#]/);
if (!result)
{
_throwParserErr(_p, "unexpected char " + c);
}
_p.pos--;
state = STATE_EXPR_END;
break;
}
break;
case STATE_EXPR_END:
switch(c)
{
// Skip whitespace
case " ": case "\n": case "\r": case "\t":
break;
default:
_p.pos--;
return result;
}
}
}
_throwParserErr(_p, "unexpected end of string while parsing access expressions!");
}
function _php_parser(_expr)
{
return {
expr: _expr,
pos: 0
};
}
function _throwCompilerErr(_err)
{
throw("PHP to JS compiler error, " + _err);
}
function _php_compileVariable(_vars, _variable)
{
if (_vars.indexOf(_variable.variable) >= 0)
{
// Attach a "_" to the variable name as PHP variable names may start
// with numeric values
var result = "_" + _variable.variable;
// Create the access functions
for (var i = 0; i < _variable.accessExpressions.length; i++)
{
result += "[" +
_php_compileString(_vars, _variable.accessExpressions[i]) +
"]";
}
return '(typeof _'+_variable.variable+' != "undefined" && typeof '+result + '!="undefined" && ' + result + ' != null ? ' + result + ':"")';
}
_throwCompilerErr("Variable $" + _variable.variable + " is not defined.");
}
function _php_compileString(_vars, _string)
{
if (!(_string instanceof Array))
{
_string = [_string];
}
var parts = [];
var hasString = false;
for (var i = 0; i < _string.length; i++)
{
var part = _string[i];
if (typeof part == "string")
{
hasString = true;
// Escape all "'" and "\" chars and add the string to the parts array
parts.push("'" + part.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'");
}
else
{
parts.push(_php_compileVariable(_vars, part));
}
}
if (!hasString) // Force the result to be of the type string
{
parts.push('""');
}
return parts.join(" + ");
}
function _php_compileJSCode(_vars, _tree)
{
// Each tree starts with a "string"
return "return " + _php_compileString(_vars, _tree) + ";";
}
// Include this code in in order to test the above code
/*(function () {
var row = 10;
var row_cont = {"title": "Hello World!"};
var cont = {10: row_cont};
function test(_php, _res)
{
console.log(
et2_compilePHPExpression(_php, ["row", "row_cont", "cont"])
(row, row_cont, cont) === _res);
}
test("${row}[title]", "10[title]");
test("{$row_cont[title]}", "Hello World!");
test('{$cont["$row"][\'title\']}', "Hello World!");
test("$row_cont[${row}[title]]");
test("\\\\", "\\");
test("", "");
})();*/

View File

@ -1,66 +1,46 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS widget class with value attribute and auto loading * EGroupware eTemplate2 - JS widget class with value attribute and auto loading
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_valueWidget = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_baseWidget; et2_core_baseWidget;
*/ */
var et2_core_baseWidget_1 = require("./et2_core_baseWidget"); import { et2_baseWidget } from './et2_core_baseWidget';
require("./et2_core_common"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { et2_csvSplit, et2_no_init } from "./et2_core_common";
/** /**
* et2_valueWidget is the base class for et2_inputWidget - valueWidget introduces * et2_valueWidget is the base class for et2_inputWidget - valueWidget introduces
* the "value" attribute and automatically loads it from the "content" array * the "value" attribute and automatically loads it from the "content" array
* after loading from XML. * after loading from XML.
*/ */
var et2_valueWidget = /** @class */ (function (_super) { export class et2_valueWidget extends et2_baseWidget {
__extends(et2_valueWidget, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_valueWidget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_valueWidget._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_valueWidget._attributes, _child || {}));
_this.label = ''; this.label = '';
_this._labelContainer = null; this._labelContainer = null;
return _this;
} }
/** /**
* *
* @param _attrs * @param _attrs
*/ */
et2_valueWidget.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
if (this.id) { if (this.id) {
// Set the value for this element // Set the value for this element
var contentMgr = this.getArrayMgr("content"); var contentMgr = this.getArrayMgr("content");
if (contentMgr != null) { if (contentMgr != null) {
var val = contentMgr.getEntry(this.id, false, true); let val = contentMgr.getEntry(this.id, false, true);
if (val !== null) { if (val !== null) {
_attrs["value"] = val; _attrs["value"] = val;
} }
@ -70,8 +50,8 @@ var et2_valueWidget = /** @class */ (function (_super) {
_attrs["value"] = this.getArrayMgr("content").data; _attrs["value"] = this.getArrayMgr("content").data;
} }
} }
}; }
et2_valueWidget.prototype.set_label = function (_value) { set_label(_value) {
// Abort if there was no change in the label // Abort if there was no change in the label
if (_value == this.label) { if (_value == this.label) {
return; return;
@ -113,19 +93,20 @@ var et2_valueWidget = /** @class */ (function (_super) {
this.getSurroundings().update(); this.getSurroundings().update();
// Copy the given value // Copy the given value
this.label = _value; this.label = _value;
}; }
et2_valueWidget.prototype.get_value = function () { get_value() {
return this.value; return this.value;
}; }
/** /**
* Set value of widget * Set value of widget
* *
* @param {string} _value value to set * @param {string} _value value to set
*/ */
et2_valueWidget.prototype.set_value = function (_value) { set_value(_value) {
this.value = _value; this.value = _value;
}; }
et2_valueWidget._attributes = { }
et2_valueWidget._attributes = {
"label": { "label": {
"name": "Label", "name": "Label",
"default": "", "default": "",
@ -139,8 +120,5 @@ var et2_valueWidget = /** @class */ (function (_super) {
"type": "rawstring", "type": "rawstring",
"default": et2_no_init "default": et2_no_init
} }
}; };
return et2_valueWidget;
}(et2_core_baseWidget_1.et2_baseWidget));
exports.et2_valueWidget = et2_valueWidget;
//# sourceMappingURL=et2_core_valueWidget.js.map //# sourceMappingURL=et2_core_valueWidget.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -16,9 +15,9 @@
*/ */
import { et2_baseWidget } from './et2_core_baseWidget' import { et2_baseWidget } from './et2_core_baseWidget'
import './et2_core_common';
import {WidgetConfig} from "./et2_core_widget"; import {WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_csvSplit, et2_no_init} from "./et2_core_common";
/** /**
* et2_valueWidget is the base class for et2_inputWidget - valueWidget introduces * et2_valueWidget is the base class for et2_inputWidget - valueWidget introduces

View File

@ -1,4 +1,3 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Widget base class * EGroupware eTemplate2 - JS Widget base class
* *
@ -8,21 +7,6 @@
* @link https://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_widget = exports.et2_createWidget = exports.et2_register_widget = void 0;
/*egw:uses /*egw:uses
jsapi.egw; jsapi.egw;
et2_core_xml; et2_core_xml;
@ -30,14 +14,18 @@ exports.et2_widget = exports.et2_createWidget = exports.et2_register_widget = vo
et2_core_inheritance; et2_core_inheritance;
et2_core_arrayMgr; et2_core_arrayMgr;
*/ */
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from './et2_core_inheritance';
var et2_core_arrayMgr_1 = require("./et2_core_arrayMgr"); import { et2_arrayMgr } from "./et2_core_arrayMgr";
import { egw } from "../jsapi/egw_global";
import { et2_cloneObject, et2_csvSplit } from "./et2_core_common";
import { et2_compileLegacyJS } from "./et2_core_legacyJSFunctions";
import { et2_IDOMNode, et2_IInputNode } from "./et2_core_interfaces";
/** /**
* The registry contains all XML tag names and the corresponding widget * The registry contains all XML tag names and the corresponding widget
* constructor. * constructor.
*/ */
var et2_registry = {}; export var et2_registry = {};
var et2_attribute_registry = {}; export var et2_attribute_registry = {};
/** /**
* Registers the widget class defined by the given constructor, registers all its class attributes, and associates it * Registers the widget class defined by the given constructor, registers all its class attributes, and associates it
* with the types in the _types array. * with the types in the _types array.
@ -45,9 +33,9 @@ var et2_attribute_registry = {};
* @param {function} _constructor constructor * @param {function} _constructor constructor
* @param {array} _types widget types _constructor wants to register for * @param {array} _types widget types _constructor wants to register for
*/ */
function et2_register_widget(_constructor, _types) { export function et2_register_widget(_constructor, _types) {
"use strict"; "use strict";
et2_attribute_registry[_constructor.name] = et2_core_inheritance_1.ClassWithAttributes.buildAttributes(_constructor); et2_attribute_registry[_constructor.name] = ClassWithAttributes.buildAttributes(_constructor);
// Iterate over all given types and register those // Iterate over all given types and register those
for (var i = 0; i < _types.length; i++) { for (var i = 0; i < _types.length; i++) {
var type = _types[i].toLowerCase(); var type = _types[i].toLowerCase();
@ -60,7 +48,6 @@ function et2_register_widget(_constructor, _types) {
et2_registry[type] = _constructor; et2_registry[type] = _constructor;
} }
} }
exports.et2_register_widget = et2_register_widget;
/** /**
* Creates a widget registered for the given tag-name. If "readonly" is listed * Creates a widget registered for the given tag-name. If "readonly" is listed
* inside the attributes, et2_createWidget will try to use the "_ro" type of the * inside the attributes, et2_createWidget will try to use the "_ro" type of the
@ -74,7 +61,7 @@ exports.et2_register_widget = et2_register_widget;
* is not passed, it will default to null. Then you have to attach the element * is not passed, it will default to null. Then you have to attach the element
* to a parent using the addChild or insertChild method. * to a parent using the addChild or insertChild method.
*/ */
function et2_createWidget(_name, _attrs, _parent) { export function et2_createWidget(_name, _attrs, _parent) {
"use strict"; "use strict";
if (typeof _attrs == "undefined") { if (typeof _attrs == "undefined") {
_attrs = {}; _attrs = {};
@ -92,24 +79,21 @@ function et2_createWidget(_name, _attrs, _parent) {
typeof _attrs["readonly"] == "undefined" ? false : _attrs["readonly"]; typeof _attrs["readonly"] == "undefined" ? false : _attrs["readonly"];
// Get the constructor - if the widget is readonly, use the special "_ro" // Get the constructor - if the widget is readonly, use the special "_ro"
// constructor if it is available // constructor if it is available
var constructor = typeof et2_registry[nodeName] == "undefined" ? let constructor = et2_registry[typeof et2_registry[nodeName] == "undefined" ? 'placeholder' : nodeName];
et2_placeholder : et2_registry[nodeName];
if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined") { if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined") {
constructor = et2_registry[nodeName + "_ro"]; constructor = et2_registry[nodeName + "_ro"];
} }
// Do an sanity check for the attributes // Do an sanity check for the attributes
et2_core_inheritance_1.ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], _attrs); ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], _attrs);
// Create the new widget and return it // Create the new widget and return it
return new constructor(_parent, _attrs); return new constructor(_parent, _attrs);
} }
exports.et2_createWidget = et2_createWidget;
/** /**
* The et2 widget base class. * The et2 widget base class.
* *
* @augments ClassWithAttributes * @augments ClassWithAttributes
*/ */
var et2_widget = /** @class */ (function (_super) { export class et2_widget extends ClassWithAttributes {
__extends(et2_widget, _super);
/** /**
* Widget constructor * Widget constructor
* *
@ -123,17 +107,17 @@ var et2_widget = /** @class */ (function (_super) {
* @param _attrs is an associative array of attributes. * @param _attrs is an associative array of attributes.
* @param _child attributes object from the child * @param _child attributes object from the child
*/ */
function et2_widget(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this = _super.call(this) || this; super(); // because we in the top of the widget hierarchy
_this._children = []; this._children = [];
_this._mgrs = {}; this._mgrs = {};
/** /**
* This is used and therefore it we can not (yet) make it private * This is used and therefore it we can not (yet) make it private
* *
* @deprecated use this.getInstanceMgr() * @deprecated use this.getInstanceMgr()
*/ */
_this._inst = null; this._inst = null;
_this.attributes = et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_widget._attributes, _child || {}); this.attributes = ClassWithAttributes.extendAttributes(et2_widget._attributes, _child || {});
// Check whether all attributes are available // Check whether all attributes are available
if (typeof _parent == "undefined") { if (typeof _parent == "undefined") {
_parent = null; _parent = null;
@ -145,33 +129,32 @@ var et2_widget = /** @class */ (function (_super) {
jQuery.extend(_attrs, _attrs.attributes); jQuery.extend(_attrs, _attrs.attributes);
} }
// Initialize all important parameters // Initialize all important parameters
_this._mgrs = {}; this._mgrs = {};
_this._inst = null; this._inst = null;
_this._children = []; this._children = [];
_this._type = _attrs["type"]; this._type = _attrs["type"];
_this.id = _attrs["id"]; this.id = _attrs["id"];
// Add this widget to the given parent widget // Add this widget to the given parent widget
if (_parent != null) { if (_parent != null) {
_parent.addChild(_this); _parent.addChild(this);
} }
// The supported widget classes array defines a whitelist for all widget // The supported widget classes array defines a whitelist for all widget
// classes or interfaces child widgets have to support. // classes or interfaces child widgets have to support.
_this.supportedWidgetClasses = [et2_widget]; this.supportedWidgetClasses = [et2_widget];
if (_attrs["id"]) { if (_attrs["id"]) {
// Create a namespace for this object // Create a namespace for this object
if (_this._createNamespace()) { if (this._createNamespace()) {
_this.checkCreateNamespace(_attrs); this.checkCreateNamespace(_attrs);
} }
} }
if (_this.id) { if (this.id) {
//this.id = this.id.replace(/\[/g,'&#x5B;').replace(/]/g,'&#x5D;'); //this.id = this.id.replace(/\[/g,'&#x5B;').replace(/]/g,'&#x5D;');
} }
// Add all attributes hidden in the content arrays to the attributes // Add all attributes hidden in the content arrays to the attributes
// parameter // parameter
_this.transformAttributes(_attrs); this.transformAttributes(_attrs);
// Create a local copy of the options object // Create a local copy of the options object
_this.options = et2_cloneObject(_attrs); this.options = et2_cloneObject(_attrs);
return _this;
} }
/** /**
* The destroy function destroys all children of the widget, removes itself * The destroy function destroys all children of the widget, removes itself
@ -181,7 +164,7 @@ var et2_widget = /** @class */ (function (_super) {
* unbind ANY event this widget created and to remove all DOM-Nodes it * unbind ANY event this widget created and to remove all DOM-Nodes it
* created. * created.
*/ */
et2_widget.prototype.destroy = function () { destroy() {
// Call the destructor of all children // Call the destructor of all children
for (var i = this._children.length - 1; i >= 0; i--) { for (var i = this._children.length - 1; i >= 0; i--) {
this._children[i].destroy(); this._children[i].destroy();
@ -196,13 +179,13 @@ var et2_widget = /** @class */ (function (_super) {
this._mgrs[key].destroy(); this._mgrs[key].destroy();
} }
} }
}; }
et2_widget.prototype.getType = function () { getType() {
return this._type; return this._type;
}; }
et2_widget.prototype.setType = function (_type) { setType(_type) {
this._type = _type; this._type = _type;
}; }
/** /**
* Creates a copy of this widget. The parameters given are passed to the * Creates a copy of this widget. The parameters given are passed to the
* constructor of the copied object. If the parameters are omitted, _parent * constructor of the copied object. If the parameters are omitted, _parent
@ -210,7 +193,7 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @param {et2_widget} _parent parent to set for clone, default null * @param {et2_widget} _parent parent to set for clone, default null
*/ */
et2_widget.prototype.clone = function (_parent) { clone(_parent) {
// Default _parent to null // Default _parent to null
if (typeof _parent == "undefined") { if (typeof _parent == "undefined") {
_parent = null; _parent = null;
@ -220,8 +203,8 @@ var et2_widget = /** @class */ (function (_super) {
// Assign this element to the copy // Assign this element to the copy
copy.assign(this); copy.assign(this);
return copy; return copy;
}; }
et2_widget.prototype.assign = function (_obj) { assign(_obj) {
if (typeof _obj._children == "undefined") { if (typeof _obj._children == "undefined") {
this.egw().debug("log", "Foo!"); this.egw().debug("log", "Foo!");
} }
@ -231,39 +214,39 @@ var et2_widget = /** @class */ (function (_super) {
} }
// Copy a reference to the content array manager // Copy a reference to the content array manager
this.setArrayMgrs(_obj.mgrs); this.setArrayMgrs(_obj.mgrs);
}; }
/** /**
* Returns the parent widget of this widget * Returns the parent widget of this widget
*/ */
et2_widget.prototype.getParent = function () { getParent() {
return this._parent; return this._parent;
}; }
/** /**
* Returns the list of children of this widget. * Returns the list of children of this widget.
*/ */
et2_widget.prototype.getChildren = function () { getChildren() {
return this._children; return this._children;
}; }
/** /**
* Returns the base widget * Returns the base widget
*/ */
et2_widget.prototype.getRoot = function () { getRoot() {
if (this._parent != null) { if (this._parent != null) {
return this._parent.getRoot(); return this._parent.getRoot();
} }
else { else {
return this; return this;
} }
}; }
/** /**
* Inserts an child at the end of the list. * Inserts an child at the end of the list.
* *
* @param _node is the node which should be added. It has to be an instance * @param _node is the node which should be added. It has to be an instance
* of et2_widget * of et2_widget
*/ */
et2_widget.prototype.addChild = function (_node) { addChild(_node) {
this.insertChild(_node, this._children.length); this.insertChild(_node, this._children.length);
}; }
/** /**
* Inserts a child at the given index. * Inserts a child at the given index.
* *
@ -271,7 +254,7 @@ var et2_widget = /** @class */ (function (_super) {
* of et2_widget * of et2_widget
* @param _idx is the position at which the element should be added. * @param _idx is the position at which the element should be added.
*/ */
et2_widget.prototype.insertChild = function (_node, _idx) { insertChild(_node, _idx) {
// Check whether the node is one of the supported widget classes. // Check whether the node is one of the supported widget classes.
if (this.isOfSupportedWidgetClass(_node)) { if (this.isOfSupportedWidgetClass(_node)) {
// Remove the node from its original parent // Remove the node from its original parent
@ -285,13 +268,13 @@ var et2_widget = /** @class */ (function (_super) {
this.egw().debug("error", "Widget " + _node._type + " is not supported by this widget class", this); this.egw().debug("error", "Widget " + _node._type + " is not supported by this widget class", this);
// throw("Widget is not supported by this widget class!"); // throw("Widget is not supported by this widget class!");
} }
}; }
/** /**
* Removes the child but does not destroy it. * Removes the child but does not destroy it.
* *
* @param {et2_widget} _node child to remove * @param {et2_widget} _node child to remove
*/ */
et2_widget.prototype.removeChild = function (_node) { removeChild(_node) {
// Retrieve the child from the child list // Retrieve the child from the child list
var idx = this._children.indexOf(_node); var idx = this._children.indexOf(_node);
if (idx >= 0) { if (idx >= 0) {
@ -299,13 +282,13 @@ var et2_widget = /** @class */ (function (_super) {
_node._parent = null; _node._parent = null;
this._children.splice(idx, 1); this._children.splice(idx, 1);
} }
}; }
/** /**
* Searches an element by id in the tree, descending into the child levels. * Searches an element by id in the tree, descending into the child levels.
* *
* @param _id is the id you're searching for * @param _id is the id you're searching for
*/ */
et2_widget.prototype.getWidgetById = function (_id) { getWidgetById(_id) {
if (this.id == _id) { if (this.id == _id) {
return this; return this;
} }
@ -318,7 +301,7 @@ var et2_widget = /** @class */ (function (_super) {
} }
} }
if (this.id && _id.indexOf('[') > -1 && this._children.length) { if (this.id && _id.indexOf('[') > -1 && this._children.length) {
var ids = (new et2_core_arrayMgr_1.et2_arrayMgr()).explodeKey(_id); var ids = (new et2_arrayMgr()).explodeKey(_id);
var widget = this; var widget = this;
for (var i = 0; i < ids.length && widget !== null; i++) { for (var i = 0; i < ids.length && widget !== null; i++) {
widget = widget.getWidgetById(ids[i]); widget = widget.getWidgetById(ids[i]);
@ -326,7 +309,7 @@ var et2_widget = /** @class */ (function (_super) {
return widget; return widget;
} }
return null; return null;
}; }
/** /**
* Function which allows iterating over the complete widget tree. * Function which allows iterating over the complete widget tree.
* *
@ -335,7 +318,7 @@ var et2_widget = /** @class */ (function (_super) {
* @param _type is an optional parameter which specifies a class/interface * @param _type is an optional parameter which specifies a class/interface
* the elements have to be instanceOf. * the elements have to be instanceOf.
*/ */
et2_widget.prototype.iterateOver = function (_callback, _context, _type) { iterateOver(_callback, _context, _type) {
if (typeof _type == "undefined") { if (typeof _type == "undefined") {
_type = et2_widget; _type = et2_widget;
} }
@ -345,7 +328,7 @@ var et2_widget = /** @class */ (function (_super) {
for (var i = 0; i < this._children.length; i++) { for (var i = 0; i < this._children.length; i++) {
this._children[i].iterateOver(_callback, _context, _type); this._children[i].iterateOver(_callback, _context, _type);
} }
}; }
/** /**
* Returns true if the widget currently resides in the visible part of the * Returns true if the widget currently resides in the visible part of the
* widget tree. E.g. Templates which have been cloned are not in the visible * widget tree. E.g. Templates which have been cloned are not in the visible
@ -357,7 +340,7 @@ var et2_widget = /** @class */ (function (_super) {
* return this._super(inTree); * return this._super(inTree);
* when calling this function the _vis parameter does not have to be supplied. * when calling this function the _vis parameter does not have to be supplied.
*/ */
et2_widget.prototype.isInTree = function (_sender, _vis) { isInTree(_sender, _vis) {
if (typeof _vis == "undefined") { if (typeof _vis == "undefined") {
_vis = true; _vis = true;
} }
@ -365,15 +348,15 @@ var et2_widget = /** @class */ (function (_super) {
return _vis && this._parent.isInTree(this); return _vis && this._parent.isInTree(this);
} }
return _vis; return _vis;
}; }
et2_widget.prototype.isOfSupportedWidgetClass = function (_obj) { isOfSupportedWidgetClass(_obj) {
for (var i = 0; i < this.supportedWidgetClasses.length; i++) { for (var i = 0; i < this.supportedWidgetClasses.length; i++) {
if (_obj instanceof this.supportedWidgetClasses[i]) { if (_obj instanceof this.supportedWidgetClasses[i]) {
return true; return true;
} }
} }
return false; return false;
}; }
/** /**
* The parseXMLAttrs function takes an XML DOM attributes object * The parseXMLAttrs function takes an XML DOM attributes object
* and adds the given attributes to the _target associative array. This * and adds the given attributes to the _target associative array. This
@ -383,7 +366,7 @@ var et2_widget = /** @class */ (function (_super) {
* @param {object} _target is the object to which the attributes should be written. * @param {object} _target is the object to which the attributes should be written.
* @param {et2_widget} _proto prototype with attributes and legacyOptions attribute * @param {et2_widget} _proto prototype with attributes and legacyOptions attribute
*/ */
et2_widget.prototype.parseXMLAttrs = function (_attrsObj, _target, _proto) { parseXMLAttrs(_attrsObj, _target, _proto) {
// Check whether the attributes object is really existing, if not abort // Check whether the attributes object is really existing, if not abort
if (typeof _attrsObj == "undefined") { if (typeof _attrsObj == "undefined") {
return; return;
@ -395,8 +378,8 @@ var et2_widget = /** @class */ (function (_super) {
var attrValue = _attrsObj[i].value; var attrValue = _attrsObj[i].value;
// Special handling for the legacy options // Special handling for the legacy options
if (attrName == "options" && _proto.constructor.legacyOptions && _proto.constructor.legacyOptions.length > 0) { if (attrName == "options" && _proto.constructor.legacyOptions && _proto.constructor.legacyOptions.length > 0) {
var legacy = _proto.constructor.legacyOptions || []; let legacy = _proto.constructor.legacyOptions || [];
var attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {}; let attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
// Check for modifications on legacy options here. Normal modifications // Check for modifications on legacy options here. Normal modifications
// are handled in widget constructor, but it's too late for legacy options then // are handled in widget constructor, but it's too late for legacy options then
if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) { if (_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) {
@ -441,7 +424,7 @@ var et2_widget = /** @class */ (function (_super) {
// do NOT overwrite already evaluated readonly attribute // do NOT overwrite already evaluated readonly attribute
} }
else { else {
var attrs = et2_attribute_registry[_proto.constructor.name] || {}; let attrs = et2_attribute_registry[_proto.constructor.name] || {};
if (mgr != null && typeof attrs[attrName] != "undefined") { if (mgr != null && typeof attrs[attrName] != "undefined") {
var attr = attrs[attrName]; var attr = attrs[attrName];
// If the attribute is marked as boolean, parse the // If the attribute is marked as boolean, parse the
@ -457,14 +440,14 @@ var et2_widget = /** @class */ (function (_super) {
_target[attrName] = attrValue; _target[attrName] = attrValue;
} }
} }
}; }
/** /**
* Apply the "modifications" to the element and translate attributes marked * Apply the "modifications" to the element and translate attributes marked
* with "translate: true" * with "translate: true"
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_widget.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
// Apply the content of the modifications array // Apply the content of the modifications array
if (this.id) { if (this.id) {
if (typeof this.id != "string") { if (typeof this.id != "string") {
@ -483,30 +466,26 @@ var et2_widget = /** @class */ (function (_super) {
} }
} }
} }
var _loop_1 = function () { // Translate the attributes
if (_attrs[key] && typeof this_1.attributes[key] != "undefined") { for (var key in _attrs) {
if (this_1.attributes[key].translate === true || if (_attrs[key] && typeof this.attributes[key] != "undefined") {
(this_1.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) { if (this.attributes[key].translate === true ||
var value = _attrs[key]; (this.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) {
let value = _attrs[key];
// allow statustext to contain multiple translated sub-strings eg: {Firstname}.{Lastname} // allow statustext to contain multiple translated sub-strings eg: {Firstname}.{Lastname}
if (value.indexOf('{') !== -1) { if (value.indexOf('{') !== -1) {
var egw_1 = this_1.egw(); const egw = this.egw();
_attrs[key] = value.replace(/{([^}]+)}/g, function (str, p1) { _attrs[key] = value.replace(/{([^}]+)}/g, function (str, p1) {
return egw_1.lang(p1); return egw.lang(p1);
}); });
} }
else { else {
_attrs[key] = this_1.egw().lang(value); _attrs[key] = this.egw().lang(value);
}
} }
} }
} }
};
var this_1 = this;
// Translate the attributes
for (var key in _attrs) {
_loop_1();
} }
};
/** /**
* Create a et2_widget from an XML node. * Create a et2_widget from an XML node.
* *
@ -521,7 +500,7 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @return et2_widget * @return et2_widget
*/ */
et2_widget.prototype.createElementFromNode = function (_node, _name) { createElementFromNode(_node, _name) {
var attributes = {}; var attributes = {};
// Parse the "readonly" and "type" flag for this element here, as they // Parse the "readonly" and "type" flag for this element here, as they
// determine which constructor is used // determine which constructor is used
@ -557,28 +536,27 @@ var et2_widget = /** @class */ (function (_super) {
} }
// Get the constructor - if the widget is readonly, use the special "_ro" // Get the constructor - if the widget is readonly, use the special "_ro"
// constructor if it is available // constructor if it is available
var constructor = typeof et2_registry[_nodeName] == "undefined" ? var constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
et2_placeholder : et2_registry[_nodeName];
if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") { if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") {
constructor = et2_registry[_nodeName + "_ro"]; constructor = et2_registry[_nodeName + "_ro"];
} }
// Parse the attributes from the given XML attributes object // Parse the attributes from the given XML attributes object
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype); this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
// Do an sanity check for the attributes // Do an sanity check for the attributes
et2_core_inheritance_1.ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], attributes); ClassWithAttributes.generateAttributeSet(et2_attribute_registry[constructor.name], attributes);
// Creates the new widget, passes this widget as an instance and // Creates the new widget, passes this widget as an instance and
// passes the widgetType. Then it goes on loading the XML for it. // passes the widgetType. Then it goes on loading the XML for it.
var widget = new constructor(this, attributes); var widget = new constructor(this, attributes);
// Load the widget itself from XML // Load the widget itself from XML
widget.loadFromXML(_node); widget.loadFromXML(_node);
return widget; return widget;
}; }
/** /**
* Loads the widget tree from an XML node * Loads the widget tree from an XML node
* *
* @param _node xml node * @param _node xml node
*/ */
et2_widget.prototype.loadFromXML = function (_node) { loadFromXML(_node) {
// Load the child nodes. // Load the child nodes.
for (var i = 0; i < _node.childNodes.length; i++) { for (var i = 0; i < _node.childNodes.length; i++) {
var node = _node.childNodes[i]; var node = _node.childNodes[i];
@ -595,14 +573,14 @@ var et2_widget = /** @class */ (function (_super) {
// Create the new element // Create the new element
this.createElementFromNode(node); this.createElementFromNode(node);
} }
}; }
/** /**
* Called whenever textNodes are loaded from the XML tree * Called whenever textNodes are loaded from the XML tree
* *
* @param _content * @param _content
*/ */
et2_widget.prototype.loadContent = function (_content) { loadContent(_content) {
}; }
/** /**
* Called when loading the widget (sub-tree) is finished. First when this * Called when loading the widget (sub-tree) is finished. First when this
* function is called, the DOM-Tree is created. loadingFinished is * function is called, the DOM-Tree is created. loadingFinished is
@ -624,7 +602,7 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @param {Promise[]} promises List of promises from widgets that are not done. Pass an empty array, it will be filled if needed. * @param {Promise[]} promises List of promises from widgets that are not done. Pass an empty array, it will be filled if needed.
*/ */
et2_widget.prototype.loadingFinished = function (promises) { loadingFinished(promises) {
// Call all availble setters // Call all availble setters
this.initAttributes(this.options); this.initAttributes(this.options);
// Make sure promises is defined to avoid errors. // Make sure promises is defined to avoid errors.
@ -660,7 +638,7 @@ var et2_widget = /** @class */ (function (_super) {
// Fihish loading when it's finished // Fihish loading when it's finished
result.done(jQuery.proxy(loadChildren, this)); result.done(jQuery.proxy(loadChildren, this));
} }
}; }
/** /**
* The initAttributes function sets the attributes to their default * The initAttributes function sets the attributes to their default
* values. The attributes are not overwritten, which means, that the * values. The attributes are not overwritten, which means, that the
@ -671,19 +649,19 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_widget.prototype.initAttributes = function (_attrs) { initAttributes(_attrs) {
for (var key in _attrs) { for (var key in _attrs) {
if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) { if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) {
var val = _attrs[key]; var val = _attrs[key];
// compile string values of attribute type "js" to functions // compile string values of attribute type "js" to functions
if (this.attributes[key].type == 'js' && typeof _attrs[key] == 'string') { if (this.attributes[key].type == 'js' && typeof _attrs[key] == 'string') {
val = et2_compileLegacyJS(val, this, this.instanceOf(et2_inputWidget) ? this.getInputNode() : val = et2_compileLegacyJS(val, this, this.implements(et2_IInputNode) ? this.getInputNode() :
(this.implements(et2_IDOMNode) ? this.getDOMNode() : null)); (this.implements(et2_IDOMNode) ? this.getDOMNode() : null));
} }
this.setAttribute(key, val, false); this.setAttribute(key, val, false);
} }
} }
}; }
/** /**
* Does specific post-processing after the widget is loaded. Most widgets should not * Does specific post-processing after the widget is loaded. Most widgets should not
* need to do anything here, it should all be done before. * need to do anything here, it should all be done before.
@ -693,15 +671,15 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @see {@link http://api.jquery.com/deferred.promise/|jQuery Promise} * @see {@link http://api.jquery.com/deferred.promise/|jQuery Promise}
*/ */
et2_widget.prototype.doLoadingFinished = function () { doLoadingFinished() {
return true; return true;
}; }
/** /**
* The egw function returns the instance of the client side api belonging * The egw function returns the instance of the client side api belonging
* to this widget tree. The api instance can be set in the "container" * to this widget tree. The api instance can be set in the "container"
* widget using the setApiInstance function. * widget using the setApiInstance function.
*/ */
et2_widget.prototype.egw = function () { egw() {
// The _egw property is not set // The _egw property is not set
if (typeof this._egw === 'undefined') { if (typeof this._egw === 'undefined') {
if (this._parent != null) { if (this._parent != null) {
@ -719,31 +697,31 @@ var et2_widget = /** @class */ (function (_super) {
return egw('phpgwapi', wnd); return egw('phpgwapi', wnd);
} }
return this._egw; return this._egw;
}; }
/** /**
* Sets the client side api instance. It can be retrieved by the widget tree * Sets the client side api instance. It can be retrieved by the widget tree
* by using the "egw()" function. * by using the "egw()" function.
* *
* @param {IegwAppLocal} _egw egw object to set * @param {IegwAppLocal} _egw egw object to set
*/ */
et2_widget.prototype.setApiInstance = function (_egw) { setApiInstance(_egw) {
this._egw = _egw; this._egw = _egw;
}; }
/** /**
* Sets all array manager objects - this function can be used to set the * Sets all array manager objects - this function can be used to set the
* root array managers of the container object. * root array managers of the container object.
* *
* @param {object} _mgrs * @param {object} _mgrs
*/ */
et2_widget.prototype.setArrayMgrs = function (_mgrs) { setArrayMgrs(_mgrs) {
this._mgrs = et2_cloneObject(_mgrs); this._mgrs = et2_cloneObject(_mgrs);
}; }
/** /**
* Returns an associative array containing the top-most array managers. * Returns an associative array containing the top-most array managers.
* *
* @param _mgrs is used internally and should not be supplied. * @param _mgrs is used internally and should not be supplied.
*/ */
et2_widget.prototype.getArrayMgrs = function (_mgrs) { getArrayMgrs(_mgrs) {
if (typeof _mgrs == "undefined") { if (typeof _mgrs == "undefined") {
_mgrs = {}; _mgrs = {};
} }
@ -759,22 +737,22 @@ var et2_widget = /** @class */ (function (_super) {
this._parent.getArrayMgrs(_mgrs); this._parent.getArrayMgrs(_mgrs);
} }
return _mgrs; return _mgrs;
}; }
/** /**
* Sets the array manager for the given part * Sets the array manager for the given part
* *
* @param {string} _part which array mgr to set * @param {string} _part which array mgr to set
* @param {object} _mgr * @param {object} _mgr
*/ */
et2_widget.prototype.setArrayMgr = function (_part, _mgr) { setArrayMgr(_part, _mgr) {
this._mgrs[_part] = _mgr; this._mgrs[_part] = _mgr;
}; }
/** /**
* Returns the array manager object for the given part * Returns the array manager object for the given part
* *
* @param {string} managed_array_type name of array mgr to return * @param {string} managed_array_type name of array mgr to return
*/ */
et2_widget.prototype.getArrayMgr = function (managed_array_type) { getArrayMgr(managed_array_type) {
if (this._mgrs && typeof this._mgrs[managed_array_type] != "undefined") { if (this._mgrs && typeof this._mgrs[managed_array_type] != "undefined") {
return this._mgrs[managed_array_type]; return this._mgrs[managed_array_type];
} }
@ -782,7 +760,7 @@ var et2_widget = /** @class */ (function (_super) {
return this._parent.getArrayMgr(managed_array_type); return this._parent.getArrayMgr(managed_array_type);
} }
return null; return null;
}; }
/** /**
* Checks whether a namespace exists for this element in the content array. * Checks whether a namespace exists for this element in the content array.
* If yes, an own perspective of the content array is created. If not, the * If yes, an own perspective of the content array is created. If not, the
@ -790,7 +768,7 @@ var et2_widget = /** @class */ (function (_super) {
* *
* Constructor attributes are passed in case a child needs to make decisions * Constructor attributes are passed in case a child needs to make decisions
*/ */
et2_widget.prototype.checkCreateNamespace = function (_attrs) { checkCreateNamespace(_attrs) {
// Get the content manager // Get the content manager
var mgrs = this.getArrayMgrs(); var mgrs = this.getArrayMgrs();
for (var key in mgrs) { for (var key in mgrs) {
@ -813,7 +791,7 @@ var et2_widget = /** @class */ (function (_super) {
delete (this._mgrs[key]); delete (this._mgrs[key]);
} }
} }
}; }
/** /**
* Widgets that do support a namespace should override and return true. * Widgets that do support a namespace should override and return true.
* *
@ -822,23 +800,23 @@ var et2_widget = /** @class */ (function (_super) {
* *
* @private * @private
*/ */
et2_widget.prototype._createNamespace = function () { _createNamespace() {
return false; return false;
}; }
/** /**
* Sets the instance manager object (of type etemplate2, see etemplate2.js) * Sets the instance manager object (of type etemplate2, see etemplate2.js)
* *
* @param {etemplate2} _inst * @param {etemplate2} _inst
*/ */
et2_widget.prototype.setInstanceManager = function (_inst) { setInstanceManager(_inst) {
this._inst = _inst; this._inst = _inst;
}; }
/** /**
* Returns the instance manager * Returns the instance manager
* *
* @return {etemplate2} * @return {etemplate2}
*/ */
et2_widget.prototype.getInstanceManager = function () { getInstanceManager() {
if (this._inst != null) { if (this._inst != null) {
return this._inst; return this._inst;
} }
@ -846,19 +824,20 @@ var et2_widget = /** @class */ (function (_super) {
return this._parent.getInstanceManager(); return this._parent.getInstanceManager();
} }
return null; return null;
}; }
/** /**
* Returns the path into the data array. By default, array manager takes care of * Returns the path into the data array. By default, array manager takes care of
* this, but some extensions need to override this * this, but some extensions need to override this
*/ */
et2_widget.prototype.getPath = function () { getPath() {
var path = this.getArrayMgr("content").getPath(); var path = this.getArrayMgr("content").getPath();
// Prevent namespaced widgets with value from going an extra layer deep // Prevent namespaced widgets with value from going an extra layer deep
if (this.id && this._createNamespace() && path[path.length - 1] == this.id) if (this.id && this._createNamespace() && path[path.length - 1] == this.id)
path.pop(); path.pop();
return path; return path;
}; }
et2_widget._attributes = { }
et2_widget._attributes = {
"id": { "id": {
"name": "ID", "name": "ID",
"type": "string", "type": "string",
@ -903,11 +882,8 @@ var et2_widget = /** @class */ (function (_super) {
"ignore": true, "ignore": true,
"description": "Object of widget attributes" "description": "Object of widget attributes"
} }
}; };
// Set the legacyOptions array to the names of the properties the "options" // Set the legacyOptions array to the names of the properties the "options"
// attribute defines. // attribute defines.
et2_widget.legacyOptions = []; et2_widget.legacyOptions = [];
return et2_widget;
}(et2_core_inheritance_1.ClassWithAttributes));
exports.et2_widget = et2_widget;
//# sourceMappingURL=et2_core_widget.js.map //# sourceMappingURL=et2_core_widget.js.map

View File

@ -17,15 +17,21 @@
*/ */
import {ClassWithAttributes} from './et2_core_inheritance'; import {ClassWithAttributes} from './et2_core_inheritance';
import {et2_arrayMgr, et2_readonlysArrayMgr} from "./et2_core_arrayMgr"; import {et2_arrayMgr} from "./et2_core_arrayMgr";
import {et2_baseWidget, et2_container} from "./et2_core_baseWidget"; import {egw, IegwAppLocal} from "../jsapi/egw_global";
import {et2_cloneObject, et2_csvSplit} from "./et2_core_common";
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
import {et2_IDOMNode, et2_IInputNode} from "./et2_core_interfaces";
// fixing circular dependencies by only importing type
import type {et2_container} from "./et2_core_baseWidget";
import type {et2_inputWidget, et2_input} from "./et2_core_inputWidget";
/** /**
* The registry contains all XML tag names and the corresponding widget * The registry contains all XML tag names and the corresponding widget
* constructor. * constructor.
*/ */
var et2_registry = {}; export var et2_registry = {};
var et2_attribute_registry = {}; export var et2_attribute_registry = {};
/** /**
@ -97,8 +103,7 @@ export function et2_createWidget(_name : string, _attrs : object, _parent? : any
// Get the constructor - if the widget is readonly, use the special "_ro" // Get the constructor - if the widget is readonly, use the special "_ro"
// constructor if it is available // constructor if it is available
var constructor = typeof et2_registry[nodeName] == "undefined" ? let constructor = et2_registry[typeof et2_registry[nodeName] == "undefined" ? 'placeholder' : nodeName];
et2_placeholder : et2_registry[nodeName];
if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined") if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined")
{ {
constructor = et2_registry[nodeName + "_ro"]; constructor = et2_registry[nodeName + "_ro"];
@ -327,7 +332,7 @@ export class et2_widget extends ClassWithAttributes
this.setArrayMgrs(_obj.mgrs); this.setArrayMgrs(_obj.mgrs);
} }
private _parent: et2_widget; _parent: et2_widget;
/** /**
* Returns the parent widget of this widget * Returns the parent widget of this widget
@ -700,8 +705,7 @@ export class et2_widget extends ClassWithAttributes
// Get the constructor - if the widget is readonly, use the special "_ro" // Get the constructor - if the widget is readonly, use the special "_ro"
// constructor if it is available // constructor if it is available
var constructor = typeof et2_registry[_nodeName] == "undefined" ? var constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
et2_placeholder : et2_registry[_nodeName];
if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") { if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") {
constructor = et2_registry[_nodeName + "_ro"]; constructor = et2_registry[_nodeName + "_ro"];
} }
@ -838,7 +842,7 @@ export class et2_widget extends ClassWithAttributes
// compile string values of attribute type "js" to functions // compile string values of attribute type "js" to functions
if (this.attributes[key].type == 'js' && typeof _attrs[key] == 'string') { if (this.attributes[key].type == 'js' && typeof _attrs[key] == 'string') {
val = et2_compileLegacyJS(val, this, val = et2_compileLegacyJS(val, this,
this.instanceOf(et2_inputWidget) ? (<et2_inputWidget><unknown>this).getInputNode() : this.implements(et2_IInputNode) ? (<et2_inputWidget><unknown>this).getInputNode() :
(this.implements(et2_IDOMNode) ? (<et2_IDOMNode><unknown>this).getDOMNode() : null)); (this.implements(et2_IDOMNode) ? (<et2_IDOMNode><unknown>this).getDOMNode() : null));
} }
this.setAttribute(key, val, false); this.setAttribute(key, val, false);

View File

@ -4,9 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
import { egw } from "../jsapi/egw_global";
/** /**
* Loads the given URL asynchronously from the server * Loads the given URL asynchronously from the server
* *
@ -18,12 +19,12 @@
* @param {object} _context for _callback * @param {object} _context for _callback
* @param {function} _fail_callback function(_xml) * @param {function} _fail_callback function(_xml)
*/ */
function et2_loadXMLFromURL(_url, _callback, _context, _fail_callback) { export function et2_loadXMLFromURL(_url, _callback, _context, _fail_callback) {
if (typeof _context == "undefined") { if (typeof _context == "undefined") {
_context = null; _context = null;
} }
// use window object from main window with same algorithm as for the template cache // use window object from main window with same algorithm as for the template cache
var win; let win;
try { try {
if (opener && opener.etemplate2) { if (opener && opener.etemplate2) {
win = opener; win = opener;
@ -54,28 +55,28 @@ function et2_loadXMLFromURL(_url, _callback, _context, _fail_callback) {
} }
}); });
} }
function et2_directChildrenByTagName(_node, _tagName) { export function et2_directChildrenByTagName(_node, _tagName) {
// Normalize the tag name // Normalize the tag name
_tagName = _tagName.toLowerCase(); _tagName = _tagName.toLowerCase();
var result = []; let result = [];
for (var i = 0; i < _node.childNodes.length; i++) { for (let i = 0; i < _node.childNodes.length; i++) {
if (_tagName == _node.childNodes[i].nodeName.toLowerCase()) { if (_tagName == _node.childNodes[i].nodeName.toLowerCase()) {
result.push(_node.childNodes[i]); result.push(_node.childNodes[i]);
} }
} }
return result; return result;
} }
function et2_filteredNodeIterator(_node, _callback, _context) { export function et2_filteredNodeIterator(_node, _callback, _context) {
for (var i = 0; i < _node.childNodes.length; i++) { for (let i = 0; i < _node.childNodes.length; i++) {
var node = _node.childNodes[i]; let node = _node.childNodes[i];
var nodeName = node.nodeName.toLowerCase(); let nodeName = node.nodeName.toLowerCase();
if (nodeName.charAt(0) != "#") { if (nodeName.charAt(0) != "#") {
_callback.call(_context, node, nodeName); _callback.call(_context, node, nodeName);
} }
} }
} }
function et2_readAttrWithDefault(_node, _name, _default) { export function et2_readAttrWithDefault(_node, _name, _default) {
var val = _node.getAttribute(_name); let val = _node.getAttribute(_name);
return (val === null) ? _default : val; return (val === null) ? _default : val;
} }
//# sourceMappingURL=et2_core_xml.js.map //# sourceMappingURL=et2_core_xml.js.map

View File

@ -4,10 +4,12 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
import {egw} from "../jsapi/egw_global";
/** /**
* Loads the given URL asynchronously from the server * Loads the given URL asynchronously from the server
* *
@ -19,7 +21,7 @@
* @param {object} _context for _callback * @param {object} _context for _callback
* @param {function} _fail_callback function(_xml) * @param {function} _fail_callback function(_xml)
*/ */
function et2_loadXMLFromURL(_url : string, _callback : Function, _context : object, _fail_callback? : Function) export function et2_loadXMLFromURL(_url : string, _callback : Function, _context : object, _fail_callback? : Function)
{ {
if (typeof _context == "undefined") if (typeof _context == "undefined")
{ {
@ -62,7 +64,7 @@ function et2_loadXMLFromURL(_url : string, _callback : Function, _context : obje
}); });
} }
function et2_directChildrenByTagName(_node : HTMLElement, _tagName : String) : HTMLElement[] export function et2_directChildrenByTagName(_node : HTMLElement, _tagName : String) : HTMLElement[]
{ {
// Normalize the tag name // Normalize the tag name
_tagName = _tagName.toLowerCase(); _tagName = _tagName.toLowerCase();
@ -79,7 +81,7 @@ function et2_directChildrenByTagName(_node : HTMLElement, _tagName : String) : H
return result; return result;
} }
function et2_filteredNodeIterator(_node : HTMLElement, _callback : Function, _context : object) export function et2_filteredNodeIterator(_node : HTMLElement, _callback : Function, _context : object)
{ {
for (let i = 0; i < _node.childNodes.length; i++) for (let i = 0; i < _node.childNodes.length; i++)
{ {
@ -92,7 +94,7 @@ function et2_filteredNodeIterator(_node : HTMLElement, _callback : Function, _co
} }
} }
function et2_readAttrWithDefault(_node : HTMLElement, _name : string, _default : string) : string export function et2_readAttrWithDefault(_node : HTMLElement, _name : string, _default : string) : string
{ {
let val = _node.getAttribute(_name); let val = _node.getAttribute(_name);

View File

@ -1,16 +1,13 @@
"use strict";
/** /**
* EGroupware eTemplate2 - dataview code * EGroupware eTemplate2 - dataview code
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_common; et2_core_common;
@ -20,12 +17,10 @@
et2_dataview_view_rowProvider; et2_dataview_view_rowProvider;
et2_dataview_view_resizeable; et2_dataview_view_resizeable;
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); import { et2_dataview_column, et2_dataview_columns } from './et2_dataview_model_columns';
exports.et2_dataview = void 0; import { et2_dataview_view_resizable } from "./et2_dataview_view_resizeable";
var et2_dataview_model_columns_1 = require("./et2_dataview_model_columns"); import { et2_dataview_grid } from "./et2_dataview_view_grid";
var et2_dataview_view_resizeable_1 = require("./et2_dataview_view_resizeable"); import { et2_dataview_rowProvider } from "./et2_dataview_view_rowProvider";
var et2_dataview_view_grid_1 = require("./et2_dataview_view_grid");
var et2_dataview_view_rowProvider_1 = require("./et2_dataview_view_rowProvider");
/** /**
* The et2_dataview class is the main class for displaying a dataview. The * The et2_dataview class is the main class for displaying a dataview. The
* dataview class manages the creation of the outer html nodes (like the table, * dataview class manages the creation of the outer html nodes (like the table,
@ -35,7 +30,7 @@ var et2_dataview_view_rowProvider_1 = require("./et2_dataview_view_rowProvider")
* *
* @augments Class * @augments Class
*/ */
var et2_dataview = /** @class */ (function () { export class et2_dataview {
/** /**
* Constructor for the grid container * Constructor for the grid container
* *
@ -43,7 +38,7 @@ var et2_dataview = /** @class */ (function () {
* @param {egw} _egw * @param {egw} _egw
* @memberOf et2_dataview * @memberOf et2_dataview
*/ */
function et2_dataview(_parentNode, _egw) { constructor(_parentNode, _egw) {
// Copy the arguments // Copy the arguments
this.parentNode = jQuery(_parentNode); this.parentNode = jQuery(_parentNode);
this.egw = _egw; this.egw = _egw;
@ -63,7 +58,7 @@ var et2_dataview = /** @class */ (function () {
/** /**
* Destroys the object, removes all dom nodes and clears all references. * Destroys the object, removes all dom nodes and clears all references.
*/ */
et2_dataview.prototype.destroy = function () { destroy() {
// Clear the columns // Clear the columns
this._clearHeader(); this._clearHeader();
// Free the grid // Free the grid
@ -76,46 +71,46 @@ var et2_dataview = /** @class */ (function () {
} }
// Detatch the outer element // Detatch the outer element
this.table.remove(); this.table.remove();
}; }
/** /**
* Clears all data rows and reloads them * Clears all data rows and reloads them
*/ */
et2_dataview.prototype.clear = function () { clear() {
if (this.grid) { if (this.grid) {
this.grid.clear(); this.grid.clear();
} }
}; }
/** /**
* Returns the column container node for the given column index * Returns the column container node for the given column index
* *
* @param _columnIdx the integer column index * @param _columnIdx the integer column index
*/ */
et2_dataview.prototype.getHeaderContainerNode = function (_columnIdx) { getHeaderContainerNode(_columnIdx) {
if (typeof this.columnNodes[_columnIdx] != "undefined") { if (typeof this.columnNodes[_columnIdx] != "undefined") {
return this.columnNodes[_columnIdx].container[0]; return this.columnNodes[_columnIdx].container[0];
} }
return null; return null;
}; }
/** /**
* Sets the column descriptors and creates the column header according to it. * Sets the column descriptors and creates the column header according to it.
* The inner grid will be emptied if it has already been built. * The inner grid will be emptied if it has already been built.
*/ */
et2_dataview.prototype.setColumns = function (_columnData) { setColumns(_columnData) {
// Free all column objects which have been created till this moment // Free all column objects which have been created till this moment
this._clearHeader(); this._clearHeader();
// Copy the given column data // Copy the given column data
this.columnMgr = new et2_dataview_model_columns_1.et2_dataview_columns(_columnData); this.columnMgr = new et2_dataview_columns(_columnData);
// Create the stylesheets // Create the stylesheets
this.updateColumns(); this.updateColumns();
// Build the header row // Build the header row
this._buildHeader(); this._buildHeader();
// Build the grid // Build the grid
this._buildGrid(); this._buildGrid();
}; }
/** /**
* Resizes the grid * Resizes the grid
*/ */
et2_dataview.prototype.resize = function (_w, _h) { resize(_w, _h) {
// Not fully initialized yet... // Not fully initialized yet...
if (!this.columnMgr) if (!this.columnMgr)
return; return;
@ -137,22 +132,21 @@ var et2_dataview = /** @class */ (function () {
this.headTr.outerHeight(true)); this.headTr.outerHeight(true));
} }
} }
}; }
/** /**
* Returns the column manager object. You can use it to set the visibility * Returns the column manager object. You can use it to set the visibility
* of columns etc. Call "updateHeader" if you did any changes. * of columns etc. Call "updateHeader" if you did any changes.
*/ */
et2_dataview.prototype.getColumnMgr = function () { getColumnMgr() {
return this.columnMgr; return this.columnMgr;
}; }
/** /**
* Recalculates the stylesheets which determine the column visibility and * Recalculates the stylesheets which determine the column visibility and
* width. * width.
* *
* @param setDefault boolean Allow admins to save current settings as default for all users * @param setDefault boolean Allow admins to save current settings as default for all users
*/ */
et2_dataview.prototype.updateColumns = function (setDefault) { updateColumns(setDefault = false) {
if (setDefault === void 0) { setDefault = false; }
if (this.columnMgr) { if (this.columnMgr) {
this._updateColumns(); this._updateColumns();
} }
@ -160,13 +154,13 @@ var et2_dataview = /** @class */ (function () {
if (this.onUpdateColumns) { if (this.onUpdateColumns) {
this.onUpdateColumns(setDefault); this.onUpdateColumns(setDefault);
} }
}; }
/* --- PRIVATE FUNCTIONS --- */ /* --- PRIVATE FUNCTIONS --- */
/* --- Code for building the grid container DOM-Tree elements ---- */ /* --- Code for building the grid container DOM-Tree elements ---- */
/** /**
* Builds the base DOM-Tree elements * Builds the base DOM-Tree elements
*/ */
et2_dataview.prototype._createElements = function () { _createElements() {
/* /*
Structure: Structure:
<table class="egwGridView_outer"> <table class="egwGridView_outer">
@ -188,12 +182,12 @@ var et2_dataview = /** @class */ (function () {
.addClass("egwGridView_outer") .addClass("egwGridView_outer")
.append(this.thead, this.tbody) .append(this.thead, this.tbody)
.appendTo(this.parentNode); .appendTo(this.parentNode);
}; }
/* --- Code for building the header row --- */ /* --- Code for building the header row --- */
/** /**
* Clears the header row * Clears the header row
*/ */
et2_dataview.prototype._clearHeader = function () { _clearHeader() {
if (this.columnMgr) { if (this.columnMgr) {
this.columnMgr.destroy(); this.columnMgr.destroy();
this.columnMgr = null; this.columnMgr = null;
@ -216,12 +210,12 @@ var et2_dataview = /** @class */ (function () {
this.columnNodes = []; this.columnNodes = [];
this.columns = []; this.columns = [];
this.headTr.empty(); this.headTr.empty();
}; }
/** /**
* Sets the column data which is retrieved by calling egwGridColumns.getColumnData. * Sets the column data which is retrieved by calling egwGridColumns.getColumnData.
* The columns will be updated. * The columns will be updated.
*/ */
et2_dataview.prototype._updateColumns = function () { _updateColumns() {
// Copy the columns data // Copy the columns data
this.columns = this.columnMgr.getColumnData(); this.columns = this.columnMgr.getColumnData();
// Count the visible rows // Count the visible rows
@ -292,11 +286,11 @@ var et2_dataview = /** @class */ (function () {
this.egw.css(".egwGridView_grid ." + this.uniqueId + "_div_fullRow", "width: " + (totalWidth - this.columnBorderWidth - 2) + "px; border-right-width: 0 !important;"); this.egw.css(".egwGridView_grid ." + this.uniqueId + "_div_fullRow", "width: " + (totalWidth - this.columnBorderWidth - 2) + "px; border-right-width: 0 !important;");
this.egw.css(".egwGridView_outer ." + this.uniqueId + "_td_fullRow", "border-right-width: 0 !important;"); this.egw.css(".egwGridView_outer ." + this.uniqueId + "_td_fullRow", "border-right-width: 0 !important;");
this.egw.css(".egwGridView_outer ." + this.uniqueId + "_spacer_fullRow", "width: " + (totalWidth - 1) + "px; border-right-width: 0 !important;"); this.egw.css(".egwGridView_outer ." + this.uniqueId + "_spacer_fullRow", "width: " + (totalWidth - 1) + "px; border-right-width: 0 !important;");
}; }
/** /**
* Builds the containers for the header row * Builds the containers for the header row
*/ */
et2_dataview.prototype._buildHeader = function () { _buildHeader() {
var self = this; var self = this;
var handler = function (event) { var handler = function (event) {
}; };
@ -320,7 +314,7 @@ var et2_dataview = /** @class */ (function () {
// make column resizable // make column resizable
var enc_column = self.columnMgr.getColumnById(col.id); var enc_column = self.columnMgr.getColumnById(col.id);
if (enc_column.visibility !== et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT) { if (enc_column.visibility !== et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT) {
et2_dataview_view_resizeable_1.et2_dataview_view_resizable.makeResizeable(column, function (_w) { et2_dataview_view_resizable.makeResizeable(column, function (_w) {
// User wants the column to stay where they put it, even for relative // User wants the column to stay where they put it, even for relative
// width columns, so set it explicitly first and adjust other relative // width columns, so set it explicitly first and adjust other relative
// columns to match. // columns to match.
@ -356,11 +350,11 @@ var et2_dataview = /** @class */ (function () {
}); });
} }
this._buildSelectCol(); this._buildSelectCol();
}; }
/** /**
* Builds the select cols column * Builds the select cols column
*/ */
et2_dataview.prototype._buildSelectCol = function () { _buildSelectCol() {
// Build the "select columns" icon // Build the "select columns" icon
this.selectColIcon = jQuery(document.createElement("span")) this.selectColIcon = jQuery(document.createElement("span"))
.addClass("selectcols") .addClass("selectcols")
@ -375,11 +369,11 @@ var et2_dataview = /** @class */ (function () {
.appendTo(this.headTr); .appendTo(this.headTr);
this.selectCol.css("width", this.scrollbarWidth - this.selectCol.outerWidth() this.selectCol.css("width", this.scrollbarWidth - this.selectCol.outerWidth()
+ this.selectCol.width() + 1); + this.selectCol.width() + 1);
}; }
/** /**
* Builds the inner grid class * Builds the inner grid class
*/ */
et2_dataview.prototype._buildGrid = function () { _buildGrid() {
// Create the collection of column ids // Create the collection of column ids
var colIds = []; var colIds = [];
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
@ -391,19 +385,19 @@ var et2_dataview = /** @class */ (function () {
if (this.rowProvider) { if (this.rowProvider) {
this.rowProvider.destroy(); this.rowProvider.destroy();
} }
this.rowProvider = new et2_dataview_view_rowProvider_1.et2_dataview_rowProvider(this.uniqueId, colIds); this.rowProvider = new et2_dataview_rowProvider(this.uniqueId, colIds);
// Create the grid class and pass "19" as the starting average row height // Create the grid class and pass "19" as the starting average row height
this.grid = new et2_dataview_view_grid_1.et2_dataview_grid(null, null, this.egw, this.rowProvider, 19); this.grid = new et2_dataview_grid(null, null, this.egw, this.rowProvider, 19);
// Insert the grid into the DOM-Tree // Insert the grid into the DOM-Tree
var tr = jQuery(this.grid.getFirstNode()); var tr = jQuery(this.grid.getFirstNode());
this.containerTr.replaceWith(tr); this.containerTr.replaceWith(tr);
this.containerTr = tr; this.containerTr = tr;
}; }
/* --- Code for calculating the browser/css depending widths --- */ /* --- Code for calculating the browser/css depending widths --- */
/** /**
* Reads the browser dependant variables * Reads the browser dependant variables
*/ */
et2_dataview.prototype._getDepVars = function () { _getDepVars() {
if (typeof this.scrollbarWidth === 'undefined') { if (typeof this.scrollbarWidth === 'undefined') {
// Clone the table and attach it to the outer body tag // Clone the table and attach it to the outer body tag
var clone = this.table.clone(); var clone = this.table.clone();
@ -421,11 +415,11 @@ var et2_dataview = /** @class */ (function () {
// Remove the cloned DOM-Node again from the outer body // Remove the cloned DOM-Node again from the outer body
clone.remove(); clone.remove();
} }
}; }
/** /**
* Reads the scrollbar width * Reads the scrollbar width
*/ */
et2_dataview.prototype._getScrollbarWidth = function (_table) { _getScrollbarWidth(_table) {
// Create a temporary td and two divs, which are inserted into the // Create a temporary td and two divs, which are inserted into the
// DOM-Tree. The outer div has a fixed size and "overflow" set to auto. // DOM-Tree. The outer div has a fixed size and "overflow" set to auto.
// When the second div is inserted, it will be forced to display a scrollbar. // When the second div is inserted, it will be forced to display a scrollbar.
@ -444,11 +438,11 @@ var et2_dataview = /** @class */ (function () {
// Remove the elements again // Remove the elements again
div_outer.remove(); div_outer.remove();
return width; return width;
}; }
/** /**
* Calculates the total width of the header column border * Calculates the total width of the header column border
*/ */
et2_dataview.prototype._getHeaderBorderWidth = function (_table) { _getHeaderBorderWidth(_table) {
// Create a temporary th which is appended to the outer thead row // Create a temporary th which is appended to the outer thead row
var cont = jQuery(document.createElement("div")) var cont = jQuery(document.createElement("div"))
.addClass("innerContainer"); .addClass("innerContainer");
@ -461,11 +455,11 @@ var et2_dataview = /** @class */ (function () {
// Remove the appended element again // Remove the appended element again
th.remove(); th.remove();
return width; return width;
}; }
/** /**
* Calculates the total width of the column border * Calculates the total width of the column border
*/ */
et2_dataview.prototype._getColumnBorderWidth = function (_table) { _getColumnBorderWidth(_table) {
// Create a temporary th which is appended to the outer thead row // Create a temporary th which is appended to the outer thead row
var cont = jQuery(document.createElement("div")) var cont = jQuery(document.createElement("div"))
.addClass("innerContainer"); .addClass("innerContainer");
@ -479,8 +473,6 @@ var et2_dataview = /** @class */ (function () {
// Remove the appended element again // Remove the appended element again
td.remove(); td.remove();
return width; return width;
}; }
return et2_dataview; }
}());
exports.et2_dataview = et2_dataview;
//# sourceMappingURL=et2_dataview.js.map //# sourceMappingURL=et2_dataview.js.map

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
@ -20,7 +19,7 @@
et2_dataview_view_resizeable; et2_dataview_view_resizeable;
*/ */
import {et2_dataview_columns} from './et2_dataview_model_columns'; import {et2_dataview_column, et2_dataview_columns} from './et2_dataview_model_columns';
import {et2_dataview_view_resizable} from "./et2_dataview_view_resizeable"; import {et2_dataview_view_resizable} from "./et2_dataview_view_resizeable";
import {et2_dataview_grid} from "./et2_dataview_view_grid"; import {et2_dataview_grid} from "./et2_dataview_view_grid";
import {et2_dataview_rowProvider} from "./et2_dataview_view_rowProvider" import {et2_dataview_rowProvider} from "./et2_dataview_view_rowProvider"
@ -67,9 +66,9 @@ export class et2_dataview
private columnNodes: any[]; private columnNodes: any[];
private columns: any[]; private columns: any[];
private columnMgr: et2_dataview_columns; private columnMgr: et2_dataview_columns;
private rowProvider: et2_dataview_rowProvider; rowProvider: et2_dataview_rowProvider;
private grid: et2_dataview_grid; grid: et2_dataview_grid;
// DOM stuff // DOM stuff
private selectColIcon: JQuery; private selectColIcon: JQuery;
@ -667,6 +666,4 @@ export class et2_dataview
return width; return width;
} }
} }

View File

@ -1,41 +1,29 @@
"use strict";
/** /**
* EGroupware eTemplate2 * EGroupware eTemplate2
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
*/
/*egw:uses import { et2_dataview_selectionManager } from "./et2_dataview_controller_selection";
et2_core_common; import { et2_dataview_row } from "./et2_dataview_view_row";
et2_core_inheritance; import { et2_arrayIntKeys, et2_bounds } from "./et2_core_common";
import { egw } from "../jsapi/egw_global";
et2_dataview_interfaces;
et2_dataview_controller_selection;
et2_dataview_view_row;
et2_dataview_view_tile;
egw_action.egw_action;
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_controller = void 0;
var et2_dataview_controller_selection_1 = require("./et2_dataview_controller_selection");
var et2_dataview_view_row_1 = require("./et2_dataview_view_row");
/** /**
* The fetch timeout specifies the time during which the controller tries to * The fetch timeout specifies the time during which the controller tries to
* consolidate requests for rows. * consolidate requests for rows.
*/ */
var ET2_DATAVIEW_FETCH_TIMEOUT = 50; export const ET2_DATAVIEW_FETCH_TIMEOUT = 50;
var ET2_DATAVIEW_STEPSIZE = 50; export const ET2_DATAVIEW_STEPSIZE = 50;
/** /**
* The et2_dataview_controller class is the intermediate layer between a grid * The et2_dataview_controller class is the intermediate layer between a grid
* instance and the corresponding data source. It manages updating the grid, * instance and the corresponding data source. It manages updating the grid,
* as well as inserting and deleting rows. * as well as inserting and deleting rows.
*/ */
var et2_dataview_controller = /** @class */ (function () { export class et2_dataview_controller {
/** /**
* Constructor of the et2_dataview_controller, connects to the grid * Constructor of the et2_dataview_controller, connects to the grid
* callback. * callback.
@ -50,7 +38,7 @@ var et2_dataview_controller = /** @class */ (function () {
* @param _actionObjectManager is the object that manages the action * @param _actionObjectManager is the object that manages the action
* objects. * objects.
*/ */
function et2_dataview_controller(_parentController, _grid) { constructor(_parentController, _grid) {
this._indexMap = {}; this._indexMap = {};
// Copy the given arguments // Copy the given arguments
this._parentController = _parentController; this._parentController = _parentController;
@ -74,7 +62,7 @@ var et2_dataview_controller = /** @class */ (function () {
this._parentController._children.push(this); this._parentController._children.push(this);
} }
} }
et2_dataview_controller.prototype.destroy = function () { destroy() {
// Destroy the selection manager // Destroy the selection manager
this._selectionMgr.destroy(); this._selectionMgr.destroy();
// Clear the selection timeout // Clear the selection timeout
@ -89,34 +77,34 @@ var et2_dataview_controller = /** @class */ (function () {
} }
} }
this._grid = null; this._grid = null;
}; }
/** /**
* @param value is an object implementing the et2_IDataProvider * @param value is an object implementing the et2_IDataProvider
* interface * interface
*/ */
et2_dataview_controller.prototype.setDataProvider = function (value) { setDataProvider(value) {
this._dataProvider = value; this._dataProvider = value;
}; }
et2_dataview_controller.prototype.setRowCallback = function (value) { setRowCallback(value) {
this._rowCallback = value; this._rowCallback = value;
}; }
et2_dataview_controller.prototype.setLinkCallback = function (value) { setLinkCallback(value) {
this._linkCallback = value; this._linkCallback = value;
}; }
/** /**
* @param value is the context in which the _rowCallback and the * @param value is the context in which the _rowCallback and the
* _linkCallback are called. * _linkCallback are called.
*/ */
et2_dataview_controller.prototype.setContext = function (value) { setContext(value) {
this._context = value; this._context = value;
}; }
et2_dataview_controller.prototype.setActionObjectManager = function (_actionObjectManager) { setActionObjectManager(_actionObjectManager) {
if (this._selectionMgr) { if (this._selectionMgr) {
this._selectionMgr.destroy(); this._selectionMgr.destroy();
} }
// Create the selection manager // Create the selection manager
this._selectionMgr = new et2_dataview_controller_selection_1.et2_dataview_selectionManager(this._parentController ? this._parentController._selectionMgr : null, this._indexMap, _actionObjectManager, this._selectionFetchRange, this._makeIndexVisible, this); this._selectionMgr = new et2_dataview_selectionManager(this._parentController ? this._parentController._selectionMgr : null, this._indexMap, _actionObjectManager, this._selectionFetchRange, this._makeIndexVisible, this);
}; }
/** /**
* The update function queries the server for changes in the currently * The update function queries the server for changes in the currently
* managed index range -- those changes are then merged into the current * managed index range -- those changes are then merged into the current
@ -125,7 +113,7 @@ var et2_dataview_controller = /** @class */ (function () {
* @param {boolean} clear Skip the fancy stuff, dump everything and start again. * @param {boolean} clear Skip the fancy stuff, dump everything and start again.
* Completely clears the grid and selection. * Completely clears the grid and selection.
*/ */
et2_dataview_controller.prototype.update = function (clear) { update(clear) {
// Avoid update after destroy // Avoid update after destroy
// Happens sometimes if AJAX response comes after etemplate unload // Happens sometimes if AJAX response comes after etemplate unload
if (!this._grid) if (!this._grid)
@ -163,11 +151,11 @@ var et2_dataview_controller = /** @class */ (function () {
this._request_queue = []; this._request_queue = [];
// Require that range from the server // Require that range from the server
this._queueFetch(et2_bounds(range.top, clear ? 0 : range.bottom + 1), 0, true); this._queueFetch(et2_bounds(range.top, clear ? 0 : range.bottom + 1), 0, true);
}; }
/** /**
* Rebuilds the complete grid. * Rebuilds the complete grid.
*/ */
et2_dataview_controller.prototype.reset = function () { reset() {
// Throw away all internal mappings and reset the timestamp // Throw away all internal mappings and reset the timestamp
this._indexMap = {}; this._indexMap = {};
// Update selection manager, it uses this by reference // Update selection manager, it uses this by reference
@ -180,22 +168,22 @@ var et2_dataview_controller = /** @class */ (function () {
this._request_queue = []; this._request_queue = [];
// Update the data // Update the data
this.update(); this.update();
}; }
/** /**
* Loads the initial order. Do not call multiple times. * Loads the initial order. Do not call multiple times.
*/ */
et2_dataview_controller.prototype.loadInitialOrder = function (order) { loadInitialOrder(order) {
for (var i = 0; i < order.length; i++) { for (var i = 0; i < order.length; i++) {
this._getIndexEntry(i).uid = order[i]; this._getIndexEntry(i).uid = order[i];
} }
}; }
/** /**
* Load initial data * Load initial data
* *
* @param {string} uid_key Name of the unique row identifier field * @param {string} uid_key Name of the unique row identifier field
* @param {Object} data Key / Value mapping of initial data. * @param {Object} data Key / Value mapping of initial data.
*/ */
et2_dataview_controller.prototype.loadInitialData = function (uid_prefix, uid_key, data) { loadInitialData(uid_prefix, uid_key, data) {
var idx = 0; var idx = 0;
for (var key in data) { for (var key in data) {
// Skip any extra keys // Skip any extra keys
@ -216,32 +204,32 @@ var et2_dataview_controller = /** @class */ (function () {
this._selectionMgr.clear(); this._selectionMgr.clear();
this._emptyRow(this._grid._total == 0); this._emptyRow(this._grid._total == 0);
} }
}; }
/** /**
* Returns the depth of the controller instance. * Returns the depth of the controller instance.
*/ */
et2_dataview_controller.prototype.getDepth = function () { getDepth() {
if (this._parentController) { if (this._parentController) {
return this._parentController.getDepth() + 1; return this._parentController.getDepth() + 1;
} }
return 0; return 0;
}; }
/** /**
* Set the data cache prefix * Set the data cache prefix
* The default is to use appname, but if you need to set it explicitly to * The default is to use appname, but if you need to set it explicitly to
* something else to avoid conflicts. Use the same prefix everywhere for * something else to avoid conflicts. Use the same prefix everywhere for
* each type of data. eg. infolog for infolog entries, even if accessed via addressbook * each type of data. eg. infolog for infolog entries, even if accessed via addressbook
*/ */
et2_dataview_controller.prototype.setPrefix = function (prefix) { setPrefix(prefix) {
this.dataStorePrefix = prefix; this.dataStorePrefix = prefix;
}; }
/** /**
* Returns the row information of the passed node, or null if not available * Returns the row information of the passed node, or null if not available
* *
* @param {DOMNode} node * @param {DOMNode} node
* @return {string|false} UID, or false if not found * @return {string|false} UID, or false if not found
*/ */
et2_dataview_controller.prototype.getRowByNode = function (node) { getRowByNode(node) {
// Whatever the node, find a TR // Whatever the node, find a TR
var row_node = jQuery(node).closest('tr'); var row_node = jQuery(node).closest('tr');
var row = null; var row = null;
@ -270,15 +258,15 @@ var et2_dataview_controller = /** @class */ (function () {
row.controller = this; row.controller = this;
} }
return row; return row;
}; }
/** /**
* Returns the current "total" count. * Returns the current "total" count.
*/ */
et2_dataview_controller.prototype.getTotalCount = function () { getTotalCount() {
return this._grid.getTotalCount(); return this._grid.getTotalCount();
}; }
/* -- PRIVATE FUNCTIONS -- */ /* -- PRIVATE FUNCTIONS -- */
et2_dataview_controller.prototype._getIndexEntry = function (_idx) { _getIndexEntry(_idx) {
// Create an entry in the index map if it does not exist yet // Create an entry in the index map if it does not exist yet
if (typeof this._indexMap[_idx] === "undefined") { if (typeof this._indexMap[_idx] === "undefined") {
this._indexMap[_idx] = { this._indexMap[_idx] = {
@ -291,7 +279,7 @@ var et2_dataview_controller = /** @class */ (function () {
// index does not get updated any further // index does not get updated any further
this._indexMap[_idx]["idx"] = _idx; this._indexMap[_idx]["idx"] = _idx;
return this._indexMap[_idx]; return this._indexMap[_idx];
}; }
/** /**
* Inserts a new data row into the grid. index and uid are derived from the * Inserts a new data row into the grid. index and uid are derived from the
* given management entry. If the data for the given uid does not exist yet, * given management entry. If the data for the given uid does not exist yet,
@ -306,8 +294,7 @@ var et2_dataview_controller = /** @class */ (function () {
* @return true, if all data for the row has been available, false * @return true, if all data for the row has been available, false
* otherwise. * otherwise.
*/ */
et2_dataview_controller.prototype._insertDataRow = function (_entry, _update) { _insertDataRow(_entry, _update) {
var _this = this;
// Abort if the entry already has a row but the _insert flag is not set // Abort if the entry already has a row but the _insert flag is not set
if (_entry.row && !_update) { if (_entry.row && !_update) {
return true; return true;
@ -350,9 +337,9 @@ var et2_dataview_controller = /** @class */ (function () {
} }
// Update index map only for push (autorefresh disabled) // Update index map only for push (autorefresh disabled)
if (this._indexMap[_entry.idx] && this._indexMap[_entry.idx].uid !== _entry.uid) { if (this._indexMap[_entry.idx] && this._indexMap[_entry.idx].uid !== _entry.uid) {
var max = parseInt(Object.keys(this._indexMap).reduce(function (a, b) { return _this._indexMap[a] > _this._indexMap[b] ? a : b; })); let max = parseInt(Object.keys(this._indexMap).reduce((a, b) => this._indexMap[a] > this._indexMap[b] ? a : b));
for (var idx = max; idx >= _entry.idx; idx--) { for (let idx = max; idx >= _entry.idx; idx--) {
var entry = this._indexMap[idx]; let entry = this._indexMap[idx];
this._indexMap[idx].idx = idx + 1; this._indexMap[idx].idx = idx + 1;
this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx]; this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx];
if (this._selectionMgr && this._selectionMgr._registeredRows[entry.uid]) { if (this._selectionMgr && this._selectionMgr._registeredRows[entry.uid]) {
@ -362,16 +349,16 @@ var et2_dataview_controller = /** @class */ (function () {
} }
this._indexMap[_entry.idx] = _entry; this._indexMap[_entry.idx] = _entry;
return this.hasData; return this.hasData;
}; }
/** /**
* Create a new row. * Create a new row.
* *
* @param {type} ctx * @param {type} ctx
* @returns {et2_dataview_container} * @returns {et2_dataview_container}
*/ */
et2_dataview_controller.prototype._createRow = function (ctx) { _createRow(ctx) {
return new et2_dataview_view_row_1.et2_dataview_row(this._grid); return new et2_dataview_row(this._grid);
}; }
/** /**
* Function which gets called by the grid when data is requested. * Function which gets called by the grid when data is requested.
* *
@ -379,7 +366,7 @@ var et2_dataview_controller = /** @class */ (function () {
* requested. * requested.
* @param _idxEnd is the index of the last requested row. * @param _idxEnd is the index of the last requested row.
*/ */
et2_dataview_controller.prototype._gridCallback = function (_idxStart, _idxEnd) { _gridCallback(_idxStart, _idxEnd) {
var needsData = false; var needsData = false;
// Iterate over all elements the dataview requested and create a row // Iterate over all elements the dataview requested and create a row
// which indicates that we are currently loading data // which indicates that we are currently loading data
@ -395,12 +382,12 @@ var et2_dataview_controller = /** @class */ (function () {
if (needsData !== false) { if (needsData !== false) {
this._queueFetch(et2_bounds(needsData, _idxEnd + 1), needsData == _idxStart ? 0 : needsData > _idxStart ? 1 : -1, false); this._queueFetch(et2_bounds(needsData, _idxEnd + 1), needsData == _idxStart ? 0 : needsData > _idxStart ? 1 : -1, false);
} }
}; }
/** /**
* The _queueFetch function is used to queue a fetch request. * The _queueFetch function is used to queue a fetch request.
* TODO: Refresh is currently not used * TODO: Refresh is currently not used
*/ */
et2_dataview_controller.prototype._queueFetch = function (_range, _direction, _isUpdate) { _queueFetch(_range, _direction, _isUpdate) {
// Force immediate to be false // Force immediate to be false
_isUpdate = _isUpdate ? _isUpdate : false; _isUpdate = _isUpdate ? _isUpdate : false;
// Push the requests onto the request queue // Push the requests onto the request queue
@ -422,11 +409,11 @@ var et2_dataview_controller = /** @class */ (function () {
if (_isUpdate) { if (_isUpdate) {
this._flushQueue(true); this._flushQueue(true);
} }
}; }
/** /**
* Flushes the queue. * Flushes the queue.
*/ */
et2_dataview_controller.prototype._flushQueue = function (_isUpdate) { _flushQueue(_isUpdate) {
// Clear any still existing timer // Clear any still existing timer
this._clearTimer(); this._clearTimer();
// Mark all elements in a radius of ET2_DATAVIEW_STEPSIZE // Mark all elements in a radius of ET2_DATAVIEW_STEPSIZE
@ -496,20 +483,21 @@ var et2_dataview_controller = /** @class */ (function () {
"self": this, "self": this,
"start": query.start, "start": query.start,
"count": query.num_rows, "count": query.num_rows,
"lastModification": this._lastModification "lastModification": this._lastModification,
prefix: undefined
}; };
if (this.dataStorePrefix) { if (this.dataStorePrefix) {
ctx.prefix = this.dataStorePrefix; ctx.prefix = this.dataStorePrefix;
} }
this._queueRequest(query, ctx); this._queueRequest(query, ctx);
} }
}; }
/** /**
* Queue a request for data * Queue a request for data
* @param {Object} query * @param {Object} query
* @param {Object} ctx * @param {Object} ctx
*/ */
et2_dataview_controller.prototype._queueRequest = function (query, ctx) { _queueRequest(query, ctx) {
this._request_queue.push({ this._request_queue.push({
query: query, query: query,
context: ctx, context: ctx,
@ -517,11 +505,11 @@ var et2_dataview_controller = /** @class */ (function () {
status: 0 status: 0
}); });
this._fetchQueuedRequest(); this._fetchQueuedRequest();
}; }
/** /**
* Fetch data for a queued request, subject to rate limit * Fetch data for a queued request, subject to rate limit
*/ */
et2_dataview_controller.prototype._fetchQueuedRequest = function () { _fetchQueuedRequest() {
// Check to see if there's room // Check to see if there's room
var count = 0; var count = 0;
for (var i = 0; i < this._request_queue.length; i++) { for (var i = 0; i < this._request_queue.length; i++) {
@ -558,20 +546,20 @@ var et2_dataview_controller = /** @class */ (function () {
request.status = 1; request.status = 1;
// Call the callback // Call the callback
this._dataProvider.dataFetch(request.query, this._fetchCallback, request.context); this._dataProvider.dataFetch(request.query, this._fetchCallback, request.context);
}; }
et2_dataview_controller.prototype._clearTimer = function () { _clearTimer() {
// Reset the queue timer upon destruction // Reset the queue timer upon destruction
if (this._queueTimer) { if (this._queueTimer) {
window.clearTimeout(this._queueTimer); window.clearTimeout(this._queueTimer);
this._queueTimer = null; this._queueTimer = null;
} }
}; }
/** /**
* Called by the data source when the data changes * Called by the data source when the data changes
* *
* @param _data Object|null New data, or null. Null will remove the row. * @param _data Object|null New data, or null. Null will remove the row.
*/ */
et2_dataview_controller.prototype._dataCallback = function (_data) { _dataCallback(_data) {
// Set the "hasData" flag // Set the "hasData" flag
this.self.hasData = true; this.self.hasData = true;
// Call the row callback with the new data -- the row callback then // Call the row callback with the new data -- the row callback then
@ -617,11 +605,11 @@ var et2_dataview_controller = /** @class */ (function () {
// Invalidate the current row entry // Invalidate the current row entry
this.entry.row.invalidate(); this.entry.row.invalidate();
} }
}; }
/** /**
* *
*/ */
et2_dataview_controller.prototype._destroyCallback = function (_row) { _destroyCallback(_row) {
// Unregister the row from the selection manager, if not selected // Unregister the row from the selection manager, if not selected
// If it is selected, leave it there - allows selecting rows and scrolling // If it is selected, leave it there - allows selecting rows and scrolling
var selection = this.self._selectionMgr._getRegisteredRowsEntry(this.entry.uid); var selection = this.self._selectionMgr._getRegisteredRowsEntry(this.entry.uid);
@ -634,18 +622,18 @@ var et2_dataview_controller = /** @class */ (function () {
this.entry.row = null; this.entry.row = null;
// Unregister the data callback // Unregister the data callback
this.self._dataProvider.dataUnregisterUID(this.entry.uid, this.self._dataCallback, this); this.self._dataProvider.dataUnregisterUID(this.entry.uid, this.self._dataCallback, this);
}; }
/** /**
* Returns an array containing "_count" index mapping entries starting from * Returns an array containing "_count" index mapping entries starting from
* the index given in "_start". * the index given in "_start".
*/ */
et2_dataview_controller.prototype._getIndexMapping = function (_start, _count) { _getIndexMapping(_start, _count) {
var result = []; var result = [];
for (var i = _start; i < _start + _count; i++) { for (var i = _start; i < _start + _count; i++) {
result.push(this._getIndexEntry(i)); result.push(this._getIndexEntry(i));
} }
return result; return result;
}; }
/** /**
* Updates the grid according to the new order. The function simply does the * Updates the grid according to the new order. The function simply does the
* following: It iterates along the new order (given in _order) and the old * following: It iterates along the new order (given in _order) and the old
@ -665,7 +653,7 @@ var et2_dataview_controller = /** @class */ (function () {
* newly created index entries are returned. This function does not update * newly created index entries are returned. This function does not update
* the internal mapping in _idxMap. * the internal mapping in _idxMap.
*/ */
et2_dataview_controller.prototype._updateOrder = function (_start, _count, _idxMap, _order) { _updateOrder(_start, _count, _idxMap, _order) {
// The result contains the newly created index map entries which have to // The result contains the newly created index map entries which have to
// be merged with the result // be merged with the result
var result = []; var result = [];
@ -712,8 +700,8 @@ var et2_dataview_controller = /** @class */ (function () {
} }
} }
return result; return result;
}; }
et2_dataview_controller.prototype._mergeResult = function (_newEntries, _invalidStartIdx, _diff, _total) { _mergeResult(_newEntries, _invalidStartIdx, _diff, _total) {
if (_newEntries.length > 0 || _diff > 0) { if (_newEntries.length > 0 || _diff > 0) {
// Create a new index map // Create a new index map
var newMap = {}; var newMap = {};
@ -744,8 +732,8 @@ var et2_dataview_controller = /** @class */ (function () {
this._indexMap = newMap; this._indexMap = newMap;
this._selectionMgr.setIndexMap(newMap); this._selectionMgr.setIndexMap(newMap);
} }
}; }
et2_dataview_controller.prototype._fetchCallback = function (_response) { _fetchCallback(_response) {
// Remove answered request from queue // Remove answered request from queue
var request = null; var request = null;
for (var i = 0; i < this.self._request_queue.length; i++) { for (var i = 0; i < this.self._request_queue.length; i++) {
@ -798,11 +786,11 @@ var et2_dataview_controller = /** @class */ (function () {
this.self._grid.invalidate(); this.self._grid.invalidate();
// Check if requests are waiting // Check if requests are waiting
this.self._fetchQueuedRequest(); this.self._fetchQueuedRequest();
}; }
/** /**
* Insert an empty / placeholder row when there is no data to display * Insert an empty / placeholder row when there is no data to display
*/ */
et2_dataview_controller.prototype._emptyRow = function (_noRows) { _emptyRow(_noRows) {
var noRows = !_noRows ? false : true; var noRows = !_noRows ? false : true;
jQuery(".egwGridView_empty", this._grid.innerTbody).remove(); jQuery(".egwGridView_empty", this._grid.innerTbody).remove();
if (typeof this._grid._rowProvider != "undefined" && this._grid._rowProvider.getPrototype("empty")) { if (typeof this._grid._rowProvider != "undefined" && this._grid._rowProvider.getPrototype("empty")) {
@ -821,26 +809,24 @@ var et2_dataview_controller = /** @class */ (function () {
this._selectionMgr.registerRow("", 0, placeholder.get(0), links); this._selectionMgr.registerRow("", 0, placeholder.get(0), links);
} }
} }
}; }
/** /**
* Callback function used by the selection manager to translate the selected * Callback function used by the selection manager to translate the selected
* range to uids. * range to uids.
*/ */
et2_dataview_controller.prototype._selectionFetchRange = function (_range, _callback, _context) { _selectionFetchRange(_range, _callback, _context) {
this._dataProvider.dataFetch({ "start": _range.top, "num_rows": _range.bottom - _range.top + 1, this._dataProvider.dataFetch({ "start": _range.top, "num_rows": _range.bottom - _range.top + 1,
"no_data": true }, function (_response) { "no_data": true }, function (_response) {
_callback.call(_context, _response.order); _callback.call(_context, _response.order);
}, _context); }, _context);
}; }
/** /**
* Tells the grid to make the given index visible. * Tells the grid to make the given index visible.
*/ */
et2_dataview_controller.prototype._makeIndexVisible = function (_idx) { _makeIndexVisible(_idx) {
this._grid.makeIndexVisible(_idx); this._grid.makeIndexVisible(_idx);
}; }
// Maximum concurrent data requests. Additional ones are held in the queue. }
et2_dataview_controller.CONCURRENT_REQUESTS = 5; // Maximum concurrent data requests. Additional ones are held in the queue.
return et2_dataview_controller; et2_dataview_controller.CONCURRENT_REQUESTS = 5;
}());
exports.et2_dataview_controller = et2_dataview_controller;
//# sourceMappingURL=et2_dataview_controller.js.map //# sourceMappingURL=et2_dataview_controller.js.map

View File

@ -4,9 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
*/
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
@ -24,14 +25,16 @@ import {et2_IDataProvider} from "./et2_dataview_interfaces";
import {et2_dataview_selectionManager} from "./et2_dataview_controller_selection"; import {et2_dataview_selectionManager} from "./et2_dataview_controller_selection";
import {et2_dataview_row} from "./et2_dataview_view_row"; import {et2_dataview_row} from "./et2_dataview_view_row";
import {et2_dataview_grid} from "./et2_dataview_view_grid"; import {et2_dataview_grid} from "./et2_dataview_view_grid";
import {et2_arrayIntKeys, et2_bounds} from "./et2_core_common";
import {egw} from "../jsapi/egw_global";
/** /**
* The fetch timeout specifies the time during which the controller tries to * The fetch timeout specifies the time during which the controller tries to
* consolidate requests for rows. * consolidate requests for rows.
*/ */
var ET2_DATAVIEW_FETCH_TIMEOUT = 50; export const ET2_DATAVIEW_FETCH_TIMEOUT = 50;
var ET2_DATAVIEW_STEPSIZE = 50; export const ET2_DATAVIEW_STEPSIZE = 50;
/** /**
* The et2_dataview_controller class is the intermediate layer between a grid * The et2_dataview_controller class is the intermediate layer between a grid
@ -43,24 +46,25 @@ export class et2_dataview_controller
// Maximum concurrent data requests. Additional ones are held in the queue. // Maximum concurrent data requests. Additional ones are held in the queue.
public static readonly CONCURRENT_REQUESTS = 5; public static readonly CONCURRENT_REQUESTS = 5;
private _parentController: any; protected _parentController: any;
private _grid: et2_dataview_grid; protected _grid: et2_dataview_grid;
private dataStorePrefix: any; protected dataStorePrefix: any;
private _dataProvider: any; private _dataProvider: any;
private _rowCallback: any; protected _rowCallback: any;
private _linkCallback: any; protected _linkCallback: any;
private _context: any; private _context: any;
private _children: any[]; protected _children: any[];
private _indexMap: any = {}; protected _indexMap: any = {};
private _queueTimer: number; private _queueTimer: number;
private _lastModification: number; private _lastModification: number;
private _queue: {}; private _queue: {};
private _request_queue: any[]; private _request_queue: any[];
private _selectionMgr: et2_dataview_selectionManager; protected _selectionMgr: et2_dataview_selectionManager;
private _objectManager: any; protected _objectManager: any;
private hasData: boolean;
/** /**
* Constructor of the et2_dataview_controller, connects to the grid * Constructor of the et2_dataview_controller, connects to the grid
@ -679,7 +683,8 @@ export class et2_dataview_controller
"self": this, "self": this,
"start": query.start, "start": query.start,
"count": query.num_rows, "count": query.num_rows,
"lastModification": this._lastModification "lastModification": this._lastModification,
prefix: undefined
}; };
if(this.dataStorePrefix) if(this.dataStorePrefix)
{ {

View File

@ -1,22 +1,22 @@
"use strict";
/** /**
* EGroupware eTemplate2 * EGroupware eTemplate2
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* */
/*egw:uses /*egw:uses
et2_dataview_view_aoi; et2_dataview_view_aoi;
egw_action.egw_keymanager; egw_action.egw_keymanager;
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); import { egw } from "../jsapi/egw_global";
exports.et2_dataview_selectionManager = void 0; import { et2_bounds } from "./et2_core_common";
import { et2_dialog } from "./et2_widget_dialog";
import { et2_createWidget } from "./et2_core_widget";
/** /**
* The selectioManager is internally used by the et2_dataview_controller class * The selectioManager is internally used by the et2_dataview_controller class
* to manage the row selection. * to manage the row selection.
@ -28,7 +28,7 @@ exports.et2_dataview_selectionManager = void 0;
* *
* @augments Class * @augments Class
*/ */
var et2_dataview_selectionManager = /** @class */ (function () { export class et2_dataview_selectionManager {
/** /**
* Constructor * Constructor
* *
@ -40,7 +40,7 @@ var et2_dataview_selectionManager = /** @class */ (function () {
* @param _context * @param _context
* @memberOf et2_dataview_selectionManager * @memberOf et2_dataview_selectionManager
*/ */
function et2_dataview_selectionManager(_parent, _indexMap, _actionObjectManager, _queryRangeCallback, _makeVisibleCallback, _context) { constructor(_parent, _indexMap, _actionObjectManager, _queryRangeCallback, _makeVisibleCallback, _context) {
// Copy the arguments // Copy the arguments
this._parent = _parent; this._parent = _parent;
this._indexMap = _indexMap; this._indexMap = _indexMap;
@ -68,7 +68,7 @@ var et2_dataview_selectionManager = /** @class */ (function () {
// Callback for when the selection changes // Callback for when the selection changes
this.select_callback = null; this.select_callback = null;
} }
et2_dataview_selectionManager.prototype.destroy = function () { destroy() {
// If we have a parent, unregister from that // If we have a parent, unregister from that
if (this._parent) { if (this._parent) {
var idx = this._parent._children.indexOf(this); var idx = this._parent._children.indexOf(this);
@ -83,8 +83,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
this.unregisterRow(key, this._registeredRows[key].tr); this.unregisterRow(key, this._registeredRows[key].tr);
} }
this.select_callback = null; this.select_callback = null;
}; }
et2_dataview_selectionManager.prototype.clear = function () { clear() {
for (var key in this._registeredRows) { for (var key in this._registeredRows) {
this.unregisterRow(key, this._registeredRows[key].tr); this.unregisterRow(key, this._registeredRows[key].tr);
delete this._registeredRows[key]; delete this._registeredRows[key];
@ -100,14 +100,14 @@ var et2_dataview_selectionManager = /** @class */ (function () {
this._invertSelection = false; this._invertSelection = false;
this._selectAll = false; this._selectAll = false;
this._inUpdate = false; this._inUpdate = false;
}; }
et2_dataview_selectionManager.prototype.setIndexMap = function (_indexMap) { setIndexMap(_indexMap) {
this._indexMap = _indexMap; this._indexMap = _indexMap;
}; }
et2_dataview_selectionManager.prototype.setTotalCount = function (_total) { setTotalCount(_total) {
this._total = _total; this._total = _total;
}; }
et2_dataview_selectionManager.prototype.registerRow = function (_uid, _idx, _tr, _links) { registerRow(_uid, _idx, _tr, _links) {
// Get the corresponding entry from the registered rows array // Get the corresponding entry from the registered rows array
var entry = this._getRegisteredRowsEntry(_uid); var entry = this._getRegisteredRowsEntry(_uid);
// If the row has changed unregister the old one and do not delete // If the row has changed unregister the old one and do not delete
@ -127,8 +127,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
entry.tr = _tr; entry.tr = _tr;
// Update the visible state of the _tr // Update the visible state of the _tr
this._updateEntryState(entry, entry.state); this._updateEntryState(entry, entry.state);
}; }
et2_dataview_selectionManager.prototype.unregisterRow = function (_uid, _tr, _noDelete) { unregisterRow(_uid, _tr, _noDelete) {
// _noDelete defaults to false // _noDelete defaults to false
_noDelete = _noDelete ? true : false; _noDelete = _noDelete ? true : false;
if (typeof this._registeredRows[_uid] !== "undefined" if (typeof this._registeredRows[_uid] !== "undefined"
@ -152,8 +152,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
} }
this._inUpdate = false; this._inUpdate = false;
} }
}; }
et2_dataview_selectionManager.prototype.resetSelection = function () { resetSelection() {
this._invertSelection = false; this._invertSelection = false;
this._selectAll = false; this._selectAll = false;
this._actionObjectManager.setAllSelected(false); this._actionObjectManager.setAllSelected(false);
@ -163,17 +163,17 @@ var et2_dataview_selectionManager = /** @class */ (function () {
for (var i = 0; i < this._children.length; i++) { for (var i = 0; i < this._children.length; i++) {
this._children[i].resetSelection(); this._children[i].resetSelection();
} }
}; }
et2_dataview_selectionManager.prototype.setSelected = function (_uid, _selected) { setSelected(_uid, _selected) {
this._selectAll = false; this._selectAll = false;
var entry = this._getRegisteredRowsEntry(_uid); var entry = this._getRegisteredRowsEntry(_uid);
this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_SELECTED, _selected)); this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_SELECTED, _selected));
}; }
et2_dataview_selectionManager.prototype.getAllSelected = function () { getAllSelected() {
var selected = this.getSelected(); var selected = this.getSelected();
return selected.all || (selected.ids.length === this._total); return selected.all || (selected.ids.length === this._total);
}; }
et2_dataview_selectionManager.prototype.setFocused = function (_uid, _focused) { setFocused(_uid, _focused) {
// Reset the state of the currently focused entry // Reset the state of the currently focused entry
if (this._focusedEntry) { if (this._focusedEntry) {
this._updateEntryState(this._focusedEntry, egwSetBit(this._focusedEntry.state, EGW_AO_STATE_FOCUSED, false)); this._updateEntryState(this._focusedEntry, egwSetBit(this._focusedEntry.state, EGW_AO_STATE_FOCUSED, false));
@ -185,8 +185,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
var entry = this._focusedEntry = this._getRegisteredRowsEntry(_uid); var entry = this._focusedEntry = this._getRegisteredRowsEntry(_uid);
this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_FOCUSED, true)); this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_FOCUSED, true));
} }
}; }
et2_dataview_selectionManager.prototype.selectAll = function () { selectAll() {
// Reset the selection // Reset the selection
this.resetSelection(); this.resetSelection();
this._selectAll = true; this._selectAll = true;
@ -203,8 +203,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
this._updateEntryState(entry, entry.state); this._updateEntryState(entry, entry.state);
} }
this._selectAll = true; this._selectAll = true;
}; }
et2_dataview_selectionManager.prototype.getSelected = function () { getSelected() {
// Collect all currently selected ids // Collect all currently selected ids
var ids = []; var ids = [];
for (var key in this._registeredRows) { for (var key in this._registeredRows) {
@ -223,9 +223,9 @@ var et2_dataview_selectionManager = /** @class */ (function () {
"all": this._selectAll, "all": this._selectAll,
"ids": ids "ids": ids
}; };
}; }
/** -- PRIVATE FUNCTIONS -- **/ /** -- PRIVATE FUNCTIONS -- **/
et2_dataview_selectionManager.prototype._attachActionObjectInterface = function (_entry, _tr, _uid) { _attachActionObjectInterface(_entry, _tr, _uid) {
// Create the AOI which is used internally in the selection manager // Create the AOI which is used internally in the selection manager
// this AOI is not connected to the AO, as the selection manager // this AOI is not connected to the AO, as the selection manager
// cares about selection etc. // cares about selection etc.
@ -236,8 +236,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
this._handleSelect(_uid, _entry, egwBitIsSet(_shiftState, EGW_AO_SHIFT_STATE_BLOCK), egwBitIsSet(_shiftState, EGW_AO_SHIFT_STATE_MULTI)); this._handleSelect(_uid, _entry, egwBitIsSet(_shiftState, EGW_AO_SHIFT_STATE_BLOCK), egwBitIsSet(_shiftState, EGW_AO_SHIFT_STATE_MULTI));
} }
}, this); }, this);
}; }
et2_dataview_selectionManager.prototype._getDummyAOI = function (_entry, _tr, _uid, _idx) { _getDummyAOI(_entry, _tr, _uid, _idx) {
// Create AOI // Create AOI
var dummyAOI = new egwActionObjectInterface(); var dummyAOI = new egwActionObjectInterface();
var self = this; var self = this;
@ -261,8 +261,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
// handlers can be properly bound // handlers can be properly bound
dummyAOI.getDOMNode = function () { return _tr; }; dummyAOI.getDOMNode = function () { return _tr; };
return dummyAOI; return dummyAOI;
}; }
et2_dataview_selectionManager.prototype._attachActionObject = function (_entry, _tr, _uid, _links, _idx) { _attachActionObject(_entry, _tr, _uid, _links, _idx) {
// Get the dummyAOI which connects the action object to the tr but // Get the dummyAOI which connects the action object to the tr but
// does no selection handling // does no selection handling
var dummyAOI = this._getDummyAOI(_entry, _tr, _uid, _idx); var dummyAOI = this._getDummyAOI(_entry, _tr, _uid, _idx);
@ -322,13 +322,13 @@ var et2_dataview_selectionManager = /** @class */ (function () {
} }
return result; return result;
}; };
}; }
et2_dataview_selectionManager.prototype._updateState = function (_uid, _state) { _updateState(_uid, _state) {
var entry = this._getRegisteredRowsEntry(_uid); var entry = this._getRegisteredRowsEntry(_uid);
this._updateEntryState(entry, _state); this._updateEntryState(entry, _state);
return entry; return entry;
}; }
et2_dataview_selectionManager.prototype._updateEntryState = function (_entry, _state) { _updateEntryState(_entry, _state) {
if (this._selectAll) { if (this._selectAll) {
_state |= EGW_AO_STATE_SELECTED; _state |= EGW_AO_STATE_SELECTED;
} }
@ -371,8 +371,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
} }
// Update the state of the entry // Update the state of the entry
_entry.state = _state; _entry.state = _state;
}; }
et2_dataview_selectionManager.prototype._getRegisteredRowsEntry = function (_uid) { _getRegisteredRowsEntry(_uid) {
if (typeof this._registeredRows[_uid] === "undefined") { if (typeof this._registeredRows[_uid] === "undefined") {
this._registeredRows[_uid] = { this._registeredRows[_uid] = {
"uid": _uid, "uid": _uid,
@ -384,8 +384,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
}; };
} }
return this._registeredRows[_uid]; return this._registeredRows[_uid];
}; }
et2_dataview_selectionManager.prototype._handleSelect = function (_uid, _entry, _shift, _ctrl) { _handleSelect(_uid, _entry, _shift, _ctrl) {
// If not "_ctrl" is set, reset the selection // If not "_ctrl" is set, reset the selection
if (!_ctrl) { if (!_ctrl) {
var top = this; var top = this;
@ -408,8 +408,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
if (this.select_callback && typeof this.select_callback == "function") { if (this.select_callback && typeof this.select_callback == "function") {
this.select_callback.apply(this._context, arguments); this.select_callback.apply(this._context, arguments);
} }
}; }
et2_dataview_selectionManager.prototype._selectRange = function (_start, _stop) { _selectRange(_start, _stop) {
// Contains ranges that are not currently in the index map and that have // Contains ranges that are not currently in the index map and that have
// to be queried // to be queried
var queryRanges = []; var queryRanges = [];
@ -455,8 +455,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
if (queryRanges.length > 0) { if (queryRanges.length > 0) {
this._query_ranges(queryRanges); this._query_ranges(queryRanges);
} }
}; }
et2_dataview_selectionManager.prototype._query_ranges = function (queryRanges) { _query_ranges(queryRanges) {
var that = this; var that = this;
var record_count = 0; var record_count = 0;
var range_index = 0; var range_index = 0;
@ -513,11 +513,9 @@ var et2_dataview_selectionManager = /** @class */ (function () {
fetchPromise.finally(function () { fetchPromise.finally(function () {
dialog.destroy(); dialog.destroy();
}); });
}; }
// Maximum number of rows we can safely fetch for selection }
// Actual selection may have more rows if we already have some // Maximum number of rows we can safely fetch for selection
et2_dataview_selectionManager.MAX_SELECTION = 1000; // Actual selection may have more rows if we already have some
return et2_dataview_selectionManager; et2_dataview_selectionManager.MAX_SELECTION = 1000;
}());
exports.et2_dataview_selectionManager = et2_dataview_selectionManager;
//# sourceMappingURL=et2_dataview_controller_selection.js.map //# sourceMappingURL=et2_dataview_controller_selection.js.map

View File

@ -4,10 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* */
/*egw:uses /*egw:uses
et2_dataview_view_aoi; et2_dataview_view_aoi;
@ -15,6 +15,11 @@
egw_action.egw_keymanager; egw_action.egw_keymanager;
*/ */
import {egw} from "../jsapi/egw_global";
import {et2_bounds} from "./et2_core_common";
import {et2_dialog} from "./et2_widget_dialog";
import {et2_createWidget} from "./et2_core_widget";
/** /**
* The selectioManager is internally used by the et2_dataview_controller class * The selectioManager is internally used by the et2_dataview_controller class
* to manage the row selection. * to manage the row selection.
@ -41,8 +46,8 @@ export class et2_dataview_selectionManager
private select_callback: null; private select_callback: null;
private _context: any; private _context: any;
private _registeredRows: {}; _registeredRows: {};
private _focusedEntry: null; _focusedEntry: null;
private _invertSelection: boolean; private _invertSelection: boolean;
private _selectAll: boolean; private _selectAll: boolean;
private _inUpdate: boolean; private _inUpdate: boolean;

View File

@ -1,26 +1,27 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Contains interfaces used inside the dataview * EGroupware eTemplate2 - Contains interfaces used inside the dataview
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); /*egw:uses
var et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable"; et2_core_inheritance;
function implements_et2_dataview_IInvalidatable(obj) { */
import { implements_methods, et2_implements_registry } from "./et2_core_interfaces";
export const et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable";
et2_implements_registry.et2_dataview_IInvalidatable = function (obj) {
return implements_methods(obj, ["invalidate"]); return implements_methods(obj, ["invalidate"]);
} };
var et2_dataview_IViewRange = "et2_dataview_IViewRange"; export const et2_dataview_IViewRange = "et2_dataview_IViewRange";
function implements_et2_dataview_IViewRange(obj) { et2_implements_registry.et2_dataview_IViewRange = function (obj) {
return implements_methods(obj, ["setViewRange"]); return implements_methods(obj, ["setViewRange"]);
} };
var et2_IDataProvider = "et2_IDataProvider"; export const et2_IDataProvider = "et2_IDataProvider";
function implements_et2_IDataProvider(obj) { et2_implements_registry.et2_IDataProvider = function (obj) {
return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]); return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]);
} };
//# sourceMappingURL=et2_dataview_interfaces.js.map //# sourceMappingURL=et2_dataview_interfaces.js.map

View File

@ -4,22 +4,24 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
et2_core_inheritance; et2_core_inheritance;
*/ */
import {implements_methods,et2_implements_registry} from "./et2_core_interfaces";
import type {et2_widget} from "./et2_core_widget";
export interface et2_dataview_IInvalidatable export interface et2_dataview_IInvalidatable
{ {
invalidate() invalidate()
} }
var et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable"; export const et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable";
function implements_et2_dataview_IInvalidatable(obj : et2_widget) et2_implements_registry.et2_dataview_IInvalidatable = function(obj : et2_widget)
{ {
return implements_methods(obj, ["invalidate"]); return implements_methods(obj, ["invalidate"]);
} }
@ -27,8 +29,8 @@ export interface et2_dataview_IViewRange
{ {
setViewRange(_range) setViewRange(_range)
} }
var et2_dataview_IViewRange = "et2_dataview_IViewRange"; export const et2_dataview_IViewRange = "et2_dataview_IViewRange";
function implements_et2_dataview_IViewRange(obj : et2_widget) et2_implements_registry.et2_dataview_IViewRange = function(obj : et2_widget)
{ {
return implements_methods(obj, ["setViewRange"]); return implements_methods(obj, ["setViewRange"]);
} }
@ -101,8 +103,8 @@ export interface et2_IDataProvider
dataUnregisterUID (_uid : string, _callback : Function, _context : object) dataUnregisterUID (_uid : string, _callback : Function, _context : object)
} }
var et2_IDataProvider = "et2_IDataProvider"; export const et2_IDataProvider = "et2_IDataProvider";
function implements_et2_IDataProvider(obj : et2_widget) et2_implements_registry.et2_IDataProvider = function(obj : et2_widget)
{ {
return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]); return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]);
} }

113
api/js/etemplate/et2_dataview_model_columns.js Executable file → Normal file
View File

@ -1,31 +1,28 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Class which contains a the columns model * EGroupware eTemplate2 - Class which contains a the columns model
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_columns = exports.et2_dataview_column = void 0;
/*egw:uses /*egw:uses
et2_core_inheritance; et2_core_inheritance;
et2_inheritance; et2_inheritance;
*/ */
import { egw } from "../jsapi/egw_global";
/** /**
* Class which stores the data of a single column. * Class which stores the data of a single column.
* *
* @augments Class * @augments Class
*/ */
var et2_dataview_column = /** @class */ (function () { export class et2_dataview_column {
/** /**
* Constructor * Constructor
*/ */
function et2_dataview_column(_attrs) { constructor(_attrs) {
/** /**
* Defines the visibility state of this column. * Defines the visibility state of this column.
*/ */
@ -78,7 +75,7 @@ var et2_dataview_column = /** @class */ (function () {
* *
* @param {float|string} _value * @param {float|string} _value
*/ */
et2_dataview_column.prototype.set_width = function (_value) { set_width(_value) {
// Parse the width parameter. // Parse the width parameter.
this.relativeWidth = false; this.relativeWidth = false;
this.fixedWidth = false; this.fixedWidth = false;
@ -99,8 +96,8 @@ var et2_dataview_column = /** @class */ (function () {
else if (typeof w == 'string' && !isNaN(parseFloat(w))) { else if (typeof w == 'string' && !isNaN(parseFloat(w))) {
this.fixedWidth = parseInt(w); this.fixedWidth = parseInt(w);
} }
}; }
et2_dataview_column.prototype.set_visibility = function (_value) { set_visibility(_value) {
// If visibility is always, don't turn it off // If visibility is always, don't turn it off
if (this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS || this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT) if (this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS || this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT)
return; return;
@ -116,15 +113,16 @@ var et2_dataview_column = /** @class */ (function () {
else { else {
egw().debug("warn", "Invalid visibility option for column: ", _value); egw().debug("warn", "Invalid visibility option for column: ", _value);
} }
}; }
et2_dataview_column.ET2_COL_TYPE_DEFAULT = 0; }
et2_dataview_column.ET2_COL_TYPE_NAME_ICON_FIXED = 1; et2_dataview_column.ET2_COL_TYPE_DEFAULT = 0;
et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS = 0; et2_dataview_column.ET2_COL_TYPE_NAME_ICON_FIXED = 1;
et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE = 1; et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS = 0;
et2_dataview_column.ET2_COL_VISIBILITY_INVISIBLE = 2; et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE = 1;
et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3; et2_dataview_column.ET2_COL_VISIBILITY_INVISIBLE = 2;
et2_dataview_column.ET2_COL_VISIBILITY_DISABLED = 4; et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
et2_dataview_column._attributes = { et2_dataview_column.ET2_COL_VISIBILITY_DISABLED = 4;
et2_dataview_column._attributes = {
"id": { "id": {
"name": "ID", "name": "ID",
"type": "string", "type": "string",
@ -167,17 +165,14 @@ var et2_dataview_column = /** @class */ (function () {
"default": 0, "default": 0,
"description": "Maximum width of the column" "description": "Maximum width of the column"
} }
}; };
return et2_dataview_column;
}());
exports.et2_dataview_column = et2_dataview_column;
/** /**
* Contains logic for the columns class. The columns class represents the unique set * Contains logic for the columns class. The columns class represents the unique set
* of columns a grid view owns. The parameters of the columns (except for visibility) * of columns a grid view owns. The parameters of the columns (except for visibility)
* do normaly not change. * do normaly not change.
*/ */
var et2_dataview_columns = /** @class */ (function () { export class et2_dataview_columns {
function et2_dataview_columns(_columnData) { constructor(_columnData) {
// Initialize some variables // Initialize some variables
this._totalWidth = 0; this._totalWidth = 0;
this._totalFixed = 0; this._totalFixed = 0;
@ -189,71 +184,63 @@ var et2_dataview_columns = /** @class */ (function () {
} }
this._updated = true; this._updated = true;
} }
et2_dataview_columns.prototype.destroy = function () { destroy() {
// Free all column objects // Free all column objects
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
this.columns[i] = null; this.columns[i] = null;
} }
}; }
et2_dataview_columns.prototype.updated = function () { updated() {
this._updated = true; this._updated = true;
}; }
et2_dataview_columns.prototype.columnCount = function () { columnCount() {
return this.columns.length; return this.columns.length;
}; }
Object.defineProperty(et2_dataview_columns.prototype, "totalWidth", { get totalWidth() {
get: function () {
return this._totalWidth; return this._totalWidth;
}, }
enumerable: false, get totalFixed() {
configurable: true
});
Object.defineProperty(et2_dataview_columns.prototype, "totalFixed", {
get: function () {
return this._totalFixed ? this._totalFixed : 0; return this._totalFixed ? this._totalFixed : 0;
}, }
enumerable: false,
configurable: true
});
/** /**
* Set the total width of the header row * Set the total width of the header row
* *
* @param {(string|number)} _width * @param {(string|number)} _width
*/ */
et2_dataview_columns.prototype.setTotalWidth = function (_width) { setTotalWidth(_width) {
if (_width != this._totalWidth && _width > 0) { if (_width != this._totalWidth && _width > 0) {
this._totalWidth = _width; this._totalWidth = _width;
this._updated = true; this._updated = true;
} }
}; }
/** /**
* Returns the index of the colum with the given id * Returns the index of the colum with the given id
* *
* @param {string} _id * @param {string} _id
*/ */
et2_dataview_columns.prototype.getColumnIndexById = function (_id) { getColumnIndexById(_id) {
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
if (this.columns[i].id == _id) { if (this.columns[i].id == _id) {
return i; return i;
} }
} }
return -1; return -1;
}; }
/** /**
* Returns the column with the given id * Returns the column with the given id
* *
* @param {string} _id * @param {string} _id
*/ */
et2_dataview_columns.prototype.getColumnById = function (_id) { getColumnById(_id) {
var idx = this.getColumnIndexById(_id); var idx = this.getColumnIndexById(_id);
return (idx == -1) ? null : this.columns[idx]; return (idx == -1) ? null : this.columns[idx];
}; }
/** /**
* Returns the width of the column with the given index * Returns the width of the column with the given index
* *
* @param {number} _idx * @param {number} _idx
*/ */
et2_dataview_columns.prototype.getColumnWidth = function (_idx) { getColumnWidth(_idx) {
if (this._totalWidth > 0 && _idx >= 0 && _idx < this.columns.length) { if (this._totalWidth > 0 && _idx >= 0 && _idx < this.columns.length) {
// Recalculate the column widths if something has changed. // Recalculate the column widths if something has changed.
if (this._updated) { if (this._updated) {
@ -264,12 +251,12 @@ var et2_dataview_columns = /** @class */ (function () {
return this.columnWidths[_idx]; return this.columnWidths[_idx];
} }
return 0; return 0;
}; }
/** /**
* Returns an array containing the width of the column and its visibility * Returns an array containing the width of the column and its visibility
* state. * state.
*/ */
et2_dataview_columns.prototype.getColumnData = function () { getColumnData() {
var result = []; var result = [];
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
result.push({ result.push({
@ -280,12 +267,12 @@ var et2_dataview_columns = /** @class */ (function () {
}); });
} }
return result; return result;
}; }
/** /**
* Returns an associative array which contains data about the visibility * Returns an associative array which contains data about the visibility
* state of the columns. * state of the columns.
*/ */
et2_dataview_columns.prototype.getColumnVisibilitySet = function () { getColumnVisibilitySet() {
var result = {}; var result = {};
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
if (this.columns[i].visibility != et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT) { if (this.columns[i].visibility != et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT) {
@ -299,13 +286,13 @@ var et2_dataview_columns = /** @class */ (function () {
} }
} }
return result; return result;
}; }
/** /**
* Sets a column visiblity set * Sets a column visiblity set
* *
* @param {object} _set * @param {object} _set
*/ */
et2_dataview_columns.prototype.setColumnVisibilitySet = function (_set) { setColumnVisibilitySet(_set) {
for (var k in _set) { for (var k in _set) {
var col = this.getColumnById(k); var col = this.getColumnById(k);
if (col) { if (col) {
@ -314,16 +301,16 @@ var et2_dataview_columns = /** @class */ (function () {
} }
} }
this._updated = true; this._updated = true;
}; }
/* ---- PRIVATE FUNCTIONS ---- */ /* ---- PRIVATE FUNCTIONS ---- */
/** /**
* Calculates the absolute column width depending on the previously set * Calculates the absolute column width depending on the previously set
* "totalWidth" value. The calculated values are stored in the columnWidths * "totalWidth" value. The calculated values are stored in the columnWidths
* array. * array.
*/ */
et2_dataview_columns.prototype._calculateWidths = function () { _calculateWidths() {
// Reset some values which are used during the calculation // Reset some values which are used during the calculation
var _larger = Array(this.columns.length); let _larger = Array(this.columns.length);
for (var i = 0; i < this.columns.length; i++) { for (var i = 0; i < this.columns.length; i++) {
_larger[i] = false; _larger[i] = false;
} }
@ -424,8 +411,6 @@ var et2_dataview_columns = /** @class */ (function () {
this.columnWidths[columnIndex] = Math.max(column.minWidth, this.columnWidths[columnIndex] - remaining_width); this.columnWidths[columnIndex] = Math.max(column.minWidth, this.columnWidths[columnIndex] - remaining_width);
} }
} }
}; }
return et2_dataview_columns; }
}());
exports.et2_dataview_columns = et2_dataview_columns;
//# sourceMappingURL=et2_dataview_model_columns.js.map //# sourceMappingURL=et2_dataview_model_columns.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -16,6 +15,8 @@
*/ */
import {egw} from "../jsapi/egw_global";
/** /**
* Class which stores the data of a single column. * Class which stores the data of a single column.
* *

View File

@ -4,53 +4,40 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
egw_action.egw_action_common; egw_action.egw_action_common;
egw_action.egw_action; egw_action.egw_action;
/vendor/bower-asset/jquery-touchswipe/jquery.touchSwipe.js; /vendor/bower-asset/jquery-touchswipe/jquery.touchSwipe.js;
*/ */
/** /**
* Contains the action object interface implementation for the nextmatch widget * Contains the action object interface implementation for the nextmatch widget
* row. * row.
*/ */
export const EGW_SELECTMODE_DEFAULT = 0;
var EGW_SELECTMODE_DEFAULT = 0; export const EGW_SELECTMODE_TOGGLE = 1;
var EGW_SELECTMODE_TOGGLE = 1;
/** /**
* An action object interface for each nextmatch widget row - "inherits" from * An action object interface for each nextmatch widget row - "inherits" from
* egwActionObjectInterface * egwActionObjectInterface
* *
* @param {DOMNode} _node * @param {DOMNode} _node
*/ */
function et2_dataview_rowAOI(_node) export function et2_dataview_rowAOI(_node) {
{
"use strict"; "use strict";
var aoi = new egwActionObjectInterface(); var aoi = new egwActionObjectInterface();
aoi.node = _node; aoi.node = _node;
aoi.selectMode = EGW_SELECTMODE_DEFAULT; aoi.selectMode = EGW_SELECTMODE_DEFAULT;
aoi.checkBox = null; //(jQuery(":checkbox", aoi.node))[0]; aoi.checkBox = null; //(jQuery(":checkbox", aoi.node))[0];
// Rows without a checkbox OR an id set are unselectable // Rows without a checkbox OR an id set are unselectable
aoi.doGetDOMNode = function() { aoi.doGetDOMNode = function () {
return aoi.node; return aoi.node;
}; };
// Prevent the browser from selecting the content of the element, when // Prevent the browser from selecting the content of the element, when
// a special key is pressed. // a special key is pressed.
jQuery(_node).mousedown(egwPreventSelect); jQuery(_node).mousedown(egwPreventSelect);
/** /**
* Now append some action code to the node * Now append some action code to the node
* *
@ -58,31 +45,25 @@ function et2_dataview_rowAOI(_node)
* @param {DOMEvent} e * @param {DOMEvent} e
* @param {object} _params * @param {object} _params
*/ */
var selectHandler = function(e, _params) { var selectHandler = function (e, _params) {
// Reset the focus so that keyboard navigation will work properly // Reset the focus so that keyboard navigation will work properly
// after the element has been clicked // after the element has been clicked
egwUnfocus(); egwUnfocus();
// Reset the prevent selection code (in order to allow wanted // Reset the prevent selection code (in order to allow wanted
// selection of text) // selection of text)
_node.onselectstart = null; _node.onselectstart = null;
if (e.target != aoi.checkBox) {
if (e.target != aoi.checkBox)
{
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED); var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
var state = egwGetShiftState(e); var state = egwGetShiftState(e);
if (_params) {
if (_params) if (egwIsMobile()) {
{ switch (_params.swip) {
if (egwIsMobile())
{
switch (_params.swip)
{
case "left": case "left":
case "right": case "right":
state = 1; state = 1;
// Hide context menu on swip actions // Hide context menu on swip actions
if(_egw_active_menu) _egw_active_menu.hide(); if (_egw_active_menu)
_egw_active_menu.hide();
break; break;
case "up": case "up":
case "down": case "down":
@ -90,62 +71,47 @@ function et2_dataview_rowAOI(_node)
} }
} }
} }
switch (aoi.selectMode) switch (aoi.selectMode) {
{
case EGW_SELECTMODE_DEFAULT: case EGW_SELECTMODE_DEFAULT:
aoi.updateState(EGW_AO_STATE_SELECTED, aoi.updateState(EGW_AO_STATE_SELECTED, !egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected, state);
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
state);
break; break;
case EGW_SELECTMODE_TOGGLE: case EGW_SELECTMODE_TOGGLE:
aoi.updateState(EGW_AO_STATE_SELECTED, !selected, aoi.updateState(EGW_AO_STATE_SELECTED, !selected, egwSetBit(state, EGW_AO_SHIFT_STATE_MULTI, true));
egwSetBit(state, EGW_AO_SHIFT_STATE_MULTI, true));
break; break;
} }
} }
}; };
if (egwIsMobile()) { if (egwIsMobile()) {
jQuery(_node).swipe({ jQuery(_node).swipe({
allowPageScroll: "vertical", allowPageScroll: "vertical",
longTapThreshold: 10, longTapThreshold: 10,
swipe: function (event, direction, distance) swipe: function (event, direction, distance) {
{ if (distance > 100)
if (distance > 100) selectHandler(event, {swip:direction}); selectHandler(event, { swip: direction });
}, },
tap: function (event, duration) tap: function (event, duration) {
{
selectHandler(event); selectHandler(event);
}, },
// stop scrolling touch being confused from tap // stop scrolling touch being confused from tap
longTap: function (event) longTap: function (event) {
{
return; return;
} }
}); });
} else { }
else {
jQuery(_node).click(selectHandler); jQuery(_node).click(selectHandler);
} }
jQuery(aoi.checkBox).change(function () {
jQuery(aoi.checkBox).change(function() {
aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI); aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI);
}); });
aoi.doSetState = function (_state) {
aoi.doSetState = function(_state) {
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED); var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
if (this.checkBox) {
if (this.checkBox)
{
this.checkBox.checked = selected; this.checkBox.checked = selected;
} }
jQuery(this.node).toggleClass('focused', egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
jQuery(this.node).toggleClass('focused', jQuery(this.node).toggleClass('selected', selected);
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
jQuery(this.node).toggleClass('selected',
selected);
}; };
return aoi; return aoi;
} }
//# sourceMappingURL=et2_dataview_view_aoi.js.map

View File

@ -0,0 +1,150 @@
/**
* EGroupware eTemplate2 - Contains interfaces used inside the dataview
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage dataview
* @link https://www.egroupware.org
* @author Andreas Stöckel
* @copyright EGroupware GmbH 2011-2021
*/
/*egw:uses
egw_action.egw_action_common;
egw_action.egw_action;
/vendor/bower-asset/jquery-touchswipe/jquery.touchSwipe.js;
*/
/**
* Contains the action object interface implementation for the nextmatch widget
* row.
*/
export const EGW_SELECTMODE_DEFAULT = 0;
export const EGW_SELECTMODE_TOGGLE = 1;
/**
* An action object interface for each nextmatch widget row - "inherits" from
* egwActionObjectInterface
*
* @param {DOMNode} _node
*/
export function et2_dataview_rowAOI(_node)
{
"use strict";
var aoi = new egwActionObjectInterface();
aoi.node = _node;
aoi.selectMode = EGW_SELECTMODE_DEFAULT;
aoi.checkBox = null; //(jQuery(":checkbox", aoi.node))[0];
// Rows without a checkbox OR an id set are unselectable
aoi.doGetDOMNode = function() {
return aoi.node;
};
// Prevent the browser from selecting the content of the element, when
// a special key is pressed.
jQuery(_node).mousedown(egwPreventSelect);
/**
* Now append some action code to the node
*
* @memberOf et2_dataview_rowAOI
* @param {DOMEvent} e
* @param {object} _params
*/
var selectHandler = function(e, _params) {
// Reset the focus so that keyboard navigation will work properly
// after the element has been clicked
egwUnfocus();
// Reset the prevent selection code (in order to allow wanted
// selection of text)
_node.onselectstart = null;
if (e.target != aoi.checkBox)
{
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
var state = egwGetShiftState(e);
if (_params)
{
if (egwIsMobile())
{
switch (_params.swip)
{
case "left":
case "right":
state = 1;
// Hide context menu on swip actions
if(_egw_active_menu) _egw_active_menu.hide();
break;
case "up":
case "down":
return;
}
}
}
switch (aoi.selectMode)
{
case EGW_SELECTMODE_DEFAULT:
aoi.updateState(EGW_AO_STATE_SELECTED,
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
state);
break;
case EGW_SELECTMODE_TOGGLE:
aoi.updateState(EGW_AO_STATE_SELECTED, !selected,
egwSetBit(state, EGW_AO_SHIFT_STATE_MULTI, true));
break;
}
}
};
if (egwIsMobile()) {
jQuery(_node).swipe({
allowPageScroll: "vertical",
longTapThreshold: 10,
swipe: function (event, direction, distance)
{
if (distance > 100) selectHandler(event, {swip:direction});
},
tap: function (event, duration)
{
selectHandler(event);
},
// stop scrolling touch being confused from tap
longTap: function (event)
{
return;
}
});
} else {
jQuery(_node).click(selectHandler);
}
jQuery(aoi.checkBox).change(function() {
aoi.updateState(EGW_AO_STATE_SELECTED, this.checked, EGW_AO_SHIFT_STATE_MULTI);
});
aoi.doSetState = function(_state) {
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
if (this.checkBox)
{
this.checkBox.checked = selected;
}
jQuery(this.node).toggleClass('focused',
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
jQuery(this.node).toggleClass('selected',
selected);
};
return aoi;
}

View File

@ -1,17 +1,15 @@
"use strict";
/** /**
* EGroupware eTemplate2 - dataview code * EGroupware eTemplate2 - dataview code
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ * @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); import { et2_bounds } from "./et2_core_common";
exports.et2_dataview_container = void 0;
/** /**
* The et2_dataview_container class is the main object each dataview consits of. * The et2_dataview_container class is the main object each dataview consits of.
* Each row, spacer as well as the grid itself are containers. A container is * Each row, spacer as well as the grid itself are containers. A container is
@ -28,7 +26,7 @@ exports.et2_dataview_container = void 0;
* *
* @augments Class * @augments Class
*/ */
var et2_dataview_container = /** @class */ (function () { export class et2_dataview_container {
/** /**
* Initializes the container object. * Initializes the container object.
* *
@ -36,7 +34,7 @@ var et2_dataview_container = /** @class */ (function () {
* interface. _parent may not be null. * interface. _parent may not be null.
* @memberOf et2_dataview_container * @memberOf et2_dataview_container
*/ */
function et2_dataview_container(_parent) { constructor(_parent) {
// Copy the given invalidation element // Copy the given invalidation element
this._parent = _parent; this._parent = _parent;
this._nodes = []; this._nodes = [];
@ -53,14 +51,14 @@ var et2_dataview_container = /** @class */ (function () {
* should override this method and take care of unregistering all event * should override this method and take care of unregistering all event
* handlers etc. * handlers etc.
*/ */
et2_dataview_container.prototype.destroy = function () { destroy() {
// Remove the nodes from the tree // Remove the nodes from the tree
this.removeFromTree(); this.removeFromTree();
// Call the callback function (if one is registered) // Call the callback function (if one is registered)
if (this._destroyCallback) { if (this._destroyCallback) {
this._destroyCallback.call(this._destroyContext, this); this._destroyCallback.call(this._destroyContext, this);
} }
}; }
/** /**
* Sets the "destroyCallback" -- the given function gets called whenever * Sets the "destroyCallback" -- the given function gets called whenever
* the container is destroyed. This instance is passed as an parameter to * the container is destroyed. This instance is passed as an parameter to
@ -69,10 +67,10 @@ var et2_dataview_container = /** @class */ (function () {
* @param {function} _callback * @param {function} _callback
* @param {object} _context * @param {object} _context
*/ */
et2_dataview_container.prototype.setDestroyCallback = function (_callback, _context) { setDestroyCallback(_callback, _context) {
this._destroyCallback = _callback; this._destroyCallback = _callback;
this._destroyContext = _context; this._destroyContext = _context;
}; }
/** /**
* Inserts all container nodes into the DOM tree after or before the given * Inserts all container nodes into the DOM tree after or before the given
* element. * element.
@ -83,13 +81,13 @@ var et2_dataview_container = /** @class */ (function () {
* or after the given node. Inserting before is needed for inserting the * or after the given node. Inserting before is needed for inserting the
* first element in front of an spacer. * first element in front of an spacer.
*/ */
et2_dataview_container.prototype.insertIntoTree = function (_node, _prepend) { insertIntoTree(_node, _prepend) {
if (!this._inTree && _node != null && this._nodes.length > 0) { if (!this._inTree && _node != null && this._nodes.length > 0) {
// Store the parent node and indicate that this element is now in // Store the parent node and indicate that this element is now in
// the tree. // the tree.
this._attachData = { node: _node, prepend: _prepend }; this._attachData = { node: _node, prepend: _prepend };
this._inTree = true; this._inTree = true;
for (var i = 0; i < this._nodes.length; i++) { for (let i = 0; i < this._nodes.length; i++) {
if (i == 0) { if (i == 0) {
if (_prepend) { if (_prepend) {
_node.before(this._nodes[0]); _node.before(this._nodes[0]);
@ -107,28 +105,28 @@ var et2_dataview_container = /** @class */ (function () {
// parent // parent
this.invalidate(); this.invalidate();
} }
}; }
/** /**
* Removes all container nodes from the tree. * Removes all container nodes from the tree.
*/ */
et2_dataview_container.prototype.removeFromTree = function () { removeFromTree() {
if (this._inTree) { if (this._inTree) {
// Call the jQuery remove function to remove all nodes from the tree // Call the jQuery remove function to remove all nodes from the tree
// again. // again.
for (var i = 0; i < this._nodes.length; i++) { for (let i = 0; i < this._nodes.length; i++) {
this._nodes[i].remove(); this._nodes[i].remove();
} }
// Reset the "attachData" // Reset the "attachData"
this._inTree = false; this._inTree = false;
this._attachData = { "node": null, "prepend": false }; this._attachData = { "node": null, "prepend": false };
} }
}; }
/** /**
* Appends a node to the container. * Appends a node to the container.
* *
* @param _node is the DOM-Node which should be appended. * @param _node is the DOM-Node which should be appended.
*/ */
et2_dataview_container.prototype.appendNode = function (_node) { appendNode(_node) {
// Add the given node to the "nodes" array // Add the given node to the "nodes" array
this._nodes.push(_node); this._nodes.push(_node);
// If the container is already in the tree, attach the given node to the // If the container is already in the tree, attach the given node to the
@ -147,15 +145,15 @@ var et2_dataview_container = /** @class */ (function () {
} }
this.invalidate(); this.invalidate();
} }
}; }
/** /**
* Removes a certain node from the container * Removes a certain node from the container
* *
* @param {HTMLElement} _node * @param {HTMLElement} _node
*/ */
et2_dataview_container.prototype.removeNode = function (_node) { removeNode(_node) {
// Get the index of the node in the nodes array // Get the index of the node in the nodes array
var idx = this._nodes.indexOf(_node); const idx = this._nodes.indexOf(_node);
if (idx >= 0) { if (idx >= 0) {
// Remove the node if the container is currently attached // Remove the node if the container is currently attached
if (this._inTree) { if (this._inTree) {
@ -164,35 +162,35 @@ var et2_dataview_container = /** @class */ (function () {
// Remove the node from the nodes array // Remove the node from the nodes array
this._nodes.splice(idx, 1); this._nodes.splice(idx, 1);
} }
}; }
/** /**
* Returns the last node of the container - new nodes have to be appended * Returns the last node of the container - new nodes have to be appended
* after it. * after it.
*/ */
et2_dataview_container.prototype.getLastNode = function () { getLastNode() {
if (this._nodes.length > 0) { if (this._nodes.length > 0) {
return this._nodes[this._nodes.length - 1]; return this._nodes[this._nodes.length - 1];
} }
return null; return null;
}; }
/** /**
* Returns the first node of the container. * Returns the first node of the container.
*/ */
et2_dataview_container.prototype.getFirstNode = function () { getFirstNode() {
return this._nodes.length > 0 ? this._nodes[0] : null; return this._nodes.length > 0 ? this._nodes[0] : null;
}; }
/** /**
* Returns the accumulated height of all container nodes. Only visible nodes * Returns the accumulated height of all container nodes. Only visible nodes
* (without "display: none" etc.) are taken into account. * (without "display: none" etc.) are taken into account.
*/ */
et2_dataview_container.prototype.getHeight = function () { getHeight() {
if (this._height === -1 && this._inTree) { if (this._height === -1 && this._inTree) {
this._height = 0; this._height = 0;
// Setting this before measuring height helps with issues getting the // Setting this before measuring height helps with issues getting the
// wrong height due to margins & collapsed borders // wrong height due to margins & collapsed borders
this.tr.css('display', 'block'); this.tr.css('display', 'block');
// Increment the height value for each visible container node // Increment the height value for each visible container node
for (var i = 0; i < this._nodes.length; i++) { for (let i = 0; i < this._nodes.length; i++) {
if (et2_dataview_container._isVisible(this._nodes[i][0])) { if (et2_dataview_container._isVisible(this._nodes[i][0])) {
this._height += et2_dataview_container._nodeHeight(this._nodes[i][0]); this._height += et2_dataview_container._nodeHeight(this._nodes[i][0]);
} }
@ -200,7 +198,7 @@ var et2_dataview_container = /** @class */ (function () {
this.tr.css('display', ''); this.tr.css('display', '');
} }
return (this._height === -1) ? 0 : this._height; return (this._height === -1) ? 0 : this._height;
}; }
/** /**
* Returns a datastructure containing information used for calculating the * Returns a datastructure containing information used for calculating the
* average row height of a grid. * average row height of a grid.
@ -210,64 +208,64 @@ var et2_dataview_container = /** @class */ (function () {
* avgCount: <the element count this calculation was based on> * avgCount: <the element count this calculation was based on>
* } * }
*/ */
et2_dataview_container.prototype.getAvgHeightData = function () { getAvgHeightData() {
return { return {
"avgHeight": this.getHeight(), "avgHeight": this.getHeight(),
"avgCount": 1 "avgCount": 1
}; };
}; }
/** /**
* Returns the previously set "pixel top" of the container. * Returns the previously set "pixel top" of the container.
*/ */
et2_dataview_container.prototype.getTop = function () { getTop() {
return this._top; return this._top;
}; }
/** /**
* Returns the "pixel bottom" of the container. * Returns the "pixel bottom" of the container.
*/ */
et2_dataview_container.prototype.getBottom = function () { getBottom() {
return this._top + this.getHeight(); return this._top + this.getHeight();
}; }
/** /**
* Returns the range of the element. * Returns the range of the element.
*/ */
et2_dataview_container.prototype.getRange = function () { getRange() {
return et2_bounds(this.getTop(), this.getBottom()); return et2_bounds(this.getTop(), this.getBottom());
}; }
/** /**
* Returns the index of the element. * Returns the index of the element.
*/ */
et2_dataview_container.prototype.getIndex = function () { getIndex() {
return this._index; return this._index;
}; }
/** /**
* Returns how many elements this container represents. * Returns how many elements this container represents.
*/ */
et2_dataview_container.prototype.getCount = function () { getCount() {
return 1; return 1;
}; }
/** /**
* Sets the top of the element. * Sets the top of the element.
* *
* @param {number} _value * @param {number} _value
*/ */
et2_dataview_container.prototype.setTop = function (_value) { setTop(_value) {
this._top = _value; this._top = _value;
}; }
/** /**
* Sets the index of the element. * Sets the index of the element.
* *
* @param {number} _value * @param {number} _value
*/ */
et2_dataview_container.prototype.setIndex = function (_value) { setIndex(_value) {
this._index = _value; this._index = _value;
}; }
/* -- et2_dataview_IInvalidatable -- */ /* -- et2_dataview_IInvalidatable -- */
/** /**
* Broadcasts an invalidation through the container tree. Marks the own * Broadcasts an invalidation through the container tree. Marks the own
* height as invalid. * height as invalid.
*/ */
et2_dataview_container.prototype.invalidate = function () { invalidate() {
// Abort if this element is already marked as invalid. // Abort if this element is already marked as invalid.
if (this._height !== -1) { if (this._height !== -1) {
// Delete the own, probably computed height // Delete the own, probably computed height
@ -275,7 +273,7 @@ var et2_dataview_container = /** @class */ (function () {
// Broadcast the invalidation to the parent element // Broadcast the invalidation to the parent element
this._parent.invalidate(); this._parent.invalidate();
} }
}; }
/* -- PRIVATE FUNCTIONS -- */ /* -- PRIVATE FUNCTIONS -- */
/** /**
* Used to check whether an element is visible or not (non recursive). * Used to check whether an element is visible or not (non recursive).
@ -284,31 +282,29 @@ var et2_dataview_container = /** @class */ (function () {
* only checked whether some stylesheet makes the element invisible, not if * only checked whether some stylesheet makes the element invisible, not if
* the given object is actually inside the DOM. * the given object is actually inside the DOM.
*/ */
et2_dataview_container._isVisible = function (_obj) { static _isVisible(_obj) {
// Check whether the element is localy invisible // Check whether the element is localy invisible
if (_obj.style && (_obj.style.display === "none" if (_obj.style && (_obj.style.display === "none"
|| _obj.style.visibility === "none")) { || _obj.style.visibility === "none")) {
return false; return false;
} }
// Get the computed style of the element // Get the computed style of the element
var style = window.getComputedStyle ? window.getComputedStyle(_obj, null) const style = window.getComputedStyle ? window.getComputedStyle(_obj, null)
// @ts-ignore // @ts-ignore
: _obj.currentStyle; : _obj.currentStyle;
if (style.display === "none" || style.visibility === "none") { if (style.display === "none" || style.visibility === "none") {
return false; return false;
} }
return true; return true;
}; }
/** /**
* Returns the height of a node in pixels and zero if the element is not * Returns the height of a node in pixels and zero if the element is not
* visible. The height is clamped to positive values. * visible. The height is clamped to positive values.
* *
* @param {HTMLElement} _node * @param {HTMLElement} _node
*/ */
et2_dataview_container._nodeHeight = function (_node) { static _nodeHeight(_node) {
return _node.offsetHeight; return _node.offsetHeight;
}; }
return et2_dataview_container; }
}());
exports.et2_dataview_container = et2_dataview_container;
//# sourceMappingURL=et2_dataview_view_container.js.map //# sourceMappingURL=et2_dataview_view_container.js.map

View File

@ -4,9 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ * @version $Id$
*/ */
@ -16,6 +16,7 @@
*/ */
import {et2_dataview_IInvalidatable} from "./et2_dataview_interfaces"; import {et2_dataview_IInvalidatable} from "./et2_dataview_interfaces";
import {et2_bounds} from "./et2_core_common";
/** /**
* The et2_dataview_container class is the main object each dataview consits of. * The et2_dataview_container class is the main object each dataview consits of.

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
@ -23,6 +22,8 @@ import {et2_dataview_IViewRange} from "./et2_dataview_interfaces";
import {et2_dataview_container} from "./et2_dataview_view_container"; import {et2_dataview_container} from "./et2_dataview_view_container";
import {et2_dataview_spacer} from "./et2_dataview_view_spacer"; import {et2_dataview_spacer} from "./et2_dataview_view_spacer";
import {et2_dataview_rowProvider} from "./et2_dataview_view_rowProvider"; import {et2_dataview_rowProvider} from "./et2_dataview_view_rowProvider";
import {et2_bounds, et2_range, et2_rangeEqual, et2_rangeIntersect} from "./et2_core_common";
import { egw } from "../jsapi/egw_global";
export class et2_dataview_grid extends et2_dataview_container implements et2_dataview_IViewRange export class et2_dataview_grid extends et2_dataview_container implements et2_dataview_IViewRange
{ {
@ -65,16 +66,16 @@ export class et2_dataview_grid extends et2_dataview_container implements et2_dat
private _invalidateTimeout: number; private _invalidateTimeout: number;
private _invalidateCallback: Function; private _invalidateCallback: Function;
private _invalidateContext: null; private _invalidateContext: null;
private doInvalidate : boolean; doInvalidate : boolean;
private _map: any[]; private _map: any[];
private _viewRange: { top: any; bottom: any }; private _viewRange: { top: any; bottom: any };
private _total: number; _total: number;
private _avgHeight: number | boolean; private _avgHeight: number | boolean;
private _avgCount: number; private _avgCount: number;
private scrollarea: any; private scrollarea: any;
private innerTbody: any; innerTbody: any;
private outerCell: JQuery; private outerCell: JQuery;
@ -545,7 +546,7 @@ export class et2_dataview_grid extends et2_dataview_container implements et2_dat
const self = this; const self = this;
const _super = super.invalidate(); const _super = super.invalidate();
this._invalidateTimeout = window.setTimeout(function() { this._invalidateTimeout = window.setTimeout(function() {
egw.debug("log","Dataview grid timed invalidate"); this.egw.debug("log","Dataview grid timed invalidate");
// Clear the "_avgHeight" // Clear the "_avgHeight"
self._avgHeight = false; self._avgHeight = false;
self._avgCount = -1; self._avgCount = -1;
@ -794,8 +795,7 @@ export class et2_dataview_grid extends et2_dataview_container implements et2_dat
// Check which type the container object has // Check which type the container object has
const isSpacer = container instanceof et2_dataview_spacer; const isSpacer = container instanceof et2_dataview_spacer;
const hasIViewRange = !isSpacer const hasIViewRange = !isSpacer && container.implements(et2_dataview_IViewRange);
&& implements_et2_dataview_IViewRange(container);
// If the container has one of those special types, calculate the // If the container has one of those special types, calculate the
// view range and use that to update the view range of the element // view range and use that to update the view range of the element

View File

@ -1,30 +1,25 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Functions which allow resizing of table headers * EGroupware eTemplate2 - Functions which allow resizing of table headers
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true }); import { egw } from "../jsapi/egw_global";
exports.et2_dataview_view_resizable = void 0;
/** /**
* This set of functions is currently only supporting resizing in ew-direction * This set of functions is currently only supporting resizing in ew-direction
*/ */
var et2_dataview_view_resizable = /** @class */ (function () { export class et2_dataview_view_resizable {
function et2_dataview_view_resizable() {
}
// In resize region returns whether the mouse is currently in the // In resize region returns whether the mouse is currently in the
// "resizeRegion" // "resizeRegion"
et2_dataview_view_resizable.inResizeRegion = function (_x, _elem) { static inResizeRegion(_x, _elem) {
var ol = _x - _elem.offset().left; var ol = _x - _elem.offset().left;
return (ol > (_elem.outerWidth(true) - et2_dataview_view_resizable.RESIZE_BORDER)); return (ol > (_elem.outerWidth(true) - et2_dataview_view_resizable.RESIZE_BORDER));
}; }
et2_dataview_view_resizable.startResize = function (_outerElem, _elem, _callback, _column) { static startResize(_outerElem, _elem, _callback, _column) {
if (this.overlay == null || this.helper == null) { if (this.overlay == null || this.helper == null) {
// Prevent text selection // Prevent text selection
// FireFox handles highlight prevention (text selection) different than other browsers // FireFox handles highlight prevention (text selection) different than other browsers
@ -67,8 +62,8 @@ var et2_dataview_view_resizable = /** @class */ (function () {
}.bind(this)) }.bind(this))
.appendTo("body"); .appendTo("body");
} }
}; }
et2_dataview_view_resizable.stopResize = function (_outerElem) { static stopResize(_outerElem) {
jQuery(_outerElem).removeClass('egwResizing'); jQuery(_outerElem).removeClass('egwResizing');
if (this.helper != null) { if (this.helper != null) {
this.helper.remove(); this.helper.remove();
@ -78,16 +73,17 @@ var et2_dataview_view_resizable = /** @class */ (function () {
this.overlay.remove(); this.overlay.remove();
this.overlay = null; this.overlay = null;
} }
}; }
// Define some constants }
et2_dataview_view_resizable.RESIZE_BORDER = 12; // Define some constants
et2_dataview_view_resizable.RESIZE_MIN_WIDTH = 25; et2_dataview_view_resizable.RESIZE_BORDER = 12;
et2_dataview_view_resizable.RESIZE_ADD = 2; // Used to ensure mouse is under the resize element after resizing has finished et2_dataview_view_resizable.RESIZE_MIN_WIDTH = 25;
et2_dataview_view_resizable.helper = null; et2_dataview_view_resizable.RESIZE_ADD = 2; // Used to ensure mouse is under the resize element after resizing has finished
et2_dataview_view_resizable.overlay = null; et2_dataview_view_resizable.helper = null;
et2_dataview_view_resizable.didResize = false; et2_dataview_view_resizable.overlay = null;
et2_dataview_view_resizable.resizeWidth = 0; et2_dataview_view_resizable.didResize = false;
et2_dataview_view_resizable.makeResizeable = function (_elem, _callback, _context) { et2_dataview_view_resizable.resizeWidth = 0;
et2_dataview_view_resizable.makeResizeable = function (_elem, _callback, _context) {
// Get the table surrounding the given element - this element is used to // Get the table surrounding the given element - this element is used to
// align the helper properly // align the helper properly
var outerTable = _elem.closest("table"); var outerTable = _elem.closest("table");
@ -173,12 +169,9 @@ var et2_dataview_view_resizable = /** @class */ (function () {
resize.css('width', ''); resize.css('width', '');
_callback.call(_context, max_width + padding); _callback.call(_context, max_width + padding);
}); });
}; };
et2_dataview_view_resizable.et2_dataview_resetResizeable = function (_elem) { et2_dataview_view_resizable.et2_dataview_resetResizeable = function (_elem) {
// Remove all events in the ".resize" namespace from the element // Remove all events in the ".resize" namespace from the element
_elem.unbind(".resize"); _elem.unbind(".resize");
}; };
return et2_dataview_view_resizable;
}());
exports.et2_dataview_view_resizable = et2_dataview_view_resizable;
//# sourceMappingURL=et2_dataview_view_resizeable.js.map //# sourceMappingURL=et2_dataview_view_resizeable.js.map

View File

@ -4,12 +4,13 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
import {egw} from "../jsapi/egw_global";
/** /**
* This set of functions is currently only supporting resizing in ew-direction * This set of functions is currently only supporting resizing in ew-direction
*/ */

View File

@ -1,69 +1,50 @@
"use strict";
/** /**
* EGroupware eTemplate2 - dataview * EGroupware eTemplate2 - dataview
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
egw_action.egw_action; egw_action.egw_action;
et2_dataview_view_container; et2_dataview_view_container;
*/ */
var __extends = (this && this.__extends) || (function () { import { et2_dataview_IViewRange } from "./et2_dataview_interfaces";
var extendStatics = function (d, b) { import { et2_dataview_container } from "./et2_dataview_view_container";
extendStatics = Object.setPrototypeOf || export class et2_dataview_row extends et2_dataview_container {
({ __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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_row = void 0;
var et2_dataview_row = /** @class */ (function (_super) {
__extends(et2_dataview_row, _super);
/** /**
* Creates the row container. Use the "setRow" function to load the actual * Creates the row container. Use the "setRow" function to load the actual
* row content. * row content.
* *
* @param _parent is the row parent container. * @param _parent is the row parent container.
*/ */
function et2_dataview_row(_parent) { constructor(_parent) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent) || this; super(_parent);
// Create the outer "tr" tag and append it to the container // Create the outer "tr" tag and append it to the container
_this.tr = jQuery(document.createElement("tr")); this.tr = jQuery(document.createElement("tr"));
_this.appendNode(_this.tr); this.appendNode(this.tr);
// Grid row which gets expanded when clicking on the corresponding // Grid row which gets expanded when clicking on the corresponding
// button // button
_this.expansionContainer = null; this.expansionContainer = null;
_this.expansionVisible = false; this.expansionVisible = false;
// Toggle button which is used to show and hide the expansionContainer // Toggle button which is used to show and hide the expansionContainer
_this.expansionButton = null; this.expansionButton = null;
return _this;
} }
et2_dataview_row.prototype.destroy = function () { destroy() {
if (this.expansionContainer != null) { if (this.expansionContainer != null) {
this.expansionContainer.destroy(); this.expansionContainer.destroy();
} }
_super.prototype.destroy.call(this); super.destroy();
}; }
et2_dataview_row.prototype.clear = function () { clear() {
this.tr.empty(); this.tr.empty();
}; }
et2_dataview_row.prototype.makeExpandable = function (_expandable, _callback, _context) { makeExpandable(_expandable, _callback, _context) {
if (_expandable) { if (_expandable) {
// Create the tr and the button if this has not been done yet // Create the tr and the button if this has not been done yet
if (!this.expansionButton) { if (!this.expansionButton) {
@ -89,29 +70,29 @@ var et2_dataview_row = /** @class */ (function (_super) {
this.expansionButton = null; this.expansionButton = null;
this.expansionContainer = null; this.expansionContainer = null;
} }
}; }
et2_dataview_row.prototype.removeFromTree = function () { removeFromTree() {
if (this.expansionContainer) { if (this.expansionContainer) {
this.expansionContainer.removeFromTree(); this.expansionContainer.removeFromTree();
} }
this.expansionContainer = null; this.expansionContainer = null;
this.expansionButton = null; this.expansionButton = null;
_super.prototype.removeFromTree.call(this); super.removeFromTree();
}; }
et2_dataview_row.prototype.getDOMNode = function () { getDOMNode() {
return this.tr[0]; return this.tr[0];
}; }
et2_dataview_row.prototype.getJNode = function () { getJNode() {
return this.tr; return this.tr;
}; }
et2_dataview_row.prototype.getHeight = function () { getHeight() {
var h = _super.prototype.getHeight.call(this); var h = super.getHeight();
if (this.expansionContainer && this.expansionVisible) { if (this.expansionContainer && this.expansionVisible) {
h += this.expansionContainer.getHeight(); h += this.expansionContainer.getHeight();
} }
return h; return h;
}; }
et2_dataview_row.prototype.getAvgHeightData = function () { getAvgHeightData() {
// Only take the height of the own tr into account // Only take the height of the own tr into account
//var oldVisible = this.expansionVisible; //var oldVisible = this.expansionVisible;
this.expansionVisible = false; this.expansionVisible = false;
@ -121,9 +102,9 @@ var et2_dataview_row = /** @class */ (function (_super) {
}; };
this.expansionVisible = true; this.expansionVisible = true;
return res; return res;
}; }
/** -- PRIVATE FUNCTIONS -- **/ /** -- PRIVATE FUNCTIONS -- **/
et2_dataview_row.prototype._handleExpansionButtonClick = function (_callback, _context) { _handleExpansionButtonClick(_callback, _context) {
// Create the "expansionContainer" if it does not exist yet // Create the "expansionContainer" if it does not exist yet
if (!this.expansionContainer) { if (!this.expansionContainer) {
this.expansionContainer = _callback.call(_context); this.expansionContainer = _callback.call(_context);
@ -143,19 +124,17 @@ var et2_dataview_row = /** @class */ (function (_super) {
this.expansionButton.removeClass("opened"); this.expansionButton.removeClass("opened");
} }
this.invalidate(); this.invalidate();
}; }
/** -- Implementation of et2_dataview_IViewRange -- **/ /** -- Implementation of et2_dataview_IViewRange -- **/
et2_dataview_row.prototype.setViewRange = function (_range) { setViewRange(_range) {
if (this.expansionContainer && this.expansionVisible if (this.expansionContainer && this.expansionVisible
&& implements_et2_dataview_IViewRange(this.expansionContainer)) { && this.expansionContainer.implements(et2_dataview_IViewRange)) {
// Substract the height of the own row from the container // Substract the height of the own row from the container
var oh = jQuery(this._nodes[0]).height(); var oh = jQuery(this._nodes[0]).height();
_range.top -= oh; _range.top -= oh;
// Proxy the setViewRange call to the expansion container // Proxy the setViewRange call to the expansion container
this.expansionContainer.setViewRange(_range); this.expansionContainer.setViewRange(_range);
} }
}; }
return et2_dataview_row; }
}(et2_dataview_container));
exports.et2_dataview_row = et2_dataview_row;
//# sourceMappingURL=et2_dataview_view_row.js.map //# sourceMappingURL=et2_dataview_view_row.js.map

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011-2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
egw_action.egw_action; egw_action.egw_action;
@ -17,6 +16,7 @@
*/ */
import {et2_dataview_IViewRange} from "./et2_dataview_interfaces"; import {et2_dataview_IViewRange} from "./et2_dataview_interfaces";
import {et2_dataview_container} from "./et2_dataview_view_container";
export class et2_dataview_row extends et2_dataview_container implements et2_dataview_IViewRange export class et2_dataview_row extends et2_dataview_container implements et2_dataview_IViewRange
{ {
@ -189,7 +189,7 @@ export class et2_dataview_row extends et2_dataview_container implements et2_data
setViewRange( _range) setViewRange( _range)
{ {
if (this.expansionContainer && this.expansionVisible if (this.expansionContainer && this.expansionVisible
&& implements_et2_dataview_IViewRange(this.expansionContainer)) && this.expansionContainer.implements(et2_dataview_IViewRange))
{ {
// Substract the height of the own row from the container // Substract the height of the own row from the container
var oh = jQuery(this._nodes[0]).height(); var oh = jQuery(this._nodes[0]).height();

View File

@ -1,17 +1,13 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Class which contains a factory method for rows * EGroupware eTemplate2 - Class which contains a factory method for rows
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_rowProvider = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_inheritance; et2_core_inheritance;
@ -23,13 +19,13 @@ exports.et2_dataview_rowProvider = void 0;
* The row provider contains prototypes (full clonable dom-trees) * The row provider contains prototypes (full clonable dom-trees)
* for all registered row types. * for all registered row types.
*/ */
var et2_dataview_rowProvider = /** @class */ (function () { export class et2_dataview_rowProvider {
/** /**
* *
* @param _outerId * @param _outerId
* @param _columnIds * @param _columnIds
*/ */
function et2_dataview_rowProvider(_outerId, _columnIds) { constructor(_outerId, _columnIds) {
// Copy the given parameters // Copy the given parameters
this._outerId = _outerId; this._outerId = _outerId;
this._columnIds = _columnIds; this._columnIds = _columnIds;
@ -43,16 +39,16 @@ var et2_dataview_rowProvider = /** @class */ (function () {
this._createEmptyPrototype(); this._createEmptyPrototype();
this._createLoadingPrototype(); this._createLoadingPrototype();
} }
et2_dataview_rowProvider.prototype.destroy = function () { destroy() {
this._template = null; this._template = null;
this._mgrs = null; this._mgrs = null;
this._rootWidget = null; this._rootWidget = null;
this._prototypes = {}; this._prototypes = {};
this._columnIds = []; this._columnIds = [];
}; }
et2_dataview_rowProvider.prototype.getColumnCount = function () { getColumnCount() {
return this._columnIds.length; return this._columnIds.length;
}; }
/** /**
* Returns a clone of the prototype with the given name. If the generator * Returns a clone of the prototype with the given name. If the generator
* callback function is given, this function is called if the prototype * callback function is given, this function is called if the prototype
@ -62,7 +58,7 @@ var et2_dataview_rowProvider = /** @class */ (function () {
* @param {function} _generator * @param {function} _generator
* @param {object} _context * @param {object} _context
*/ */
et2_dataview_rowProvider.prototype.getPrototype = function (_name, _generator, _context) { getPrototype(_name, _generator, _context) {
if (typeof this._prototypes[_name] == "undefined") { if (typeof this._prototypes[_name] == "undefined") {
if (typeof _generator != "undefined") { if (typeof _generator != "undefined") {
this._prototypes[_name] = _generator.call(_context, this._outerId, this._columnIds); this._prototypes[_name] = _generator.call(_context, this._outerId, this._columnIds);
@ -72,9 +68,9 @@ var et2_dataview_rowProvider = /** @class */ (function () {
} }
} }
return this._prototypes[_name].clone(); return this._prototypes[_name].clone();
}; }
/* ---- PRIVATE FUNCTIONS ---- */ /* ---- PRIVATE FUNCTIONS ---- */
et2_dataview_rowProvider.prototype._createFullRowPrototype = function () { _createFullRowPrototype() {
var tr = jQuery(document.createElement("tr")); var tr = jQuery(document.createElement("tr"));
var td = jQuery(document.createElement("td")) var td = jQuery(document.createElement("td"))
.addClass(this._outerId + "_td_fullRow") .addClass(this._outerId + "_td_fullRow")
@ -84,12 +80,11 @@ var et2_dataview_rowProvider = /** @class */ (function () {
.addClass(this._outerId + "_div_fullRow") .addClass(this._outerId + "_div_fullRow")
.appendTo(td); .appendTo(td);
this._prototypes["fullRow"] = tr; this._prototypes["fullRow"] = tr;
}; }
et2_dataview_rowProvider.prototype._createDefaultPrototype = function () { _createDefaultPrototype() {
var tr = jQuery(document.createElement("tr")); var tr = jQuery(document.createElement("tr"));
// Append a td for each column // Append a td for each column
for (var _i = 0, _a = this._columnIds; _i < _a.length; _i++) { for (var column of this._columnIds) {
var column = _a[_i];
if (!column) if (!column)
continue; continue;
var td = jQuery(document.createElement("td")) var td = jQuery(document.createElement("td"))
@ -101,16 +96,14 @@ var et2_dataview_rowProvider = /** @class */ (function () {
.appendTo(td); .appendTo(td);
} }
this._prototypes["default"] = tr; this._prototypes["default"] = tr;
}; }
et2_dataview_rowProvider.prototype._createEmptyPrototype = function () { _createEmptyPrototype() {
this._prototypes["empty"] = jQuery(document.createElement("tr")); this._prototypes["empty"] = jQuery(document.createElement("tr"));
}; }
et2_dataview_rowProvider.prototype._createLoadingPrototype = function () { _createLoadingPrototype() {
var fullRow = this.getPrototype("fullRow"); var fullRow = this.getPrototype("fullRow");
jQuery("div", fullRow).addClass("loading"); jQuery("div", fullRow).addClass("loading");
this._prototypes["loading"] = fullRow; this._prototypes["loading"] = fullRow;
}; }
return et2_dataview_rowProvider; }
}());
exports.et2_dataview_rowProvider = et2_dataview_rowProvider;
//# sourceMappingURL=et2_dataview_view_rowProvider.js.map //# sourceMappingURL=et2_dataview_view_rowProvider.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses

View File

@ -1,39 +1,22 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Class which contains the spacer container * EGroupware eTemplate2 - Class which contains the spacer container
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_spacer = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_dataview_view_container; et2_dataview_view_container;
*/ */
import { et2_dataview_container } from "./et2_dataview_view_container";
/** /**
* @augments et2_dataview_container * @augments et2_dataview_container
*/ */
var et2_dataview_spacer = /** @class */ (function (_super) { export class et2_dataview_spacer extends et2_dataview_container {
__extends(et2_dataview_spacer, _super);
/** /**
* Constructor * Constructor
* *
@ -41,22 +24,20 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
* @param _rowProvider * @param _rowProvider
* @memberOf et2_dataview_spacer * @memberOf et2_dataview_spacer
*/ */
function et2_dataview_spacer(_parent, _rowProvider) { constructor(_parent, _rowProvider) {
var _this =
// Call the inherited container constructor // Call the inherited container constructor
_super.call(this, _parent) || this; super(_parent);
// Initialize the row count and the row height // Initialize the row count and the row height
_this._count = 0; this._count = 0;
_this._rowHeight = 19; this._rowHeight = 19;
_this._avgSum = 0; this._avgSum = 0;
_this._avgCount = 0; this._avgCount = 0;
// Get the spacer row and append it to the container // Get the spacer row and append it to the container
_this.spacerNode = _rowProvider.getPrototype("spacer", _this._createSpacerPrototype, _this); this.spacerNode = _rowProvider.getPrototype("spacer", this._createSpacerPrototype, this);
_this._phDiv = jQuery("td", _this.spacerNode); this._phDiv = jQuery("td", this.spacerNode);
_this.appendNode(_this.spacerNode); this.appendNode(this.spacerNode);
return _this;
} }
et2_dataview_spacer.prototype.setCount = function (_count, _rowHeight) { setCount(_count, _rowHeight) {
// Set the new count and _rowHeight if given // Set the new count and _rowHeight if given
this._count = _count; this._count = _count;
if (typeof _rowHeight !== "undefined") { if (typeof _rowHeight !== "undefined") {
@ -66,16 +47,16 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
this._phDiv.height(this._count * this._rowHeight); this._phDiv.height(this._count * this._rowHeight);
// Call the invalidate function // Call the invalidate function
this.invalidate(); this.invalidate();
}; }
et2_dataview_spacer.prototype.getCount = function () { getCount() {
return this._count; return this._count;
}; }
et2_dataview_spacer.prototype.getHeight = function () { getHeight() {
// Set the calculated height, so that "invalidate" will work correctly // Set the calculated height, so that "invalidate" will work correctly
this._height = this._count * this._rowHeight; this._height = this._count * this._rowHeight;
return this._height; return this._height;
}; }
et2_dataview_spacer.prototype.getAvgHeightData = function () { getAvgHeightData() {
if (this._avgCount > 0) { if (this._avgCount > 0) {
return { return {
"avgHeight": this._avgSum / this._avgCount, "avgHeight": this._avgSum / this._avgCount,
@ -83,13 +64,13 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
}; };
} }
return null; return null;
}; }
et2_dataview_spacer.prototype.addAvgHeight = function (_height) { addAvgHeight(_height) {
this._avgSum += _height; this._avgSum += _height;
this._avgCount++; this._avgCount++;
}; }
/* ---- PRIVATE FUNCTIONS ---- */ /* ---- PRIVATE FUNCTIONS ---- */
et2_dataview_spacer.prototype._createSpacerPrototype = function (_outerId, _columnIds) { _createSpacerPrototype(_outerId, _columnIds) {
var tr = jQuery(document.createElement("tr")); var tr = jQuery(document.createElement("tr"));
var td = jQuery(document.createElement("td")) var td = jQuery(document.createElement("td"))
.addClass("egwGridView_spacer") .addClass("egwGridView_spacer")
@ -97,8 +78,6 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
.attr("colspan", _columnIds.length) .attr("colspan", _columnIds.length)
.appendTo(tr); .appendTo(tr);
return tr; return tr;
}; }
return et2_dataview_spacer; }
}(et2_dataview_container));
exports.et2_dataview_spacer = et2_dataview_spacer;
//# sourceMappingURL=et2_dataview_view_spacer.js.map //# sourceMappingURL=et2_dataview_view_spacer.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -15,6 +14,8 @@
et2_dataview_view_container; et2_dataview_view_container;
*/ */
import {et2_dataview_container} from "./et2_dataview_view_container";
/** /**
* @augments et2_dataview_container * @augments et2_dataview_container
*/ */

View File

@ -1,34 +1,19 @@
"use strict";
/** /**
* EGroupware eTemplate2 - dataview code * EGroupware eTemplate2 - dataview code
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2014 * @copyright Nathan Gray 2014
* @version $Id: et2_dataview_view_container_1.js 46338 2014-03-20 09:40:37Z ralfbecker $ * @version $Id: et2_dataview_view_container_1.js 46338 2014-03-20 09:40:37Z ralfbecker $
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dataview_tile = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_dataview_interfaces; et2_dataview_interfaces;
*/ */
import { et2_dataview_row } from "./et2_dataview_view_row";
/** /**
* Displays tiles or thumbnails (squares) instead of full rows. * Displays tiles or thumbnails (squares) instead of full rows.
* *
@ -36,8 +21,7 @@ exports.et2_dataview_tile = void 0;
* so that the rows and columns work out properly. * so that the rows and columns work out properly.
* *
*/ */
var et2_dataview_tile = /** @class */ (function (_super) { export class et2_dataview_tile extends et2_dataview_row {
__extends(et2_dataview_tile, _super);
/** /**
* Creates the row container. Use the "setRow" function to load the actual * Creates the row container. Use the "setRow" function to load the actual
* row content. * row content.
@ -45,25 +29,23 @@ var et2_dataview_tile = /** @class */ (function (_super) {
* @param _parent is the row parent container. * @param _parent is the row parent container.
* @memberOf et2_dataview_row * @memberOf et2_dataview_row
*/ */
function et2_dataview_tile(_parent) { constructor(_parent) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent) || this; super(_parent);
_this.columns = 4; this.columns = 4;
// Make sure the needed class is there to get the CSS // Make sure the needed class is there to get the CSS
_this.tr.addClass('tile'); this.tr.addClass('tile');
return _this;
} }
et2_dataview_tile.prototype.makeExpandable = function (_expandable, _callback, _context) { makeExpandable(_expandable, _callback, _context) {
// Nope. It mostly works, it's just weird. // Nope. It mostly works, it's just weird.
}; }
et2_dataview_tile.prototype.getAvgHeightData = function () { getAvgHeightData() {
var res = { var res = {
"avgHeight": this.getHeight() / this.columns, "avgHeight": this.getHeight() / this.columns,
"avgCount": this.columns "avgCount": this.columns
}; };
return res; return res;
}; }
/** /**
* Returns the height for the tile. * Returns the height for the tile.
* *
@ -71,19 +53,19 @@ var et2_dataview_tile = /** @class */ (function (_super) {
* height. If this should be another tile in the same row, we say it has 0 height. * height. If this should be another tile in the same row, we say it has 0 height.
* @returns {Number} * @returns {Number}
*/ */
et2_dataview_tile.prototype.getHeight = function () { getHeight() {
if (this._index % this.columns == 0) { if (this._index % this.columns == 0) {
return _super.prototype.getHeight.call(this); return super.getHeight();
} }
else { else {
return 0; return 0;
} }
}; }
/** /**
* Broadcasts an invalidation through the container tree. Marks the own * Broadcasts an invalidation through the container tree. Marks the own
* height as invalid. * height as invalid.
*/ */
et2_dataview_tile.prototype.invalidate = function () { invalidate() {
if (this._inTree && this.tr) { if (this._inTree && this.tr) {
var template_width = jQuery('.innerContainer', this.tr).children().outerWidth(true); var template_width = jQuery('.innerContainer', this.tr).children().outerWidth(true);
if (template_width) { if (template_width) {
@ -91,19 +73,17 @@ var et2_dataview_tile = /** @class */ (function (_super) {
} }
} }
this._recalculate_columns(); this._recalculate_columns();
_super.prototype.invalidate.call(this); super.invalidate();
}; }
/** /**
* Recalculate how many columns we can fit in a row. * Recalculate how many columns we can fit in a row.
* While browser takes care of the actual layout, we need this for proper * While browser takes care of the actual layout, we need this for proper
* pagination. * pagination.
*/ */
et2_dataview_tile.prototype._recalculate_columns = function () { _recalculate_columns() {
if (this._inTree && this.tr && this.tr.parent()) { if (this._inTree && this.tr && this.tr.parent()) {
this.columns = Math.max(1, parseInt(this.tr.parent().innerWidth() / this.tr.outerWidth(true))); this.columns = Math.max(1, parseInt(this.tr.parent().innerWidth() / this.tr.outerWidth(true)));
} }
}; }
return et2_dataview_tile; }
}(et2_dataview_row));
exports.et2_dataview_tile = et2_dataview_tile;
//# sourceMappingURL=et2_dataview_view_tile.js.map //# sourceMappingURL=et2_dataview_view_tile.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage dataview * @subpackage dataview
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2014 * @copyright Nathan Gray 2014
* @version $Id: et2_dataview_view_container_1.js 46338 2014-03-20 09:40:37Z ralfbecker $ * @version $Id: et2_dataview_view_container_1.js 46338 2014-03-20 09:40:37Z ralfbecker $
@ -15,6 +15,8 @@
et2_dataview_interfaces; et2_dataview_interfaces;
*/ */
import {et2_dataview_row} from "./et2_dataview_view_row";
/** /**
* Displays tiles or thumbnails (squares) instead of full rows. * Displays tiles or thumbnails (squares) instead of full rows.
* *
@ -22,7 +24,8 @@
* so that the rows and columns work out properly. * so that the rows and columns work out properly.
* *
*/ */
export class et2_dataview_tile extends et2_dataview_row { export class et2_dataview_tile extends et2_dataview_row
{
columns: number = 4; columns: number = 4;
/** /**

View File

@ -1,30 +1,13 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Custom fields object * EGroupware eTemplate2 - JS Custom fields object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_customfields_list = void 0;
/*egw:uses /*egw:uses
lib/tooltip; lib/tooltip;
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
@ -32,81 +15,81 @@ exports.et2_customfields_list = void 0;
et2_core_DOMWidget; et2_core_DOMWidget;
et2_core_inputWidget; et2_core_inputWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_createWidget, et2_register_widget, et2_registry } from "./et2_core_widget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
var et2_customfields_list = /** @class */ (function (_super) { import { et2_cloneObject, et2_no_init } from "./et2_core_common";
__extends(et2_customfields_list, _super); import { egw } from "../jsapi/egw_global";
function et2_customfields_list(_parent, _attrs, _child) { export class et2_customfields_list extends et2_valueWidget {
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_customfields_list._attributes, _child || {})) || this; constructor(_parent, _attrs, _child) {
_this.rows = {}; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_customfields_list._attributes, _child || {}));
_this.widgets = {}; this.rows = {};
_this.detachedNodes = []; this.widgets = {};
this.detachedNodes = [];
// Some apps (infolog edit) don't give ID, so assign one to get settings // Some apps (infolog edit) don't give ID, so assign one to get settings
if (!_this.id) { if (!this.id) {
_this.id = _attrs.id = et2_customfields_list.DEFAULT_ID; this.id = _attrs.id = et2_customfields_list.DEFAULT_ID;
// Add all attributes hidden in the content arrays to the attributes // Add all attributes hidden in the content arrays to the attributes
// parameter // parameter
_this.transformAttributes(_attrs); this.transformAttributes(_attrs);
// Create a local copy of the options object // Create a local copy of the options object
_this.options = et2_cloneObject(_attrs); this.options = et2_cloneObject(_attrs);
} }
// Create the table body and the table // Create the table body and the table
_this.tbody = jQuery(document.createElement("tbody")); this.tbody = jQuery(document.createElement("tbody"));
_this.table = jQuery(document.createElement("table")) this.table = jQuery(document.createElement("table"))
.addClass("et2_grid et2_customfield_list"); .addClass("et2_grid et2_customfield_list");
_this.table.append(_this.tbody); this.table.append(this.tbody);
if (!_this.options.fields) if (!this.options.fields)
_this.options.fields = {}; this.options.fields = {};
if (typeof _this.options.fields === 'string') { if (typeof this.options.fields === 'string') {
var fields = _this.options.fields.split(','); const fields = this.options.fields.split(',');
_this.options.fields = {}; this.options.fields = {};
for (var i = 0; i < fields.length; i++) { for (var i = 0; i < fields.length; i++) {
_this.options.fields[fields[i]] = true; this.options.fields[fields[i]] = true;
} }
} }
if (_this.options.type_filter && typeof _this.options.type_filter == "string") { if (this.options.type_filter && typeof this.options.type_filter == "string") {
_this.options.type_filter = _this.options.type_filter.split(","); this.options.type_filter = this.options.type_filter.split(",");
} }
if (_this.options.type_filter) { if (this.options.type_filter) {
var already_filtered = !jQuery.isEmptyObject(_this.options.fields); const already_filtered = !jQuery.isEmptyObject(this.options.fields);
for (var field_name in _this.options.customfields) { for (let field_name in this.options.customfields) {
// Already excluded? // Already excluded?
if (already_filtered && !_this.options.fields[field_name]) if (already_filtered && !this.options.fields[field_name])
continue; continue;
if (!_this.options.customfields[field_name].type2 || _this.options.customfields[field_name].type2.length == 0 || if (!this.options.customfields[field_name].type2 || this.options.customfields[field_name].type2.length == 0 ||
_this.options.customfields[field_name].type2 == '0') { this.options.customfields[field_name].type2 == '0') {
// No restrictions // No restrictions
_this.options.fields[field_name] = true; this.options.fields[field_name] = true;
continue; continue;
} }
var types = typeof _this.options.customfields[field_name].type2 == 'string' ? _this.options.customfields[field_name].type2.split(",") : _this.options.customfields[field_name].type2; const types = typeof this.options.customfields[field_name].type2 == 'string' ? this.options.customfields[field_name].type2.split(",") : this.options.customfields[field_name].type2;
_this.options.fields[field_name] = false; this.options.fields[field_name] = false;
for (var i = 0; i < types.length; i++) { for (var i = 0; i < types.length; i++) {
if (jQuery.inArray(types[i], _this.options.type_filter) > -1) { if (jQuery.inArray(types[i], this.options.type_filter) > -1) {
_this.options.fields[field_name] = true; this.options.fields[field_name] = true;
} }
} }
} }
} }
_this.setDOMNode(_this.table[0]); this.setDOMNode(this.table[0]);
return _this;
} }
et2_customfields_list.prototype.destroy = function () { destroy() {
_super.prototype.destroy.call(this); super.destroy();
this.rows = {}; this.rows = {};
this.widgets = {}; this.widgets = {};
this.detachedNodes = []; this.detachedNodes = [];
this.tbody = null; this.tbody = null;
}; }
/** /**
* What does this do? I don't know, but when everything is done the second * What does this do? I don't know, but when everything is done the second
* time, this makes it work. Otherwise, all custom fields are lost. * time, this makes it work. Otherwise, all custom fields are lost.
*/ */
et2_customfields_list.prototype.assign = function (_obj) { assign(_obj) {
this.loadFields(); this.loadFields();
}; }
et2_customfields_list.prototype.getDOMNode = function (_sender) { getDOMNode(_sender) {
// Check whether the _sender object exists inside the management array // Check whether the _sender object exists inside the management array
if (this.rows && _sender.id && this.rows[_sender.id]) { if (this.rows && _sender.id && this.rows[_sender.id]) {
return this.rows[_sender.id]; return this.rows[_sender.id];
@ -114,12 +97,12 @@ var et2_customfields_list = /** @class */ (function (_super) {
if (this.rows && _sender.id && _sender.id.indexOf("_label") && this.rows[_sender.id.replace("_label", "")]) { if (this.rows && _sender.id && _sender.id.indexOf("_label") && this.rows[_sender.id.replace("_label", "")]) {
return jQuery(this.rows[_sender.id.replace("_label", "")]).prev("td")[0] || null; return jQuery(this.rows[_sender.id.replace("_label", "")]).prev("td")[0] || null;
} }
return _super.prototype.getDOMNode.call(this, _sender); return super.getDOMNode(_sender);
}; }
/** /**
* Initialize widgets for custom fields * Initialize widgets for custom fields
*/ */
et2_customfields_list.prototype.loadFields = function () { loadFields() {
if (!this.options || !this.options.customfields) if (!this.options || !this.options.customfields)
return; return;
// Already set up - avoid duplicates in nextmatch // Already set up - avoid duplicates in nextmatch
@ -128,18 +111,18 @@ var et2_customfields_list = /** @class */ (function (_super) {
if (!jQuery.isEmptyObject(this.widgets)) if (!jQuery.isEmptyObject(this.widgets))
return; return;
// Check for global setting changes (visibility) // Check for global setting changes (visibility)
var global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~'); const global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~');
if (global_data && global_data.fields && !this.options.fields) if (global_data && global_data.fields && !this.options.fields)
this.options.fields = global_data.fields; this.options.fields = global_data.fields;
// For checking app entries // For checking app entries
var apps = this.egw().link_app_list(); const apps = this.egw().link_app_list();
// Create the table rows // Create the table rows
for (var field_name in this.options.customfields) { for (let field_name in this.options.customfields) {
// Skip fields if we're filtering // Skip fields if we're filtering
if (this.getType() != 'customfields-list' && !jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name]) if (this.getType() != 'customfields-list' && !jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name])
continue; continue;
var field = this.options.customfields[field_name]; const field = this.options.customfields[field_name];
var id = this.options.prefix + field_name; let id = this.options.prefix + field_name;
// Need curlies around ID for nm row expansion // Need curlies around ID for nm row expansion
if (this.id == '$row') { if (this.id == '$row') {
id = "{" + this.id + "}" + "[" + this.options.prefix + field_name + "]"; id = "{" + this.id + "}" + "[" + this.options.prefix + field_name + "]";
@ -150,15 +133,15 @@ var et2_customfields_list = /** @class */ (function (_super) {
} }
// Avoid creating field twice // Avoid creating field twice
if (!this.rows[id]) { if (!this.rows[id]) {
var row = jQuery(document.createElement("tr")) const row = jQuery(document.createElement("tr"))
.appendTo(this.tbody) .appendTo(this.tbody)
.addClass(this.id + '_' + id); .addClass(this.id + '_' + id);
var cf = jQuery(document.createElement("td")) let cf = jQuery(document.createElement("td"))
.appendTo(row); .appendTo(row);
if (!field.type) if (!field.type)
field.type = 'text";'; field.type = 'text";';
var setup_function = '_setup_' + (apps[field.type] ? 'link_entry' : field.type.replace("-", "_")); const setup_function = '_setup_' + (apps[field.type] ? 'link_entry' : field.type.replace("-", "_"));
var attrs = jQuery.extend({}, this.options[field_name] ? this.options[field_name] : {}, { const attrs = jQuery.extend({}, this.options[field_name] ? this.options[field_name] : {}, {
'id': id, 'id': id,
'statustext': field.help, 'statustext': field.help,
'needed': field.needed, 'needed': field.needed,
@ -172,7 +155,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.onchange = this.options.onchange; attrs.onchange = this.options.onchange;
} }
if (this[setup_function]) { if (this[setup_function]) {
var no_skip = this[setup_function].call(this, field_name, field, attrs); const no_skip = this[setup_function].call(this, field_name, field, attrs);
if (!no_skip) if (!no_skip)
continue; continue;
} }
@ -193,19 +176,19 @@ var et2_customfields_list = /** @class */ (function (_super) {
// Label in first column, widget in 2nd // Label in first column, widget in 2nd
jQuery(document.createElement("td")) jQuery(document.createElement("td"))
.prependTo(row); .prependTo(row);
et2_core_widget_1.et2_createWidget("label", { id: id + "_label", value: field.label, for: id }, this); et2_createWidget("label", { id: id + "_label", value: field.label, for: id }, this);
} }
// Set any additional attributes set in options, but not for widgets that pass actual options // Set any additional attributes set in options, but not for widgets that pass actual options
if (['select', 'radio', 'radiogroup', 'checkbox', 'button'].indexOf(field.type) == -1 && !jQuery.isEmptyObject(field.values)) { if (['select', 'radio', 'radiogroup', 'checkbox', 'button'].indexOf(field.type) == -1 && !jQuery.isEmptyObject(field.values)) {
var w = et2_registry[attrs.type ? attrs.type : field.type]; const w = et2_registry[attrs.type ? attrs.type : field.type];
for (var attr_name in field.values) { for (let attr_name in field.values) {
if (typeof w._attributes[attr_name] != "undefined") { if (typeof w._attributes[attr_name] != "undefined") {
attrs[attr_name] = field.values[attr_name]; attrs[attr_name] = field.values[attr_name];
} }
} }
} }
// Create widget // Create widget
var widget = this.widgets[field_name] = et2_core_widget_1.et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this); const widget = this.widgets[field_name] = et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this);
} }
// Field is not to be shown // Field is not to be shown
if (!this.options.fields || jQuery.isEmptyObject(this.options.fields) || this.options.fields[field_name] == true) { if (!this.options.fields || jQuery.isEmptyObject(this.options.fields) || this.options.fields[field_name] == true) {
@ -215,48 +198,48 @@ var et2_customfields_list = /** @class */ (function (_super) {
jQuery(this.rows[field_name]).hide(); jQuery(this.rows[field_name]).hide();
} }
} }
}; }
/** /**
* Read needed info on available custom fields from various places it's stored. * Read needed info on available custom fields from various places it's stored.
*/ */
et2_customfields_list.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
// Add in settings that are objects // Add in settings that are objects
// Customized settings for this widget (unlikely) // Customized settings for this widget (unlikely)
var data = this.getArrayMgr("modifications").getEntry(this.id); const data = this.getArrayMgr("modifications").getEntry(this.id);
// Check for global settings // Check for global settings
var global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~', true); const global_data = this.getArrayMgr("modifications").getRoot().getEntry('~custom_fields~', true);
if (global_data) { if (global_data) {
for (var key_1 in data) { for (let key in data) {
// Don't overwrite fields with global values // Don't overwrite fields with global values
if (global_data[key_1] && key_1 !== 'fields') { if (global_data[key] && key !== 'fields') {
data[key_1] = jQuery.extend(true, {}, data[key_1], global_data[key_1]); data[key] = jQuery.extend(true, {}, data[key], global_data[key]);
} }
} }
} }
for (var key in data) { for (var key in data) {
_attrs[key] = data[key]; _attrs[key] = data[key];
} }
for (var key_2 in global_data) { for (let key in global_data) {
if (typeof global_data[key_2] != 'undefined' && !_attrs[key_2]) if (typeof global_data[key] != 'undefined' && !_attrs[key])
_attrs[key_2] = global_data[key_2]; _attrs[key] = global_data[key];
} }
if (this.id) { if (this.id) {
// Set the value for this element // Set the value for this element
var contentMgr = this.getArrayMgr("content"); const contentMgr = this.getArrayMgr("content");
if (contentMgr != null) { if (contentMgr != null) {
var val = contentMgr.getEntry(this.id); const val = contentMgr.getEntry(this.id);
_attrs["value"] = {}; _attrs["value"] = {};
var prefix = _attrs["prefix"] || et2_customfields_list.PREFIX; let prefix = _attrs["prefix"] || et2_customfields_list.PREFIX;
if (val !== null) { if (val !== null) {
if (this.id.indexOf(prefix) === 0 && typeof data.fields != 'undefined' && data.fields[this.id.replace(prefix, '')] === true) { if (this.id.indexOf(prefix) === 0 && typeof data.fields != 'undefined' && data.fields[this.id.replace(prefix, '')] === true) {
_attrs['value'][this.id] = val; _attrs['value'][this.id] = val;
} }
else { else {
// Only set the values that match desired custom fields // Only set the values that match desired custom fields
for (var key_3 in val) { for (let key in val) {
if (key_3.indexOf(prefix) === 0) { if (key.indexOf(prefix) === 0) {
_attrs["value"][key_3] = val[key_3]; _attrs["value"][key] = val[key];
} }
} }
} }
@ -270,23 +253,23 @@ var et2_customfields_list = /** @class */ (function (_super) {
} }
} }
} }
}; }
et2_customfields_list.prototype.loadFromXML = function (_node) { loadFromXML(_node) {
this.loadFields(); this.loadFields();
// Load the nodes as usual // Load the nodes as usual
_super.prototype.loadFromXML.call(this, _node); super.loadFromXML(_node);
}; }
et2_customfields_list.prototype.set_value = function (_value) { set_value(_value) {
if (!this.options.customfields) if (!this.options.customfields)
return; return;
for (var field_name in this.options.customfields) { for (let field_name in this.options.customfields) {
// Skip fields if we're filtering // Skip fields if we're filtering
if (!jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name]) if (!jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name])
continue; continue;
// Make sure widget is created, and has the needed function // Make sure widget is created, and has the needed function
if (!this.widgets[field_name] || !this.widgets[field_name].set_value) if (!this.widgets[field_name] || !this.widgets[field_name].set_value)
continue; continue;
var value = _value[this.options.prefix + field_name] ? _value[this.options.prefix + field_name] : null; let value = _value[this.options.prefix + field_name] ? _value[this.options.prefix + field_name] : null;
// Check if ID was missing // Check if ID was missing
if (value == null && this.id == et2_customfields_list.DEFAULT_ID && this.getArrayMgr("content").getEntry(this.options.prefix + field_name)) { if (value == null && this.id == et2_customfields_list.DEFAULT_ID && this.getArrayMgr("content").getEntry(this.options.prefix + field_name)) {
value = this.getArrayMgr("content").getEntry(this.options.prefix + field_name); value = this.getArrayMgr("content").getEntry(this.options.prefix + field_name);
@ -303,43 +286,43 @@ var et2_customfields_list = /** @class */ (function (_super) {
} }
this.widgets[field_name].set_value(value); this.widgets[field_name].set_value(value);
} }
}; }
/** /**
* et2_IInput so the custom field can be it's own widget. * et2_IInput so the custom field can be it's own widget.
*/ */
et2_customfields_list.prototype.getValue = function () { getValue() {
// Not using an ID means we have to grab all the widget values, and put them where server knows to look // Not using an ID means we have to grab all the widget values, and put them where server knows to look
if (this.id != et2_customfields_list.DEFAULT_ID) { if (this.id != et2_customfields_list.DEFAULT_ID) {
return null; return null;
} }
var value = {}; const value = {};
for (var field_name in this.widgets) { for (let field_name in this.widgets) {
if (this.widgets[field_name].getValue && !this.widgets[field_name].options.readonly) { if (this.widgets[field_name].getValue && !this.widgets[field_name].options.readonly) {
value[this.options.prefix + field_name] = this.widgets[field_name].getValue(); value[this.options.prefix + field_name] = this.widgets[field_name].getValue();
} }
} }
return value; return value;
}; }
et2_customfields_list.prototype.isDirty = function () { isDirty() {
var dirty = false; let dirty = false;
for (var field_name in this.widgets) { for (let field_name in this.widgets) {
if (this.widgets[field_name].isDirty) { if (this.widgets[field_name].isDirty) {
dirty = dirty || this.widgets[field_name].isDirty(); dirty = dirty || this.widgets[field_name].isDirty();
} }
} }
return dirty; return dirty;
}; }
et2_customfields_list.prototype.resetDirty = function () { resetDirty() {
for (var field_name in this.widgets) { for (let field_name in this.widgets) {
if (this.widgets[field_name].resetDirty) { if (this.widgets[field_name].resetDirty) {
this.widgets[field_name].resetDirty(); this.widgets[field_name].resetDirty();
} }
} }
}; }
et2_customfields_list.prototype.isValid = function () { isValid() {
// Individual customfields will handle themselves // Individual customfields will handle themselves
return true; return true;
}; }
/** /**
* Adapt provided attributes to match options for widget * Adapt provided attributes to match options for widget
* *
@ -347,7 +330,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
* !rows --> input, with size=len * !rows --> input, with size=len
* rows = 1 --> input, with size=len, maxlength=len * rows = 1 --> input, with size=len, maxlength=len
*/ */
et2_customfields_list.prototype._setup_text = function (field_name, field, attrs) { _setup_text(field_name, field, attrs) {
// No label on the widget itself // No label on the widget itself
delete (attrs.label); delete (attrs.label);
field.type = 'textbox'; field.type = 'textbox';
@ -358,33 +341,32 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.maxlength = field.len; attrs.maxlength = field.len;
} }
return true; return true;
}; }
et2_customfields_list.prototype._setup_passwd = function (field_name, field, attrs) { _setup_passwd(field_name, field, attrs) {
// No label on the widget itself // No label on the widget itself
delete (attrs.label); delete (attrs.label);
var defaults = { let defaults = {
viewable: true, viewable: true,
plaintext: false, plaintext: false,
suggest: 16 suggest: 16
}; };
for (var _i = 0, _a = Object.keys(defaults); _i < _a.length; _i++) { for (let key of Object.keys(defaults)) {
var key = _a[_i];
attrs[key] = (field.values && typeof field.values[key] !== "undefined") ? field.values[key] : defaults[key]; attrs[key] = (field.values && typeof field.values[key] !== "undefined") ? field.values[key] : defaults[key];
} }
return true; return true;
}; }
et2_customfields_list.prototype._setup_ajax_select = function (field_name, field, attrs) { _setup_ajax_select(field_name, field, attrs) {
var attributes = ['get_rows', 'get_title', 'id_field', 'template']; const attributes = ['get_rows', 'get_title', 'id_field', 'template'];
if (field.values) { if (field.values) {
for (var i = 0; i < attributes.length; i++) { for (let i = 0; i < attributes.length; i++) {
if (typeof field.values[attributes[i]] !== 'undefined') { if (typeof field.values[attributes[i]] !== 'undefined') {
attrs[attributes[i]] = field.values[attributes[i]]; attrs[attributes[i]] = field.values[attributes[i]];
} }
} }
} }
return true; return true;
}; }
et2_customfields_list.prototype._setup_float = function (field_name, field, attrs) { _setup_float(field_name, field, attrs) {
// No label on the widget itself // No label on the widget itself
delete (attrs.label); delete (attrs.label);
field.type = 'float'; field.type = 'float';
@ -392,31 +374,31 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.size = field.len; attrs.size = field.len;
} }
return true; return true;
}; }
et2_customfields_list.prototype._setup_select = function (field_name, field, attrs) { _setup_select(field_name, field, attrs) {
// No label on the widget itself // No label on the widget itself
delete (attrs.label); delete (attrs.label);
attrs.rows = field.rows; attrs.rows = field.rows;
// select_options are now send from server-side incl. ones defined via a file in EGroupware root // select_options are now send from server-side incl. ones defined via a file in EGroupware root
attrs.tags = field.tags; attrs.tags = field.tags;
return true; return true;
}; }
et2_customfields_list.prototype._setup_select_account = function (field_name, field, attrs) { _setup_select_account(field_name, field, attrs) {
attrs.empty_label = egw.lang('Select'); attrs.empty_label = egw.lang('Select');
if (field.account_type) { if (field.account_type) {
attrs.account_type = field.account_type; attrs.account_type = field.account_type;
} }
return this._setup_select(field_name, field, attrs); return this._setup_select(field_name, field, attrs);
}; }
et2_customfields_list.prototype._setup_date = function (field_name, field, attrs) { _setup_date(field_name, field, attrs) {
attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d'; attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d';
return true; return true;
}; }
et2_customfields_list.prototype._setup_date_time = function (field_name, field, attrs) { _setup_date_time(field_name, field, attrs) {
attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d H:i:s'; attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d H:i:s';
return true; return true;
}; }
et2_customfields_list.prototype._setup_htmlarea = function (field_name, field, attrs) { _setup_htmlarea(field_name, field, attrs) {
attrs.config = field.config ? field.config : {}; attrs.config = field.config ? field.config : {};
attrs.config.toolbarStartupExpanded = false; attrs.config.toolbarStartupExpanded = false;
if (field.len) { if (field.len) {
@ -425,12 +407,12 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.config.height = (((field.rows > 0 && field.rows != 'undefined') ? field.rows : 5) * 16) + 'px'; attrs.config.height = (((field.rows > 0 && field.rows != 'undefined') ? field.rows : 5) * 16) + 'px';
// We have to push the config modifications into the modifications array, or they'll // We have to push the config modifications into the modifications array, or they'll
// be overwritten by the site config from the server // be overwritten by the site config from the server
var data = this.getArrayMgr("modifications").getEntry(this.options.prefix + field_name); const data = this.getArrayMgr("modifications").getEntry(this.options.prefix + field_name);
if (data) if (data)
jQuery.extend(data.config, attrs.config); jQuery.extend(data.config, attrs.config);
return true; return true;
}; }
et2_customfields_list.prototype._setup_radio = function (field_name, field, attrs) { _setup_radio(field_name, field, attrs) {
// 'Empty' label will be first // 'Empty' label will be first
delete (attrs.label); delete (attrs.label);
if (field.values && field.values['']) { if (field.values && field.values['']) {
@ -440,8 +422,8 @@ var et2_customfields_list = /** @class */ (function (_super) {
field.type = 'radiogroup'; field.type = 'radiogroup';
attrs.options = field.values; attrs.options = field.values;
return true; return true;
}; }
et2_customfields_list.prototype._setup_checkbox = function (field_name, field, attrs) { _setup_checkbox(field_name, field, attrs) {
// Read-only checkbox is just text // Read-only checkbox is just text
if (attrs.readonly && this.getType() !== "customfields") { if (attrs.readonly && this.getType() !== "customfields") {
attrs.ro_true = field.label; attrs.ro_true = field.label;
@ -453,12 +435,12 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.ro_false = field.ro_false; attrs.ro_false = field.ro_false;
} }
return true; return true;
}; }
/** /**
* People set button attributes as * People set button attributes as
* label: javascript * label: javascript
*/ */
et2_customfields_list.prototype._setup_button = function (field_name, field, attrs) { _setup_button(field_name, field, attrs) {
// No label on the widget itself // No label on the widget itself
delete (attrs.label); delete (attrs.label);
attrs.label = field.label; attrs.label = field.label;
@ -468,9 +450,9 @@ var et2_customfields_list = /** @class */ (function (_super) {
} }
// Simple case, one widget for a custom field // Simple case, one widget for a custom field
if (!field.values || typeof field.values != 'object' || Object.keys(field.values).length == 1) { if (!field.values || typeof field.values != 'object' || Object.keys(field.values).length == 1) {
for (var key_4 in field.values) { for (let key in field.values) {
attrs.label = key_4; attrs.label = key;
attrs.onclick = field.values[key_4]; attrs.onclick = field.values[key];
} }
if (!attrs.label) { if (!attrs.label) {
attrs.label = 'No "label=onclick" in values!'; attrs.label = 'No "label=onclick" in values!';
@ -481,26 +463,26 @@ var et2_customfields_list = /** @class */ (function (_super) {
else { else {
// Complicated case, a single custom field you get multiple widgets // Complicated case, a single custom field you get multiple widgets
// Handle it all here, since this is the exception // Handle it all here, since this is the exception
var row = jQuery('tr', this.tbody).last(); const row = jQuery('tr', this.tbody).last();
var cf = jQuery('td', row); let cf = jQuery('td', row);
// Label in first column, widget in 2nd // Label in first column, widget in 2nd
cf.text(field.label + ""); cf.text(field.label + "");
cf = jQuery(document.createElement("td")) cf = jQuery(document.createElement("td"))
.appendTo(row); .appendTo(row);
for (var key in field.values) { for (var key in field.values) {
var button_attrs = jQuery.extend({}, attrs); const button_attrs = jQuery.extend({}, attrs);
button_attrs.label = key; button_attrs.label = key;
button_attrs.onclick = field.values[key]; button_attrs.onclick = field.values[key];
button_attrs.id = attrs.id + '_' + key; button_attrs.id = attrs.id + '_' + key;
// This controls where the button is placed in the DOM // This controls where the button is placed in the DOM
this.rows[button_attrs.id] = cf[0]; this.rows[button_attrs.id] = cf[0];
// Do not store in the widgets list, one name for multiple widgets would cause problems // Do not store in the widgets list, one name for multiple widgets would cause problems
/*this.widgets[field_name] = */ et2_core_widget_1.et2_createWidget(attrs.type ? attrs.type : field.type, button_attrs, this); /*this.widgets[field_name] = */ et2_createWidget(attrs.type ? attrs.type : field.type, button_attrs, this);
} }
return false; return false;
} }
}; }
et2_customfields_list.prototype._setup_link_entry = function (field_name, field, attrs) { _setup_link_entry(field_name, field, attrs) {
if (field.type === 'filemanager') { if (field.type === 'filemanager') {
return this._setup_filemanager(field_name, field, attrs); return this._setup_filemanager(field_name, field, attrs);
} }
@ -509,8 +491,8 @@ var et2_customfields_list = /** @class */ (function (_super) {
attrs.type = "link-entry"; attrs.type = "link-entry";
attrs.only_app = typeof field.only_app == "undefined" ? field.type : field.only_app; attrs.only_app = typeof field.only_app == "undefined" ? field.type : field.only_app;
return true; return true;
}; }
et2_customfields_list.prototype._setup_filemanager = function (field_name, field, attrs) { _setup_filemanager(field_name, field, attrs) {
attrs.type = 'vfs-upload'; attrs.type = 'vfs-upload';
delete (attrs.label); delete (attrs.label);
if (this.getType() == 'customfields-list') { if (this.getType() == 'customfields-list') {
@ -520,19 +502,19 @@ var et2_customfields_list = /** @class */ (function (_super) {
else { else {
// Complicated case, a single custom field you get multiple widgets // Complicated case, a single custom field you get multiple widgets
// Handle it all here, since this is the exception // Handle it all here, since this is the exception
var row = jQuery('tr', this.tbody).last(); const row = jQuery('tr', this.tbody).last();
var cf = jQuery('td', row); let cf = jQuery('td', row);
// Label in first column, widget in 2nd // Label in first column, widget in 2nd
cf.text(field.label + ""); cf.text(field.label + "");
cf = jQuery(document.createElement("td")) cf = jQuery(document.createElement("td"))
.appendTo(row); .appendTo(row);
// Create upload widget // Create upload widget
var widget = this.widgets[field_name] = et2_core_widget_1.et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this); let widget = this.widgets[field_name] = et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this);
// This controls where the widget is placed in the DOM // This controls where the widget is placed in the DOM
this.rows[attrs.id] = cf[0]; this.rows[attrs.id] = cf[0];
jQuery(widget.getDOMNode(widget)).css('vertical-align', 'top'); jQuery(widget.getDOMNode(widget)).css('vertical-align', 'top');
// Add a link to existing VFS file // Add a link to existing VFS file
var select_attrs = jQuery.extend({}, attrs, const select_attrs = jQuery.extend({}, attrs,
// Filemanager select // Filemanager select
{ {
label: '', label: '',
@ -545,61 +527,62 @@ var et2_customfields_list = /** @class */ (function (_super) {
// This controls where the button is placed in the DOM // This controls where the button is placed in the DOM
this.rows[select_attrs.id] = cf[0]; this.rows[select_attrs.id] = cf[0];
// Do not store in the widgets list, one name for multiple widgets would cause problems // Do not store in the widgets list, one name for multiple widgets would cause problems
widget = et2_core_widget_1.et2_createWidget(select_attrs.type, select_attrs, this); widget = et2_createWidget(select_attrs.type, select_attrs, this);
jQuery(widget.getDOMNode(widget)).css('vertical-align', 'top').prependTo(cf); jQuery(widget.getDOMNode(widget)).css('vertical-align', 'top').prependTo(cf);
} }
return false; return false;
}; }
/** /**
* Display links in list as CF name * Display links in list as CF name
* @param field_name * @param field_name
* @param field * @param field
* @param attrs * @param attrs
*/ */
et2_customfields_list.prototype._setup_url = function (field_name, field, attrs) { _setup_url(field_name, field, attrs) {
if (this.getType() == 'customfields-list') { if (this.getType() == 'customfields-list') {
attrs.label = field.label; attrs.label = field.label;
} }
return true; return true;
}; }
/** /**
* Set which fields are visible, by name * Set which fields are visible, by name
* *
* Note: no # prefix on the name * Note: no # prefix on the name
* *
*/ */
et2_customfields_list.prototype.set_visible = function (_fields) { set_visible(_fields) {
for (var name_1 in _fields) { for (let name in _fields) {
if (this.rows[this.options.prefix + name_1]) { if (this.rows[this.options.prefix + name]) {
if (_fields[name_1]) { if (_fields[name]) {
jQuery(this.rows[this.options.prefix + name_1]).show(); jQuery(this.rows[this.options.prefix + name]).show();
} }
else { else {
jQuery(this.rows[this.options.prefix + name_1]).hide(); jQuery(this.rows[this.options.prefix + name]).hide();
} }
} }
this.options.fields[name_1] = _fields[name_1]; this.options.fields[name] = _fields[name];
}
} }
};
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
*/ */
et2_customfields_list.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value", "class"); _attrs.push("value", "class");
}; }
et2_customfields_list.prototype.getDetachedNodes = function () { getDetachedNodes() {
return this.detachedNodes ? this.detachedNodes : []; return this.detachedNodes ? this.detachedNodes : [];
}; }
et2_customfields_list.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
// Individual widgets are detected and handled by the grid, but the interface is needed for this to happen // Individual widgets are detected and handled by the grid, but the interface is needed for this to happen
// Show the row if there's a value, hide it if there is no value // Show the row if there's a value, hide it if there is no value
for (var i = 0; i < _nodes.length; i++) { for (let i = 0; i < _nodes.length; i++) {
// toggle() needs a boolean to do what we want // toggle() needs a boolean to do what we want
var key = _nodes[i].getAttribute('data-field'); const key = _nodes[i].getAttribute('data-field');
jQuery(_nodes[i]).toggle(_values.fields[key] && _values.value[this.options.prefix + key] ? true : false); jQuery(_nodes[i]).toggle(_values.fields[key] && _values.value[this.options.prefix + key] ? true : false);
} }
}; }
et2_customfields_list._attributes = { }
et2_customfields_list._attributes = {
'customfields': { 'customfields': {
'name': 'Custom fields', 'name': 'Custom fields',
'description': 'Auto filled', 'description': 'Auto filled',
@ -644,12 +627,9 @@ var et2_customfields_list = /** @class */ (function (_super) {
default: "#", default: "#",
description: "Custom prefix for custom fields. Default #" description: "Custom prefix for custom fields. Default #"
} }
}; };
et2_customfields_list.legacyOptions = ["type_filter", "private", "fields"]; // Field restriction & private done server-side et2_customfields_list.legacyOptions = ["type_filter", "private", "fields"]; // Field restriction & private done server-side
et2_customfields_list.PREFIX = '#'; et2_customfields_list.PREFIX = '#';
et2_customfields_list.DEFAULT_ID = "custom_fields"; et2_customfields_list.DEFAULT_ID = "custom_fields";
return et2_customfields_list; et2_register_widget(et2_customfields_list, ["customfields", "customfields-list"]);
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_customfields_list = et2_customfields_list;
et2_core_widget_1.et2_register_widget(et2_customfields_list, ["customfields", "customfields-list"]);
//# sourceMappingURL=et2_extension_customfields.js.map //# sourceMappingURL=et2_extension_customfields.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 2011
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -18,10 +17,14 @@
et2_core_inputWidget; et2_core_inputWidget;
*/ */
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, et2_registry, WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {et2_readonlysArrayMgr} from "./et2_core_arrayMgr"; import {et2_readonlysArrayMgr} from "./et2_core_arrayMgr";
import {et2_IDetachedDOM, et2_IInput} from "./et2_core_interfaces";
import {et2_cloneObject, et2_no_init} from "./et2_core_common";
import {egw} from "../jsapi/egw_global";
import {et2_DOMWidget} from "./et2_core_DOMWidget";
export class et2_customfields_list extends et2_valueWidget implements et2_IDetachedDOM, et2_IInput export class et2_customfields_list extends et2_valueWidget implements et2_IDetachedDOM, et2_IInput
{ {
@ -80,7 +83,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
private tbody: JQuery; private tbody: JQuery;
private table: JQuery; private table: JQuery;
private rows = {}; private rows = {};
private widgets = {}; widgets = {};
private detachedNodes = []; private detachedNodes = [];
constructor(_parent?, _attrs? : WidgetConfig, _child? : object) constructor(_parent?, _attrs? : WidgetConfig, _child? : object)
@ -713,7 +716,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
.appendTo(row); .appendTo(row);
// Create upload widget // Create upload widget
let widget = this.widgets[field_name] = et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this); let widget = this.widgets[field_name] = <et2_DOMWidget>et2_createWidget(attrs.type ? attrs.type : field.type, attrs, this);
// This controls where the widget is placed in the DOM // This controls where the widget is placed in the DOM
this.rows[attrs.id] = cf[0]; this.rows[attrs.id] = cf[0];
@ -736,7 +739,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
this.rows[select_attrs.id] = cf[0]; this.rows[select_attrs.id] = cf[0];
// Do not store in the widgets list, one name for multiple widgets would cause problems // Do not store in the widgets list, one name for multiple widgets would cause problems
widget = et2_createWidget(select_attrs.type, select_attrs, this); widget = <et2_DOMWidget>et2_createWidget(select_attrs.type, select_attrs, this);
jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf); jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf);
} }
return false; return false;

View File

@ -5,7 +5,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Christian Binder * @author Christian Binder
* @author Nathan Gray * @author Nathan Gray
* @copyright 2012 Christian Binder * @copyright 2012 Christian Binder
@ -13,8 +13,8 @@
*/ */
function itempickerDocumentAction(context, data) { function itempickerDocumentAction(context, data) {
"use strict"; "use strict";
var formid = "itempicker_action_form"; let formid = "itempicker_action_form";
var form = "<form id='" + formid + "' action='index.php?menuaction=" + data.app + "." + data.app + "_merge.download_by_request' method='POST'>" let form = "<form id='" + formid + "' action='index.php?menuaction=" + data.app + "." + data.app + "_merge.download_by_request' method='POST'>"
+ "<input type='hidden' name='data_document_name' value='" + data.value.name + "' />" + "<input type='hidden' name='data_document_name' value='" + data.value.name + "' />"
+ "<input type='hidden' name='data_document_dir' value='" + data.value.dir + "' />" + "<input type='hidden' name='data_document_dir' value='" + data.value.dir + "' />"
+ "<input type='hidden' name='data_checked' value='" + data.checked.join(',') + "' />" + "<input type='hidden' name='data_checked' value='" + data.checked.join(',') + "' />"

View File

@ -5,7 +5,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Christian Binder * @author Christian Binder
* @author Nathan Gray * @author Nathan Gray
* @copyright 2012 Christian Binder * @copyright 2012 Christian Binder

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
@ -41,8 +40,8 @@
*/ */
import './et2_core_common'; import {et2_csvSplit, et2_no_init} from "./et2_core_common";
import './et2_core_interfaces'; import {et2_IInput, et2_IPrint, et2_IResizeable, implements_methods, et2_implements_registry} from "./et2_core_interfaces";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget";
import {et2_DOMWidget} from "./et2_core_DOMWidget"; import {et2_DOMWidget} from "./et2_core_DOMWidget";
@ -65,6 +64,8 @@ import {et2_arrayMgr} from "./et2_core_arrayMgr";
import {et2_button} from "./et2_widget_button"; import {et2_button} from "./et2_widget_button";
import {et2_searchbox} from "./et2_widget_textbox"; import {et2_searchbox} from "./et2_widget_textbox";
import {et2_template} from "./et2_widget_template"; import {et2_template} from "./et2_widget_template";
import {app, egw} from "../jsapi/egw_global";
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
//import {et2_selectAccount} from "./et2_widget_SelectAccount"; //import {et2_selectAccount} from "./et2_widget_SelectAccount";
@ -82,8 +83,8 @@ export interface et2_INextmatchHeader {
*/ */
setNextmatch(nextmatch : et2_nextmatch) : void setNextmatch(nextmatch : et2_nextmatch) : void
} }
var et2_INextmatchHeader = "et2_INextmatchHeader"; export const et2_INextmatchHeader = "et2_INextmatchHeader";
function implements_et2_INextmatchHeader(obj : et2_widget) et2_implements_registry.et2_INextmatchHeader = function(obj : et2_widget)
{ {
return implements_methods(obj, ["setNextmatch"]); return implements_methods(obj, ["setNextmatch"]);
} }
@ -93,9 +94,8 @@ export interface et2_INextmatchSortable
setSortmode(_sort_mode): void setSortmode(_sort_mode): void
} }
var et2_INextmatchSortable = "et2_INextmatchSortable"; export const et2_INextmatchSortable = "et2_INextmatchSortable";
et2_implements_registry.et2_INextmatchSortable = function(obj: et2_widget)
function implements_et2_INextmatchSortable(obj: et2_widget)
{ {
return implements_methods(obj, ["setSortmode"]); return implements_methods(obj, ["setSortmode"]);
} }
@ -3105,7 +3105,7 @@ et2_register_widget(et2_nextmatch, ["nextmatch"]);
* actually load templates from the server. * actually load templates from the server.
* @augments et2_DOMWidget * @augments et2_DOMWidget
*/ */
class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INextmatchHeader export class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INextmatchHeader
{ {
static readonly _attributes: any = { static readonly _attributes: any = {
"filter_label": { "filter_label": {
@ -4298,7 +4298,7 @@ et2_register_widget(et2_nextmatch_accountfilterheader, ['nextmatch-accountfilter
* *
* @augments et2_taglist * @augments et2_taglist
*/ */
class et2_nextmatch_taglistheader extends et2_taglist implements et2_INextmatchHeader, et2_IResizeable export class et2_nextmatch_taglistheader extends et2_taglist implements et2_INextmatchHeader, et2_IResizeable
{ {
static readonly _attributes : any = { static readonly _attributes : any = {
autocomplete_url: { default: ''}, autocomplete_url: { default: ''},
@ -4386,7 +4386,7 @@ et2_register_widget(et2_nextmatch_taglistheader, ['nextmatch-taglistheader']);
/** /**
* Nextmatch filter that can filter for a selected entry * Nextmatch filter that can filter for a selected entry
*/ */
class et2_nextmatch_entryheader extends et2_link_entry implements et2_INextmatchHeader export class et2_nextmatch_entryheader extends et2_link_entry implements et2_INextmatchHeader
{ {
/** /**
* Override to add change handler * Override to add change handler
@ -4461,7 +4461,7 @@ et2_register_widget(et2_nextmatch_entryheader, ['nextmatch-entryheader']);
/** /**
* @augments et2_nextmatch_filterheader * @augments et2_nextmatch_filterheader
*/ */
class et2_nextmatch_customfilter extends et2_nextmatch_filterheader export class et2_nextmatch_customfilter extends et2_nextmatch_filterheader
{ {
static readonly _attributes: any = { static readonly _attributes: any = {
"widget_type": { "widget_type": {

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright Stylite AG 2012-14 * @copyright EGroupware GmbH 2012-2021
* @version $Id$
*/ */
/** /**

View File

@ -1,53 +1,22 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Class which contains a the data model for nextmatch widgets * EGroupware eTemplate2 - Class which contains a the data model for nextmatch widgets
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
* import { et2_dataview_row } from "./et2_dataview_view_row";
import { et2_dataview_tile } from "./et2_dataview_view_tile";
/*egw:uses import { et2_dataview_controller } from "./et2_dataview_controller";
et2_core_common; import { et2_dataview_column } from "./et2_dataview_model_columns";
et2_core_inheritance; import { framework } from "../jsapi/egw_global";
et2_dataview_view_row;
et2_dataview_controller;
et2_dataview_interfaces;
et2_dataview_view_tile;
et2_extension_nextmatch_actions; // Contains nm_action
egw_data;
*/
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_nextmatch_controller = void 0;
var et2_dataview_view_row_1 = require("./et2_dataview_view_row");
var et2_dataview_view_tile_1 = require("./et2_dataview_view_tile");
var et2_dataview_controller_1 = require("./et2_dataview_controller");
var et2_dataview_model_columns_1 = require("./et2_dataview_model_columns");
/** /**
* @augments et2_dataview_controller * @augments et2_dataview_controller
*/ */
var et2_nextmatch_controller = /** @class */ (function (_super) { export class et2_nextmatch_controller extends et2_dataview_controller {
__extends(et2_nextmatch_controller, _super);
/** /**
* Initializes the nextmatch controller. * Initializes the nextmatch controller.
* *
@ -64,62 +33,60 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
* is given. * is given.
* @memberOf et2_nextmatch_controller * @memberOf et2_nextmatch_controller
*/ */
function et2_nextmatch_controller(_parentController, _egw, _execId, _widget, _parentId, _grid, _rowProvider, _actionLinks, _objectManager, _actions) { constructor(_parentController, _egw, _execId, _widget, _parentId, _grid, _rowProvider, _actionLinks, _objectManager, _actions) {
var _this =
// Call the parent et2_dataview_controller constructor // Call the parent et2_dataview_controller constructor
_super.call(this, _parentController, _grid) || this; super(_parentController, _grid);
_this.setDataProvider(_this); this.setDataProvider(this);
_this.setRowCallback(_this._rowCallback); this.setRowCallback(this._rowCallback);
_this.setLinkCallback(_this._linkCallback); this.setLinkCallback(this._linkCallback);
_this.setContext(_this); this.setContext(this);
// Copy the egw reference // Copy the egw reference
_this.egw = _egw; this.egw = _egw;
// Keep a reference to the widget // Keep a reference to the widget
_this._widget = _widget; this._widget = _widget;
// Copy the given parameters // Copy the given parameters
_this._actionLinks = _actionLinks; this._actionLinks = _actionLinks;
_this._execId = _execId; this._execId = _execId;
// Get full widget ID, including path // Get full widget ID, including path
var id = _widget.getArrayMgr('content').getPath(); var id = _widget.getArrayMgr('content').getPath();
if (typeof id == 'string') { if (typeof id == 'string') {
_this._widgetId = id; this._widgetId = id;
} }
else if (id.length === 1) { else if (id.length === 1) {
_this._widgetId = id[0]; this._widgetId = id[0];
} }
else { else {
_this._widgetId = id.shift() + '[' + id.join('][') + ']'; this._widgetId = id.shift() + '[' + id.join('][') + ']';
} }
_this._parentId = _parentId; this._parentId = _parentId;
_this._rowProvider = _rowProvider; this._rowProvider = _rowProvider;
// Initialize the action and the object manager // Initialize the action and the object manager
// _initActions calls _init_link_dnd, which uses this._actionLinks, // _initActions calls _init_link_dnd, which uses this._actionLinks,
// so this must happen after the above parameter copying // so this must happen after the above parameter copying
if (!_objectManager) { if (!_objectManager) {
_this._initActions(_actions); this._initActions(_actions);
} }
else { else {
_this._actionManager = null; this._actionManager = null;
_this._objectManager = _objectManager; this._objectManager = _objectManager;
} }
_this.setActionObjectManager(_this._objectManager); this.setActionObjectManager(this._objectManager);
// Add our selection callback to selection manager // Add our selection callback to selection manager
var self = _this; var self = this;
_this._objectManager.setSelectedCallback = function () { self._selectCallback.apply(self, [this, arguments]); }; this._objectManager.setSelectedCallback = function () { self._selectCallback.apply(self, [this, arguments]); };
// We start with no filters // We start with no filters
_this._filters = {}; this._filters = {};
// Keep selection across filter changes // Keep selection across filter changes
_this.kept_selection = null; this.kept_selection = null;
_this.kept_focus = null; this.kept_focus = null;
_this.kept_expansion = []; this.kept_expansion = [];
// Directly use the API-Implementation of dataRegisterUID and // Directly use the API-Implementation of dataRegisterUID and
// dataUnregisterUID // dataUnregisterUID
_this.dataUnregisterUID = _egw.dataUnregisterUID; this.dataUnregisterUID = _egw.dataUnregisterUID;
// Default to rows // Default to rows
_this._view = et2_nextmatch_controller.VIEW_ROW; this._view = et2_nextmatch_controller.VIEW_ROW;
return _this;
} }
et2_nextmatch_controller.prototype.destroy = function () { destroy() {
// If the actionManager variable is set, the object- and actionManager // If the actionManager variable is set, the object- and actionManager
// were created by this instance -- clear them // were created by this instance -- clear them
if (this._actionManager) { if (this._actionManager) {
@ -127,20 +94,20 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
this._actionManager.remove(); this._actionManager.remove();
} }
this._widget = null; this._widget = null;
_super.prototype.destroy.call(this); super.destroy();
}; }
/** /**
* Updates the filter instance. * Updates the filter instance.
*/ */
et2_nextmatch_controller.prototype.setFilters = function (_filters) { setFilters(_filters) {
// Update the filters // Update the filters
this._filters = _filters; this._filters = _filters;
}; }
/** /**
* Keep the selection, if possible, across a data fetch and restore it * Keep the selection, if possible, across a data fetch and restore it
* after * after
*/ */
et2_nextmatch_controller.prototype.keepSelection = function () { keepSelection() {
this.kept_selection = this._selectionMgr ? this._selectionMgr.getSelected() : null; this.kept_selection = this._selectionMgr ? this._selectionMgr.getSelected() : null;
this.kept_focus = this._selectionMgr && this._selectionMgr._focusedEntry ? this.kept_focus = this._selectionMgr && this._selectionMgr._focusedEntry ?
this._selectionMgr._focusedEntry.uid || null : null; this._selectionMgr._focusedEntry.uid || null : null;
@ -153,17 +120,17 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
controller.kept_expansion.push(entry.uid); controller.kept_expansion.push(entry.uid);
} }
}); });
}; }
et2_nextmatch_controller.prototype.getObjectManager = function () { getObjectManager() {
return this._objectManager; return this._objectManager;
}; }
/** /**
* Deletes a row from the grid * Deletes a row from the grid
* *
* @param {string} uid * @param {string} uid
*/ */
et2_nextmatch_controller.prototype.deleteRow = function (uid) { deleteRow(uid) {
var entry = Object.values(this._indexMap).find(function (entry) { return entry.uid == uid; }); var entry = Object.values(this._indexMap).find(entry => entry.uid == uid);
// Unselect // Unselect
this._selectionMgr.setSelected(uid, false); this._selectionMgr.setSelected(uid, false);
if (entry && entry.idx !== null) { if (entry && entry.idx !== null) {
@ -192,11 +159,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
// Not needed, they share by reference // Not needed, they share by reference
// this._selectionMgr.setIndexMap(this._indexMap); // this._selectionMgr.setIndexMap(this._indexMap);
} }
for (var _i = 0, _a = this._children; _i < _a.length; _i++) { for (let child of this._children) {
var child = _a[_i];
child.deleteRow(uid); child.deleteRow(uid);
} }
}; }
/** -- PRIVATE FUNCTIONS -- **/ /** -- PRIVATE FUNCTIONS -- **/
/** /**
* Create a new row, either normal or tiled * Create a new row, either normal or tiled
@ -204,10 +170,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
* @param {type} ctx * @param {type} ctx
* @returns {et2_dataview_container} * @returns {et2_dataview_container}
*/ */
et2_nextmatch_controller.prototype._createRow = function (ctx) { _createRow(ctx) {
switch (this._view) { switch (this._view) {
case et2_nextmatch_controller.VIEW_TILE: case et2_nextmatch_controller.VIEW_TILE:
var row = new et2_dataview_view_tile_1.et2_dataview_tile(this._grid); var row = new et2_dataview_tile(this._grid);
// Try to overcome chrome rendering issue where float is not // Try to overcome chrome rendering issue where float is not
// applied properly, leading to incomplete rows // applied properly, leading to incomplete rows
window.setTimeout(function () { window.setTimeout(function () {
@ -223,13 +189,13 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
return row; return row;
case et2_nextmatch_controller.VIEW_ROW: case et2_nextmatch_controller.VIEW_ROW:
default: default:
return new et2_dataview_view_row_1.et2_dataview_row(this._grid); return new et2_dataview_row(this._grid);
}
} }
};
/** /**
* Initializes the action and the object manager. * Initializes the action and the object manager.
*/ */
et2_nextmatch_controller.prototype._initActions = function (_actions) { _initActions(_actions) {
// Generate a uid for the action and object manager // Generate a uid for the action and object manager
var uid = this._widget.id || this.egw.uid(); var uid = this._widget.id || this.egw.uid();
if (_actions == null) if (_actions == null)
@ -303,11 +269,11 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
} }
} }
} }
}; }
/** /**
* Automatically add dnd support for linking * Automatically add dnd support for linking
*/ */
et2_nextmatch_controller.prototype._init_links_dnd = function () { _init_links_dnd() {
var mgr = this._actionManager; var mgr = this._actionManager;
var self = this; var self = this;
var drop_action = mgr.getActionById('egw_link_drop'); var drop_action = mgr.getActionById('egw_link_drop');
@ -403,29 +369,29 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
this._actionLinks.push(drag_action.id); this._actionLinks.push(drag_action.id);
} }
drag_action.set_dragType('link'); drag_action.set_dragType('link');
}; }
/** /**
* Set the data cache prefix * Set the data cache prefix
* Overridden from the parent to re-check automatically the added link dnd * Overridden from the parent to re-check automatically the added link dnd
* since the prefix is used in support detection. * since the prefix is used in support detection.
*/ */
et2_nextmatch_controller.prototype.setPrefix = function (prefix) { setPrefix(prefix) {
_super.prototype.setPrefix.call(this, prefix); super.setPrefix(prefix);
this._init_links_dnd(); this._init_links_dnd();
}; }
/** /**
* Overwrites the inherited _destroyCallback function in order to be able * Overwrites the inherited _destroyCallback function in order to be able
* to free the "rowWidget". * to free the "rowWidget".
*/ */
et2_nextmatch_controller.prototype._destroyCallback = function (_row) { _destroyCallback(_row) {
// Destroy any widget associated to the row // Destroy any widget associated to the row
if (this.entry.widget) { if (this.entry.widget) {
this.entry.widget.destroy(); this.entry.widget.destroy();
this.entry.widget = null; this.entry.widget = null;
} }
// Call the inherited function // Call the inherited function
_super.prototype._destroyCallback.call(this, _row); super._destroyCallback(_row);
}; }
/** /**
* Creates the actual data row. * Creates the actual data row.
* *
@ -436,11 +402,11 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
* this special case used to store the rowWidget reference, so that it can * this special case used to store the rowWidget reference, so that it can
* be properly freed. * be properly freed.
*/ */
et2_nextmatch_controller.prototype._rowCallback = function (_data, _tr, _idx, _entry) { _rowCallback(_data, _tr, _idx, _entry) {
// Let the row provider fill in the data row -- store the returned // Let the row provider fill in the data row -- store the returned
// rowWidget inside the _entry // rowWidget inside the _entry
_entry.widget = this._rowProvider.getDataRow({ "content": _data }, _tr, _idx, this); _entry.widget = this._rowProvider.getDataRow({ "content": _data }, _tr, _idx, this);
}; }
/** /**
* Returns the names of action links for a given data row -- currently these are * Returns the names of action links for a given data row -- currently these are
* always the same links, as we controll enabled/disabled over the row * always the same links, as we controll enabled/disabled over the row
@ -458,7 +424,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
* *
* @return Array List of action names that valid for the row * @return Array List of action names that valid for the row
*/ */
et2_nextmatch_controller.prototype._linkCallback = function (_data, _idx, _uid) { _linkCallback(_data, _idx, _uid) {
if (_uid.trim() != "") { if (_uid.trim() != "") {
return this._actionLinks; return this._actionLinks;
} }
@ -486,13 +452,13 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
catch (e) { catch (e) {
} }
return links; return links;
}; }
/** /**
* Overridden from the parent to also process any additional data that * Overridden from the parent to also process any additional data that
* the data source adds, such as readonlys and additonal content. * the data source adds, such as readonlys and additonal content.
* For example, non-numeric IDs in rows are added to the content manager * For example, non-numeric IDs in rows are added to the content manager
*/ */
et2_nextmatch_controller.prototype._fetchCallback = function (_response) { _fetchCallback(_response) {
var nm = this.self._widget; var nm = this.self._widget;
if (!nm) { if (!nm) {
// Nextmatch either not connected, or it tried to destroy this // Nextmatch either not connected, or it tried to destroy this
@ -542,7 +508,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
col_refresh = true; col_refresh = true;
nm.dataview.columnMgr.getColumnById('col_' + column_index) nm.dataview.columnMgr.getColumnById('col_' + column_index)
.set_visibility(nm.getArrayMgr('content').parseBoolExpression(nm.columns[column_index].disabled) ? .set_visibility(nm.getArrayMgr('content').parseBoolExpression(nm.columns[column_index].disabled) ?
et2_dataview_model_columns_1.et2_dataview_column.ET2_COL_VISIBILITY_DISABLED : et2_dataview_column.ET2_COL_VISIBILITY_DISABLED :
nm.columns[column_index].visible); nm.columns[column_index].visible);
} }
} }
@ -558,7 +524,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
this.self.keepSelection(); this.self.keepSelection();
} }
// Call the inherited function // Call the inherited function
_super.prototype._fetchCallback.apply(this, arguments); super._fetchCallback.apply(this, arguments);
// Restore selection, if passed // Restore selection, if passed
if (this.self && this.self.kept_selection && this.self._selectionMgr) { if (this.self && this.self.kept_selection && this.self._selectionMgr) {
if (this.self.kept_selection.all) { if (this.self.kept_selection.all) {
@ -584,11 +550,11 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
} }
this.self.kept_focus = null; this.self.kept_focus = null;
} }
}; }
/** /**
* Execute the select callback when the row selection changes * Execute the select callback when the row selection changes
*/ */
et2_nextmatch_controller.prototype._selectCallback = function (action, senders) { _selectCallback(action, senders) {
if (typeof senders == "undefined") { if (typeof senders == "undefined") {
senders = []; senders = [];
} }
@ -598,9 +564,9 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
if (egwIsMobile()) if (egwIsMobile())
framework.nm_onselect_ctrl(this._widget, action, senders); framework.nm_onselect_ctrl(this._widget, action, senders);
this._widget.onselect.call(this._widget, action, senders); this._widget.onselect.call(this._widget, action, senders);
}; }
/** -- Implementation of et2_IDataProvider -- **/ /** -- Implementation of et2_IDataProvider -- **/
et2_nextmatch_controller.prototype.dataFetch = function (_queriedRange, _callback, _context) { dataFetch(_queriedRange, _callback, _context) {
// Merge the parent id into the _queriedRange if it is set // Merge the parent id into the _queriedRange if it is set
if (this._parentId !== null) { if (this._parentId !== null) {
_queriedRange["parent_id"] = this._parentId; _queriedRange["parent_id"] = this._parentId;
@ -613,21 +579,19 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
// Pass the fetch call to the API, multiplex the data about the // Pass the fetch call to the API, multiplex the data about the
// nextmatch instance into the call. // nextmatch instance into the call.
this.egw.dataFetch(this._widget.getInstanceManager().etemplate_exec_id || this._execId, _queriedRange, obj._filters, this._widgetId, _callback, _context); this.egw.dataFetch(this._widget.getInstanceManager().etemplate_exec_id || this._execId, _queriedRange, obj._filters, this._widgetId, _callback, _context);
}; }
et2_nextmatch_controller.prototype.dataRegisterUID = function (_uid, _callback, _context) { dataRegisterUID(_uid, _callback, _context) {
// Make sure we use correct prefix when data comes back // Make sure we use correct prefix when data comes back
if (this._widget && this._widget._get_appname() != this.egw.getAppName()) { if (this._widget && this._widget._get_appname() != this.egw.getAppName()) {
_context.prefix = _uid.split('::')[0]; _context.prefix = _uid.split('::')[0];
} }
this.egw.dataRegisterUID(_uid, _callback, _context, this._widget.getInstanceManager().etemplate_exec_id || this._execId, this._widgetId); this.egw.dataRegisterUID(_uid, _callback, _context, this._widget.getInstanceManager().etemplate_exec_id || this._execId, this._widgetId);
}; }
et2_nextmatch_controller.prototype.dataUnregisterUID = function () { dataUnregisterUID() {
// Overwritten in the constructor // Overwritten in the constructor
}; }
// Display constants }
et2_nextmatch_controller.VIEW_ROW = 'row'; // Display constants
et2_nextmatch_controller.VIEW_TILE = 'tile'; et2_nextmatch_controller.VIEW_ROW = 'row';
return et2_nextmatch_controller; et2_nextmatch_controller.VIEW_TILE = 'tile';
}(et2_dataview_controller_1.et2_dataview_controller));
exports.et2_nextmatch_controller = et2_nextmatch_controller;
//# sourceMappingURL=et2_extension_nextmatch_controller.js.map //# sourceMappingURL=et2_extension_nextmatch_controller.js.map

View File

@ -4,11 +4,10 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$ */
*
/*egw:uses /*egw:uses
et2_core_common; et2_core_common;
@ -30,6 +29,7 @@ import {et2_dataview_tile} from "./et2_dataview_view_tile";
import {et2_nextmatch} from "./et2_extension_nextmatch"; import {et2_nextmatch} from "./et2_extension_nextmatch";
import {et2_dataview_controller} from "./et2_dataview_controller"; import {et2_dataview_controller} from "./et2_dataview_controller";
import {et2_dataview_column} from "./et2_dataview_model_columns"; import {et2_dataview_column} from "./et2_dataview_model_columns";
import {framework, Iegw} from "../jsapi/egw_global";
/** /**
* @augments et2_dataview_controller * @augments et2_dataview_controller
@ -41,6 +41,18 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
public static readonly VIEW_TILE: string = 'tile'; public static readonly VIEW_TILE: string = 'tile';
private _widget: et2_nextmatch; private _widget: et2_nextmatch;
private egw: Iegw;
private _actionLinks: any;
private _execId: string;
private _widgetId: string;
private _parentId: string;
private _rowProvider: any;
private _actionManager: any;
private _filters: any;
private kept_selection: any;
private kept_focus: any;
private kept_expansion: any[];
private _view: string;
/** /**
* Initializes the nextmatch controller. * Initializes the nextmatch controller.

View File

@ -1,30 +1,13 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Class which contains a factory method for rows * EGroupware eTemplate2 - Class which contains a factory method for rows
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_nextmatch_rowProvider = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_inheritance; et2_core_inheritance;
@ -33,14 +16,17 @@ exports.et2_nextmatch_rowProvider = void 0;
et2_core_widget; et2_core_widget;
et2_dataview_view_rowProvider; et2_dataview_view_rowProvider;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_widget } from "./et2_core_widget";
var et2_core_arrayMgr_1 = require("./et2_core_arrayMgr"); import { et2_arrayMgrs_expand } from "./et2_core_arrayMgr";
import { et2_dataview_grid } from "./et2_dataview_view_grid";
import { egw } from "../jsapi/egw_global";
import { et2_IDetachedDOM, et2_IDOMNode } from "./et2_core_interfaces";
/** /**
* The row provider contains prototypes (full clonable dom-trees) * The row provider contains prototypes (full clonable dom-trees)
* for all registered row types. * for all registered row types.
* *
*/ */
var et2_nextmatch_rowProvider = /** @class */ (function () { export class et2_nextmatch_rowProvider {
/** /**
* Creates the nextmatch row provider. * Creates the nextmatch row provider.
* *
@ -49,7 +35,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
* @param {object} _context * @param {object} _context
* @memberOf et2_nextmatch_rowProvider * @memberOf et2_nextmatch_rowProvider
*/ */
function et2_nextmatch_rowProvider(_rowProvider, _subgridCallback, _context) { constructor(_rowProvider, _subgridCallback, _context) {
/** /**
* Match category-ids from class attribute eg. "cat_15" or "123,456,789 " * Match category-ids from class attribute eg. "cat_15" or "123,456,789 "
* *
@ -68,12 +54,12 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
this._context = _context; this._context = _context;
this._createEmptyPrototype(); this._createEmptyPrototype();
} }
et2_nextmatch_rowProvider.prototype.destroy = function () { destroy() {
this._rowProvider.destroy(); this._rowProvider.destroy();
this._subgridCallback = null; this._subgridCallback = null;
this._context = null; this._context = null;
this._dataRow = null; this._dataRow = null;
}; }
/** /**
* Creates the data row prototype. * Creates the data row prototype.
* *
@ -82,7 +68,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
* @param _rootWidget is the parent widget of the data rows (i.e. * @param _rootWidget is the parent widget of the data rows (i.e.
* the nextmatch) * the nextmatch)
*/ */
et2_nextmatch_rowProvider.prototype.setDataRowTemplate = function (_widgets, _rowData, _rootWidget) { setDataRowTemplate(_widgets, _rowData, _rootWidget) {
// Copy the root widget // Copy the root widget
this._rootWidget = _rootWidget; this._rootWidget = _rootWidget;
// Create the base row // Create the base row
@ -118,12 +104,12 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
row.children().each(function () { tmpl.appendChild(this); }); row.children().each(function () { tmpl.appendChild(this); });
this._dataRow = tmpl; this._dataRow = tmpl;
this._template = rowTemplate; this._template = rowTemplate;
}; }
et2_nextmatch_rowProvider.prototype.getDataRow = function (_data, _row, _idx, _controller) { getDataRow(_data, _row, _idx, _controller) {
// Clone the row template // Clone the row template
var row = this._dataRow.cloneNode(true); var row = this._dataRow.cloneNode(true);
// Create array managers with the given data merged in // Create array managers with the given data merged in
var mgrs = et2_core_arrayMgr_1.et2_arrayMgrs_expand(rowWidget, this._template.mgrs, _data, _idx); var mgrs = et2_arrayMgrs_expand(rowWidget, this._template.mgrs, _data, _idx);
// Insert the widgets into the row which do not provide the functions // Insert the widgets into the row which do not provide the functions
// to set the _data directly // to set the _data directly
var rowWidget = null; var rowWidget = null;
@ -200,7 +186,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
// Set the row data // Set the row data
this._setRowData(this._template.rowData, tr, mgrs); this._setRowData(this._template.rowData, tr, mgrs);
return rowWidget; return rowWidget;
}; }
/** /**
* Placeholder for empty row * Placeholder for empty row
* *
@ -208,7 +194,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
* This allows the user to still have a drop target, or use actions that * This allows the user to still have a drop target, or use actions that
* do not require a row ID, such as 'Add new'. * do not require a row ID, such as 'Add new'.
*/ */
et2_nextmatch_rowProvider.prototype._createEmptyPrototype = function () { _createEmptyPrototype() {
var label = this._context && this._context.options && this._context.options.settings.placeholder; var label = this._context && this._context.options && this._context.options.settings.placeholder;
var placeholder = jQuery(document.createElement("td")) var placeholder = jQuery(document.createElement("td"))
.attr("colspan", this._rowProvider.getColumnCount()) .attr("colspan", this._rowProvider.getColumnCount())
@ -217,16 +203,16 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
this._rowProvider._prototypes["empty"] = jQuery(document.createElement("tr")) this._rowProvider._prototypes["empty"] = jQuery(document.createElement("tr"))
.addClass("egwGridView_empty") .addClass("egwGridView_empty")
.append(placeholder); .append(placeholder);
}; }
/** -- PRIVATE FUNCTIONS -- **/ /** -- PRIVATE FUNCTIONS -- **/
/** /**
* Returns an array containing objects which have variable attributes * Returns an array containing objects which have variable attributes
* *
* @param {et2_widget} _widget * @param {et2_widget} _widget
*/ */
et2_nextmatch_rowProvider.prototype._getVariableAttributeSet = function (_widget) { _getVariableAttributeSet(_widget) {
var variableAttributes = []; let variableAttributes = [];
var process = function (_widget) { const process = function (_widget) {
// Create the attribtues // Create the attribtues
var hasAttr = false; var hasAttr = false;
var widgetData = { var widgetData = {
@ -234,10 +220,10 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
"data": [] "data": []
}; };
// Get all attribute values // Get all attribute values
for (var key in _widget.attributes) { for (const key in _widget.attributes) {
if (!_widget.attributes[key].ignore && if (!_widget.attributes[key].ignore &&
typeof _widget.options[key] != "undefined") { typeof _widget.options[key] != "undefined") {
var val = _widget.options[key]; const val = _widget.options[key];
// TODO: Improve detection // TODO: Improve detection
if (typeof val == "string" && val.indexOf("$") >= 0) { if (typeof val == "string" && val.indexOf("$") >= 0) {
hasAttr = true; hasAttr = true;
@ -254,7 +240,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
} }
}; };
// Check each column // Check each column
var columns = _widget._widgets; const columns = _widget._widgets;
for (var i = 0; i < columns.length; i++) { for (var i = 0; i < columns.length; i++) {
// If column is hidden, don't process it // If column is hidden, don't process it
if (typeof columns[i] === 'undefined' || this._context && this._context.columns && this._context.columns[i] && !this._context.columns[i].visible) { if (typeof columns[i] === 'undefined' || this._context && this._context.columns && this._context.columns[i] && !this._context.columns[i].visible) {
@ -263,8 +249,8 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
columns[i].iterateOver(process, this); columns[i].iterateOver(process, this);
} }
return variableAttributes; return variableAttributes;
}; }
et2_nextmatch_rowProvider.prototype._seperateWidgets = function (_varAttrs) { _seperateWidgets(_varAttrs) {
// The detachable array contains all widgets which implement the // The detachable array contains all widgets which implement the
// et2_IDetachedDOM interface for all needed attributes // et2_IDetachedDOM interface for all needed attributes
var detachable = []; var detachable = [];
@ -324,13 +310,13 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
"detachable": detachable, "detachable": detachable,
"remaining": remaining "remaining": remaining
}; };
}; }
/** /**
* Removes to DOM code for all widgets in the "remaining" slot * Removes to DOM code for all widgets in the "remaining" slot
* *
* @param {object} _rowTemplate * @param {object} _rowTemplate
*/ */
et2_nextmatch_rowProvider.prototype._stripTemplateRow = function (_rowTemplate) { _stripTemplateRow(_rowTemplate) {
_rowTemplate.placeholders = []; _rowTemplate.placeholders = [];
for (var i = 0; i < _rowTemplate.seperated.remaining.length; i++) { for (var i = 0; i < _rowTemplate.seperated.remaining.length; i++) {
var entry = _rowTemplate.seperated.remaining[i]; var entry = _rowTemplate.seperated.remaining[i];
@ -354,8 +340,8 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
} }
} }
} }
}; }
et2_nextmatch_rowProvider.prototype._nodeIndex = function (_node) { _nodeIndex(_node) {
if (_node.parentNode == null) { if (_node.parentNode == null) {
return 0; return 0;
} }
@ -365,14 +351,14 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
} }
} }
return -1; return -1;
}; }
/** /**
* Returns a function which does a relative access on the given DOM-Node * Returns a function which does a relative access on the given DOM-Node
* *
* @param {DOMElement} _root * @param {DOMElement} _root
* @param {DOMElement} _target * @param {DOMElement} _target
*/ */
et2_nextmatch_rowProvider.prototype._compileDOMAccessFunc = function (_root, _target) { _compileDOMAccessFunc(_root, _target) {
function recordPath(_root, _target, _path) { function recordPath(_root, _target, _path) {
if (typeof _path == "undefined") { if (typeof _path == "undefined") {
_path = []; _path = [];
@ -394,13 +380,13 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
} }
} }
return new Function("_node", recordPath.call(this, _root, _target)); return new Function("_node", recordPath.call(this, _root, _target));
}; }
/** /**
* Builds relative paths to the DOM-Nodes and compiles fast-access functions * Builds relative paths to the DOM-Nodes and compiles fast-access functions
* *
* @param {object} _rowTemplate * @param {object} _rowTemplate
*/ */
et2_nextmatch_rowProvider.prototype._buildNodeAccessFuncs = function (_rowTemplate) { _buildNodeAccessFuncs(_rowTemplate) {
for (var i = 0; i < _rowTemplate.seperated.detachable.length; i++) { for (var i = 0; i < _rowTemplate.seperated.detachable.length; i++) {
var entry = _rowTemplate.seperated.detachable[i]; var entry = _rowTemplate.seperated.detachable[i];
// Get all needed nodes from the widget // Get all needed nodes from the widget
@ -411,7 +397,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
nodeFuncs[j] = this._compileDOMAccessFunc(_rowTemplate.row, nodes[j]); nodeFuncs[j] = this._compileDOMAccessFunc(_rowTemplate.row, nodes[j]);
} }
} }
}; }
/** /**
* Applies additional row data (like the class) to the tr * Applies additional row data (like the class) to the tr
* *
@ -419,7 +405,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
* @param {DOMElement} _tr * @param {DOMElement} _tr
* @param {object} _mgrs * @param {object} _mgrs
*/ */
et2_nextmatch_rowProvider.prototype._setRowData = function (_data, _tr, _mgrs) { _setRowData(_data, _tr, _mgrs) {
// TODO: Implement other fields than "class" // TODO: Implement other fields than "class"
if (_data["class"]) { if (_data["class"]) {
var classes = _mgrs["content"].expandName(_data["class"]); var classes = _mgrs["content"].expandName(_data["class"]);
@ -449,15 +435,12 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
var align = _mgrs["content"].expandName(_data["valign"]); var align = _mgrs["content"].expandName(_data["valign"]);
_tr.setAttribute("valign", align); _tr.setAttribute("valign", align);
} }
}; }
return et2_nextmatch_rowProvider; }
}());
exports.et2_nextmatch_rowProvider = et2_nextmatch_rowProvider;
/** /**
* @augments et2_widget * @augments et2_widget
*/ */
var et2_nextmatch_rowWidget = /** @class */ (function (_super) { export class et2_nextmatch_rowWidget extends et2_widget {
__extends(et2_nextmatch_rowWidget, _super);
/** /**
* Constructor * Constructor
* *
@ -465,16 +448,14 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
* @param _row * @param _row
* @memberOf et2_nextmatch_rowWidget * @memberOf et2_nextmatch_rowWidget
*/ */
function et2_nextmatch_rowWidget(_mgrs, _row) { constructor(_mgrs, _row) {
var _this =
// Call the parent constructor with some dummy attributes // Call the parent constructor with some dummy attributes
_super.call(this, null, { "id": "", "type": "rowWidget" }) || this; super(null, { "id": "", "type": "rowWidget" });
// Initialize some variables // Initialize some variables
_this._widgets = []; this._widgets = [];
// Copy the given DOM node and the content arrays // Copy the given DOM node and the content arrays
_this._mgrs = _mgrs; this._mgrs = _mgrs;
_this._row = _row; this._row = _row;
return _this;
} }
/** /**
* Copies the given array manager and clones the given widgets and inserts * Copies the given array manager and clones the given widgets and inserts
@ -482,10 +463,10 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
* *
* @param {array} _widgets * @param {array} _widgets
*/ */
et2_nextmatch_rowWidget.prototype.createWidgets = function (_widgets) { createWidgets(_widgets) {
// Clone the given the widgets with this element as parent // Clone the given the widgets with this element as parent
this._widgets = []; this._widgets = [];
var row_id = 0; let row_id = 0;
for (var i = 0; i < _widgets.length; i++) { for (var i = 0; i < _widgets.length; i++) {
// Disabled columns might be missing widget - skip it // Disabled columns might be missing widget - skip it
if (!_widgets[i]) if (!_widgets[i])
@ -498,14 +479,14 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
} }
row_id++; row_id++;
} }
}; }
/** /**
* Returns the column node for the given sender * Returns the column node for the given sender
* *
* @param {et2_widget} _sender * @param {et2_widget} _sender
* @return {DOMElement} * @return {DOMElement}
*/ */
et2_nextmatch_rowWidget.prototype.getDOMNode = function (_sender) { getDOMNode(_sender) {
var row_id = 0; var row_id = 0;
for (var i = 0; i < this._widgets.length; i++) { for (var i = 0; i < this._widgets.length; i++) {
// Disabled columns might be missing widget - skip it // Disabled columns might be missing widget - skip it
@ -517,14 +498,12 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
row_id++; row_id++;
} }
return null; return null;
}; }
return et2_nextmatch_rowWidget; }
}(et2_core_widget_1.et2_widget));
/** /**
* @augments et2_widget * @augments et2_widget
*/ */
var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) { export class et2_nextmatch_rowTemplateWidget extends et2_widget {
__extends(et2_nextmatch_rowTemplateWidget, _super);
/** /**
* Constructor * Constructor
* *
@ -532,20 +511,18 @@ var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) {
* @param _row * @param _row
* @memberOf et2_nextmatch_rowTemplateWidget * @memberOf et2_nextmatch_rowTemplateWidget
*/ */
function et2_nextmatch_rowTemplateWidget(_root, _row) { constructor(_root, _row) {
var _this =
// Call the parent constructor with some dummy attributes // Call the parent constructor with some dummy attributes
_super.call(this, null, { "id": "", "type": "rowTemplateWidget" }) || this; super(null, { "id": "", "type": "rowTemplateWidget" });
_this._root = _root; this._root = _root;
_this._mgrs = {}; this._mgrs = {};
_this._row = _row; this._row = _row;
// Set parent to root widget, so sub-widget calls still work // Set parent to root widget, so sub-widget calls still work
_this._parent = _root; this._parent = _root;
// Clone the widgets inside the placeholders array // Clone the widgets inside the placeholders array
_this._widgets = []; this._widgets = [];
return _this;
} }
et2_nextmatch_rowTemplateWidget.prototype.createWidgets = function (_mgrs, _widgets) { createWidgets(_mgrs, _widgets) {
// Set the array managers - don't use setArrayMgrs here as this creates // Set the array managers - don't use setArrayMgrs here as this creates
// an unnecessary copy of the object // an unnecessary copy of the object
this._mgrs = _mgrs; this._mgrs = _mgrs;
@ -558,21 +535,20 @@ var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) {
}; };
this._widgets[i].widget.loadingFinished(); this._widgets[i].widget.loadingFinished();
} }
}; }
/** /**
* Returns the column node for the given sender * Returns the column node for the given sender
* *
* @param {et2_widget} _sender * @param {et2_widget} _sender
* @return {DOMElement} * @return {DOMElement}
*/ */
et2_nextmatch_rowTemplateWidget.prototype.getDOMNode = function (_sender) { getDOMNode(_sender) {
for (var i = 0; i < this._widgets.length; i++) { for (var i = 0; i < this._widgets.length; i++) {
if (this._widgets[i].widget == _sender) { if (this._widgets[i].widget == _sender) {
return this._widgets[i].node; return this._widgets[i].node;
} }
} }
return null; return null;
}; }
return et2_nextmatch_rowTemplateWidget; }
}(et2_core_widget_1.et2_widget));
//# sourceMappingURL=et2_extension_nextmatch_rowProvider.js.map //# sourceMappingURL=et2_extension_nextmatch_rowProvider.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2012 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -21,6 +20,9 @@
import {et2_widget} from "./et2_core_widget"; import {et2_widget} from "./et2_core_widget";
import {et2_arrayMgrs_expand} from "./et2_core_arrayMgr"; import {et2_arrayMgrs_expand} from "./et2_core_arrayMgr";
import {et2_dataview_grid} from "./et2_dataview_view_grid";
import {egw} from "../jsapi/egw_global";
import {et2_IDetachedDOM, et2_IDOMNode} from "./et2_core_interfaces";
/** /**
* The row provider contains prototypes (full clonable dom-trees) * The row provider contains prototypes (full clonable dom-trees)
@ -590,7 +592,7 @@ export class et2_nextmatch_rowProvider
/** /**
* @augments et2_widget * @augments et2_widget
*/ */
class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode export class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode
{ {
private _widgets: any[]; private _widgets: any[];
private _row: any; private _row: any;
@ -669,7 +671,7 @@ class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode
/** /**
* @augments et2_widget * @augments et2_widget
*/ */
class et2_nextmatch_rowTemplateWidget extends et2_widget implements et2_IDOMNode export class et2_nextmatch_rowTemplateWidget extends et2_widget implements et2_IDOMNode
{ {
private _root: any; private _root: any;
private _row: any; private _row: any;

View File

@ -1,4 +1,3 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Ajax select / auto complete object * EGroupware eTemplate2 - JS Ajax select / auto complete object
@ -6,35 +5,21 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
et2_core_inputWidget; et2_core_inputWidget;
et2_core_valueWidget; et2_core_valueWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
var et2_widget_selectbox_1 = require("./et2_widget_selectbox"); import { et2_selectbox } from "./et2_widget_selectbox";
/** /**
* Using AJAX, this widget allows a type-ahead find similar to a ComboBox, where as the user enters information, * Using AJAX, this widget allows a type-ahead find similar to a ComboBox, where as the user enters information,
* a drop-down box is populated with the n closest matches. If the user clicks on an item in the drop-down, that * a drop-down box is populated with the n closest matches. If the user clicks on an item in the drop-down, that
@ -44,38 +29,35 @@ var et2_widget_selectbox_1 = require("./et2_widget_selectbox");
* This widget can get data from any function that can provide data to a nextmatch widget. * This widget can get data from any function that can provide data to a nextmatch widget.
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_ajaxSelect = /** @class */ (function (_super) { export class et2_ajaxSelect extends et2_inputWidget {
__extends(et2_ajaxSelect, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_ajaxSelect * @memberOf et2_ajaxSelect
*/ */
function et2_ajaxSelect(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_ajaxSelect._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_ajaxSelect._attributes, _child || {}));
_this.input = null; this.input = null;
if (typeof _attrs.get_rows == 'string') { if (typeof _attrs.get_rows == 'string') {
_attrs.get_rows = _this.egw().link('/index.php', { _attrs.get_rows = this.egw().link('/index.php', {
menuaction: _this.options.get_rows menuaction: this.options.get_rows
}); });
} }
_this.createInputWidget(); this.createInputWidget();
_this.input = null; this.input = null;
_this.createInputWidget(); this.createInputWidget();
return _this;
} }
et2_ajaxSelect.prototype.createInputWidget = function () { createInputWidget() {
this.input = jQuery(document.createElement("input")); this.input = jQuery(document.createElement("input"));
this.input.addClass("et2_textbox"); this.input.addClass("et2_textbox");
this.setDOMNode(this.input[0]); this.setDOMNode(this.input[0]);
var widget = this; let widget = this;
this.input.autocomplete({ this.input.autocomplete({
delay: 100, delay: 100,
source: this.options.get_rows ? source: this.options.get_rows ?
this.options.get_rows : this.options.get_rows :
et2_widget_selectbox_1.et2_selectbox.find_select_options(this, this.options.values), et2_selectbox.find_select_options(this, this.options.values),
select: function (event, ui) { select: function (event, ui) {
widget.value = ui.item[widget.options.id_field]; widget.value = ui.item[widget.options.id_field];
if (widget.options.get_title) { if (widget.options.get_title) {
@ -93,18 +75,18 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
return false; return false;
} }
}); });
}; }
et2_ajaxSelect.prototype.getValue = function () { getValue() {
if (this.options.blur && this.input.val() == this.options.blur) if (this.options.blur && this.input.val() == this.options.blur)
return ""; return "";
return this.value; return this.value;
}; }
et2_ajaxSelect.prototype.set_value = function (_value) { set_value(_value) {
this.value = _value; this.value = _value;
if (this.input.autocomplete('instance')) { if (this.input.autocomplete('instance')) {
var source = this.input.autocomplete('option', 'source'); let source = this.input.autocomplete('option', 'source');
if (typeof source == 'object') { if (typeof source == 'object') {
for (var i in source) { for (let i in source) {
if (typeof source[i].value != 'undefined' && typeof source[i].label != 'undefined' && source[i].value === _value) { if (typeof source[i].value != 'undefined' && typeof source[i].label != 'undefined' && source[i].value === _value) {
this.input.val(source[i].label); this.input.val(source[i].label);
} }
@ -118,8 +100,8 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
// TODO // TODO
} }
} }
}; }
et2_ajaxSelect.prototype.set_blur = function (_value) { set_blur(_value) {
if (_value) { if (_value) {
this.input.attr("placeholder", _value + ""); // HTML5 this.input.attr("placeholder", _value + ""); // HTML5
if (!this.input[0]["placeholder"]) { if (!this.input[0]["placeholder"]) {
@ -138,8 +120,9 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
else { else {
this.input.removeAttr("placeholder"); this.input.removeAttr("placeholder");
} }
}; }
et2_ajaxSelect._attributes = { }
et2_ajaxSelect._attributes = {
'get_rows': { 'get_rows': {
"name": "Data source", "name": "Data source",
"type": "any", "type": "any",
@ -189,60 +172,54 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
"default": {}, "default": {},
"description": "Specify the available options. Use this, or Data source." "description": "Specify the available options. Use this, or Data source."
} }
}; };
return et2_ajaxSelect; et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
}(et2_core_inputWidget_1.et2_inputWidget));
et2_core_widget_1.et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
/** /**
* et2_textbox_ro is the dummy readonly implementation of the textbox. * et2_textbox_ro is the dummy readonly implementation of the textbox.
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_ajaxSelect_ro = /** @class */ (function (_super) { export class et2_ajaxSelect_ro extends et2_valueWidget {
__extends(et2_ajaxSelect_ro, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_ajaxSelect_ro * @memberOf et2_ajaxSelect_ro
*/ */
function et2_ajaxSelect_ro(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_ajaxSelect_ro._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_ajaxSelect_ro._attributes, _child || {}));
_this.value = ""; this.value = "";
_this.span = jQuery(document.createElement("span")); this.span = jQuery(document.createElement("span"));
_this.setDOMNode(_this.span[0]); this.setDOMNode(this.span[0]);
return _this;
} }
et2_ajaxSelect_ro.prototype.set_value = function (_value) { set_value(_value) {
this.value = _value; this.value = _value;
if (!_value) if (!_value)
_value = ""; _value = "";
this.span.text(_value); this.span.text(_value);
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
*/ */
et2_ajaxSelect_ro.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value"); _attrs.push("value");
}; }
et2_ajaxSelect_ro.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.span[0]]; return [this.span[0]];
}; }
et2_ajaxSelect_ro.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
this.span = jQuery(_nodes[0]); this.span = jQuery(_nodes[0]);
if (typeof _values["value"] != 'undefined') { if (typeof _values["value"] != 'undefined') {
this.set_value(_values["value"]); this.set_value(_values["value"]);
} }
}; }
/** }
/**
* Ignore all more advanced attributes. * Ignore all more advanced attributes.
*/ */
et2_ajaxSelect_ro._attributes = { et2_ajaxSelect_ro._attributes = {
"multiline": { "multiline": {
"ignore": true "ignore": true
} }
}; };
return et2_ajaxSelect_ro; et2_register_widget(et2_ajaxSelect_ro, ["ajax_select_ro"]);
}(et2_core_valueWidget_1.et2_valueWidget));
et2_core_widget_1.et2_register_widget(et2_ajaxSelect_ro, ["ajax_select_ro"]);
//# sourceMappingURL=et2_widget_ajaxSelect.js.map //# sourceMappingURL=et2_widget_ajaxSelect.js.map

View File

@ -5,7 +5,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
*/ */
@ -22,6 +22,7 @@ import {et2_inputWidget} from "./et2_core_inputWidget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {et2_selectbox} from "./et2_widget_selectbox"; import {et2_selectbox} from "./et2_widget_selectbox";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
/** /**
* Using AJAX, this widget allows a type-ahead find similar to a ComboBox, where as the user enters information, * Using AJAX, this widget allows a type-ahead find similar to a ComboBox, where as the user enters information,
@ -32,7 +33,7 @@ import {et2_selectbox} from "./et2_widget_selectbox";
* This widget can get data from any function that can provide data to a nextmatch widget. * This widget can get data from any function that can provide data to a nextmatch widget.
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
class et2_ajaxSelect extends et2_inputWidget export class et2_ajaxSelect extends et2_inputWidget
{ {
static readonly _attributes : any = { static readonly _attributes : any = {
'get_rows': { 'get_rows': {
@ -204,7 +205,7 @@ et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
* et2_textbox_ro is the dummy readonly implementation of the textbox. * et2_textbox_ro is the dummy readonly implementation of the textbox.
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
class et2_ajaxSelect_ro extends et2_valueWidget implements et2_IDetachedDOM export class et2_ajaxSelect_ro extends et2_valueWidget implements et2_IDetachedDOM
{ {
/** /**
* Ignore all more advanced attributes. * Ignore all more advanced attributes.

View File

@ -1,38 +1,21 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Audio tag * EGroupware eTemplate2 - JS Audio tag
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh <hn[at]egroupware.org> * @author Hadi Nategh <hn[at]egroupware.org>
* @copyright EGroupware GmbH * @copyright EGroupware GmbH
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_audio = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_interfaces; et2_core_interfaces;
et2_core_baseWidget; et2_core_baseWidget;
*/ */
var et2_core_baseWidget_1 = require("./et2_core_baseWidget"); import { et2_baseWidget } from './et2_core_baseWidget';
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
/** /**
* This widget represents the HTML5 Audio tag with all its optional attributes * This widget represents the HTML5 Audio tag with all its optional attributes
* *
@ -59,39 +42,37 @@ var et2_core_widget_1 = require("./et2_core_widget");
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
var et2_audio = /** @class */ (function (_super) { export class et2_audio extends et2_baseWidget {
__extends(et2_audio, _super); constructor(_parent, _attrs, _child) {
function et2_audio(_parent, _attrs, _child) { super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_audio._attributes, _child || {}));
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_audio._attributes, _child || {})) || this; this.audio = null;
_this.audio = null; this.container = null;
_this.container = null;
//Create Audio tag //Create Audio tag
_this.audio = new Audio(); this.audio = new Audio();
// Container // Container
_this.container = document.createElement('div'); this.container = document.createElement('div');
_this.container.append(_this.audio); this.container.append(this.audio);
_this.container.classList.add('et2_audio'); this.container.classList.add('et2_audio');
if (_this.options.autohide) if (this.options.autohide)
_this.container.classList.add('et2_audio_autohide'); this.container.classList.add('et2_audio_autohide');
if (_this.options.controls) if (this.options.controls)
_this.audio.setAttribute("controls", '1'); this.audio.setAttribute("controls", '1');
if (_this.options.autoplay) if (this.options.autoplay)
_this.audio.setAttribute("autoplay", '1'); this.audio.setAttribute("autoplay", '1');
if (_this.options.muted) if (this.options.muted)
_this.audio.setAttribute("muted", '1'); this.audio.setAttribute("muted", '1');
if (_this.options.loop) if (this.options.loop)
_this.audio.setAttribute("loop", '1'); this.audio.setAttribute("loop", '1');
if (_this.options.preload) if (this.options.preload)
_this.audio.setAttribute('preload', _this.options.preload); this.audio.setAttribute('preload', this.options.preload);
_this.setDOMNode(_this.container); this.setDOMNode(this.container);
return _this;
} }
/** /**
* Set audio source * Set audio source
* *
* @param {string} _value url * @param {string} _value url
*/ */
et2_audio.prototype.set_src = function (_value) { set_src(_value) {
if (_value) { if (_value) {
this.audio.setAttribute('src', _value); this.audio.setAttribute('src', _value);
if (this.options.src_type) { if (this.options.src_type) {
@ -101,23 +82,24 @@ var et2_audio = /** @class */ (function (_super) {
if (this.options.preload != "none") if (this.options.preload != "none")
this.audio.load(); this.audio.load();
} }
}; }
/** /**
* @return Promise * @return Promise
*/ */
et2_audio.prototype.play = function () { play() {
return this.audio.play(); return this.audio.play();
}; }
et2_audio.prototype.pause = function () { pause() {
this.audio.pause(); this.audio.pause();
}; }
et2_audio.prototype.currentTime = function () { currentTime() {
return this.audio.currentTime; return this.audio.currentTime;
}; }
et2_audio.prototype.seek = function (_time) { seek(_time) {
this.audio.currentTime = _time; this.audio.currentTime = _time;
}; }
et2_audio._attributes = { }
et2_audio._attributes = {
"src": { "src": {
"name": "Audio", "name": "Audio",
"type": "string", "type": "string",
@ -164,9 +146,6 @@ var et2_audio = /** @class */ (function (_super) {
"default": 'auto', "default": 'auto',
"description": "preloads audio source based on given option. none(do not preload), auto(preload), metadata(preload metadata only)." "description": "preloads audio source based on given option. none(do not preload), auto(preload), metadata(preload metadata only)."
} }
}; };
return et2_audio; et2_register_widget(et2_audio, ["audio"]);
}(et2_core_baseWidget_1.et2_baseWidget));
exports.et2_audio = et2_audio;
et2_core_widget_1.et2_register_widget(et2_audio, ["audio"]);
//# sourceMappingURL=et2_widget_audio.js.map //# sourceMappingURL=et2_widget_audio.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh <hn[at]egroupware.org> * @author Hadi Nategh <hn[at]egroupware.org>
* @copyright EGroupware GmbH * @copyright EGroupware GmbH
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -19,6 +18,7 @@
import { et2_baseWidget } from './et2_core_baseWidget' import { et2_baseWidget } from './et2_core_baseWidget'
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {WidgetConfig, et2_register_widget} from "./et2_core_widget"; import {WidgetConfig, et2_register_widget} from "./et2_core_widget";
import {et2_IDOMNode} from "./et2_core_interfaces";
/** /**
* This widget represents the HTML5 Audio tag with all its optional attributes * This widget represents the HTML5 Audio tag with all its optional attributes

View File

@ -1,30 +1,13 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS barcode widget * EGroupware eTemplate2 - JS barcode widget
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh <hn[at]stylite.de> * @author Hadi Nategh <hn[at]stylite.de>
* @copyright Stylite AG * @copyright EGroupware GmbH
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_barcode = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
/api/js/jquery/barcode/jquery-barcode.min.js; /api/js/jquery/barcode/jquery-barcode.min.js;
@ -52,30 +35,27 @@ exports.et2_barcode = void 0;
* *
* Further information about types and formats are defined in static part of the class at the end * Further information about types and formats are defined in static part of the class at the end
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
/** /**
* Class which implements the "barcode" XET-Tag * Class which implements the "barcode" XET-Tag
* *
*/ */
var et2_barcode = /** @class */ (function (_super) { export class et2_barcode extends et2_valueWidget {
__extends(et2_barcode, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_barcode(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_barcode._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_barcode._attributes, _child || {}));
_this.div = jQuery(document.createElement('div')).attr({ class: 'et2_barcode' }); this.div = jQuery(document.createElement('div')).attr({ class: 'et2_barcode' });
// Set domid // Set domid
_this.set_id(_this.id); this.set_id(this.id);
_this.setDOMNode(_this.div[0]); this.setDOMNode(this.div[0]);
_this.createWidget(); this.createWidget();
return _this;
} }
et2_barcode.prototype.createWidget = function () { createWidget() {
this.settings = { this.settings = {
output: this.options.format, output: this.options.format,
bgColor: this.options.bgColor, bgColor: this.options.bgColor,
@ -87,35 +67,36 @@ var et2_barcode = /** @class */ (function (_super) {
// @ts-ignore // @ts-ignore
this.div.barcode(this.get_value(), this.options.code_type, this.settings); this.div.barcode(this.get_value(), this.options.code_type, this.settings);
} }
}; }
et2_barcode.prototype.set_value = function (_val) { set_value(_val) {
if (typeof _val !== 'undefined') { if (typeof _val !== 'undefined') {
this.value = _val; this.value = _val;
this.createWidget(); this.createWidget();
} }
}; }
// Class Constants }
/* // Class Constants
/*
* type const * type const
*/ */
et2_barcode.TYPE_CODEBAR = "codebar"; et2_barcode.TYPE_CODEBAR = "codebar";
et2_barcode.TYPE_CODE11 = "code11"; //(code 11) et2_barcode.TYPE_CODE11 = "code11"; //(code 11)
et2_barcode.TYPE_CODE39 = "code39"; //(code 39) et2_barcode.TYPE_CODE39 = "code39"; //(code 39)
et2_barcode.TYPE_CODE128 = "code128"; //(code 128) et2_barcode.TYPE_CODE128 = "code128"; //(code 128)
et2_barcode.TYPE_EAN8 = "ean8"; //(ean 8) - http://barcode-coder.com/en/ean-8-specification-101.html et2_barcode.TYPE_EAN8 = "ean8"; //(ean 8) - http://barcode-coder.com/en/ean-8-specification-101.html
et2_barcode.TYPE_EAN13 = "ean13"; //(ean 13) - http://barcode-coder.com/en/ean-13-specification-102.html et2_barcode.TYPE_EAN13 = "ean13"; //(ean 13) - http://barcode-coder.com/en/ean-13-specification-102.html
et2_barcode.TYPE_STD25 = "std25"; //(standard 2 of 5 - industrial 2 of 5) - http://barcode-coder.com/en/standard-2-of-5-specification-103.html et2_barcode.TYPE_STD25 = "std25"; //(standard 2 of 5 - industrial 2 of 5) - http://barcode-coder.com/en/standard-2-of-5-specification-103.html
et2_barcode.TYPE_INT25 = "int25"; //(interleaved 2 of 5) et2_barcode.TYPE_INT25 = "int25"; //(interleaved 2 of 5)
et2_barcode.TYPE_MSI = "msi"; et2_barcode.TYPE_MSI = "msi";
et2_barcode.TYPE_DATAMATRIX = "datamatrix"; //(ASCII + extended) - http://barcode-coder.com/en/datamatrix-specification-104.html et2_barcode.TYPE_DATAMATRIX = "datamatrix"; //(ASCII + extended) - http://barcode-coder.com/en/datamatrix-specification-104.html
/** /**
* Formats consts * Formats consts
*/ */
et2_barcode.FORMAT_CSS = "css"; et2_barcode.FORMAT_CSS = "css";
et2_barcode.FORMAT_SVG = "svg"; et2_barcode.FORMAT_SVG = "svg";
et2_barcode.FORMAT_bmp = "bmp"; et2_barcode.FORMAT_bmp = "bmp";
et2_barcode.FORMAT_CANVAS = "canvas"; et2_barcode.FORMAT_CANVAS = "canvas";
et2_barcode._attributes = { et2_barcode._attributes = {
"code_type": { "code_type": {
"name": "code type", "name": "code type",
"type": "string", "type": "string",
@ -152,9 +133,6 @@ var et2_barcode = /** @class */ (function (_super) {
"default": '50', "default": '50',
"description": "Defines heigh of each bar in the barcode." "description": "Defines heigh of each bar in the barcode."
}, },
}; };
return et2_barcode; et2_register_widget(et2_barcode, ["barcode"]);
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_barcode = et2_barcode;
et2_core_widget_1.et2_register_widget(et2_barcode, ["barcode"]);
//# sourceMappingURL=et2_widget_barcode.js.map //# sourceMappingURL=et2_widget_barcode.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh <hn[at]stylite.de> * @author Hadi Nategh <hn[at]stylite.de>
* @copyright Stylite AG * @copyright EGroupware GmbH
* @version $Id:$
*/ */
/*egw:uses /*egw:uses

View File

@ -1,36 +1,20 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Box object * EGroupware eTemplate2 - JS Box object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_details = exports.et2_box = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_baseWidget; et2_core_baseWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_baseWidget_1 = require("./et2_core_baseWidget"); import { et2_baseWidget } from "./et2_core_baseWidget";
import { et2_readAttrWithDefault } from "./et2_core_xml";
/** /**
* Class which implements box and vbox tag * Class which implements box and vbox tag
* *
@ -39,33 +23,31 @@ var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
* *
* @augments et2_baseWidget * @augments et2_baseWidget
*/ */
var et2_box = /** @class */ (function (_super) { export class et2_box extends et2_baseWidget {
__extends(et2_box, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_box * @memberOf et2_box
*/ */
function et2_box(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this = _super.call(this, _parent, _attrs, _child) || this; super(_parent, _attrs, _child);
_this.div = jQuery(document.createElement("div")) this.div = jQuery(document.createElement("div"))
.addClass("et2_" + _this.getType()) .addClass("et2_" + this.getType())
.addClass("et2_box_widget"); .addClass("et2_box_widget");
_this.setDOMNode(_this.div[0]); this.setDOMNode(this.div[0]);
return _this;
} }
et2_box.prototype._createNamespace = function () { _createNamespace() {
return true; return true;
}; }
/** /**
* Overriden so we can check for autorepeating children. We only check for * Overriden so we can check for autorepeating children. We only check for
* $ in the immediate children & grandchildren of this node. * $ in the immediate children & grandchildren of this node.
* *
* @param {object} _node * @param {object} _node
*/ */
et2_box.prototype.loadFromXML = function (_node) { loadFromXML(_node) {
if (this.getType() != "box") { if (this.getType() != "box") {
return _super.prototype.loadFromXML.call(this, _node); return super.loadFromXML(_node);
} }
// Load the child nodes. // Load the child nodes.
var childIndex = 0; var childIndex = 0;
@ -111,7 +93,7 @@ var et2_box = /** @class */ (function (_super) {
this.getArrayMgr(name).setPerspectiveData(currentPerspective); this.getArrayMgr(name).setPerspectiveData(currentPerspective);
} }
} }
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
* This doesn't need to be implemented. * This doesn't need to be implemented.
@ -119,13 +101,13 @@ var et2_box = /** @class */ (function (_super) {
* *
* @param {array} _attrs array to add further attributes to * @param {array} _attrs array to add further attributes to
*/ */
et2_box.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push('data'); _attrs.push('data');
}; }
et2_box.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.getDOMNode()]; return [this.getDOMNode()];
}; }
et2_box.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
if (_values.data) { if (_values.data) {
var pairs = _values.data.split(/,/g); var pairs = _values.data.split(/,/g);
for (var i = 0; i < pairs.length; ++i) { for (var i = 0; i < pairs.length; ++i) {
@ -133,16 +115,14 @@ var et2_box = /** @class */ (function (_super) {
jQuery(_nodes[0]).attr('data-' + name_value[0], name_value[1]); jQuery(_nodes[0]).attr('data-' + name_value[0], name_value[1]);
} }
} }
}; }
et2_box._attributes = { }
et2_box._attributes = {
// Not needed // Not needed
"rows": { "ignore": true }, "rows": { "ignore": true },
"cols": { "ignore": true } "cols": { "ignore": true }
}; };
return et2_box; et2_register_widget(et2_box, ["vbox", "box"]);
}(et2_core_baseWidget_1.et2_baseWidget));
exports.et2_box = et2_box;
et2_core_widget_1.et2_register_widget(et2_box, ["vbox", "box"]);
/** /**
* Details widget implementation * Details widget implementation
* widget name is "details" and can be use as a wrapping container * widget name is "details" and can be use as a wrapping container
@ -156,34 +136,32 @@ et2_core_widget_1.et2_register_widget(et2_box, ["vbox", "box"]);
* <details/> * <details/>
* *
*/ */
var et2_details = /** @class */ (function (_super) { export class et2_details extends et2_box {
__extends(et2_details, _super); constructor(_parent, _attrs, _child) {
function et2_details(_parent, _attrs, _child) { super(_parent, _attrs, _child);
var _this = _super.call(this, _parent, _attrs, _child) || this; this.div = jQuery(document.createElement('div')).addClass('et2_details');
_this.div = jQuery(document.createElement('div')).addClass('et2_details'); this.title = jQuery(document.createElement('span'))
_this.title = jQuery(document.createElement('span'))
.addClass('et2_label et2_details_title') .addClass('et2_label et2_details_title')
.appendTo(_this.div); .appendTo(this.div);
_this.span = jQuery(document.createElement('span')) this.span = jQuery(document.createElement('span'))
.addClass('et2_details_toggle') .addClass('et2_details_toggle')
.appendTo(_this.div); .appendTo(this.div);
_this.wrapper = jQuery(document.createElement('div')) this.wrapper = jQuery(document.createElement('div'))
.addClass('et2_details_wrapper') .addClass('et2_details_wrapper')
.appendTo(_this.div); .appendTo(this.div);
_this._createWidget(); this._createWidget();
return _this;
} }
/** /**
* Function happens on toggle action * Function happens on toggle action
*/ */
et2_details.prototype._toggle = function () { _toggle() {
this.div.toggleClass('et2_details_expanded'); this.div.toggleClass('et2_details_expanded');
}; }
/** /**
* Create widget, set contents, and binds handlers * Create widget, set contents, and binds handlers
*/ */
et2_details.prototype._createWidget = function () { _createWidget() {
var self = this; const self = this;
this.span.on('click', function (e) { this.span.on('click', function (e) {
self._toggle(); self._toggle();
}); });
@ -198,16 +176,17 @@ var et2_details = /** @class */ (function (_super) {
// Align toggle button left/right // Align toggle button left/right
if (this.options.toggle_align === "left") if (this.options.toggle_align === "left")
this.span.css({ float: 'left' }); this.span.css({ float: 'left' });
}; }
et2_details.prototype.getDOMNode = function (_sender) { getDOMNode(_sender) {
if (!_sender || _sender === this) { if (!_sender || _sender === this) {
return this.div[0]; return this.div[0];
} }
else { else {
return this.wrapper[0]; return this.wrapper[0];
} }
}; }
et2_details._attributes = { }
et2_details._attributes = {
"toggle_align": { "toggle_align": {
name: "Toggle button alignment", name: "Toggle button alignment",
description: " Defines where to align the toggle button, default is right alignment", description: " Defines where to align the toggle button, default is right alignment",
@ -221,9 +200,6 @@ var et2_details = /** @class */ (function (_super) {
default: "", default: "",
translate: true translate: true
} }
}; };
return et2_details; et2_register_widget(et2_details, ["details"]);
}(et2_box));
exports.et2_details = et2_details;
et2_core_widget_1.et2_register_widget(et2_details, ["details"]);
//# sourceMappingURL=et2_widget_box.js.map //# sourceMappingURL=et2_widget_box.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -18,6 +17,8 @@
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_baseWidget} from "./et2_core_baseWidget"; import {et2_baseWidget} from "./et2_core_baseWidget";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
import {et2_readAttrWithDefault} from "./et2_core_xml";
/** /**
* Class which implements box and vbox tag * Class which implements box and vbox tag

View File

@ -1,70 +1,51 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Button object * EGroupware eTemplate2 - JS Button object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_button = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_interfaces; et2_core_interfaces;
et2_core_baseWidget; et2_core_baseWidget;
*/ */
require("./et2_core_common"); import { et2_no_init } from "./et2_core_common";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
var et2_core_baseWidget_1 = require("./et2_core_baseWidget"); import { et2_baseWidget } from './et2_core_baseWidget';
/** /**
* Class which implements the "button" XET-Tag * Class which implements the "button" XET-Tag
*/ */
var et2_button = /** @class */ (function (_super) { export class et2_button extends et2_baseWidget {
__extends(et2_button, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_button(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_button._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_button._attributes, _child || {}));
_this.label = ""; this.label = "";
_this.clicked = false; this.clicked = false;
_this.btn = null; this.btn = null;
_this.image = null; this.image = null;
if (!_this.options.background_image && (_this.options.image || _this.options.ro_image)) { if (!this.options.background_image && (this.options.image || this.options.ro_image)) {
_this.image = jQuery(document.createElement("img")) this.image = jQuery(document.createElement("img"))
.addClass("et2_button et2_button_icon"); .addClass("et2_button et2_button_icon");
if (!_this.options.readonly) if (!this.options.readonly)
_this.image.addClass("et2_clickable"); this.image.addClass("et2_clickable");
_this.setDOMNode(_this.image[0]); this.setDOMNode(this.image[0]);
return _this; return;
} }
if (!_this.options.readonly || _this.options.ro_image) { if (!this.options.readonly || this.options.ro_image) {
_this.btn = jQuery(document.createElement("button")) this.btn = jQuery(document.createElement("button"))
.addClass("et2_button") .addClass("et2_button")
.attr({ type: "button" }); .attr({ type: "button" });
_this.setDOMNode(_this.btn[0]); this.setDOMNode(this.btn[0]);
} }
if (_this.options.image) if (this.options.image)
_this.set_image(_this.options.image); this.set_image(this.options.image);
return _this;
} }
/** /**
* Apply the "modifications" to the element and translate attributes marked * Apply the "modifications" to the element and translate attributes marked
@ -74,7 +55,7 @@ var et2_button = /** @class */ (function (_super) {
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_button.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
if (this.id && typeof _attrs.background_image == 'undefined' && !_attrs.image) { if (this.id && typeof _attrs.background_image == 'undefined' && !_attrs.image) {
for (var image in et2_button.default_background_images) { for (var image in et2_button.default_background_images) {
if (this.id.match(et2_button.default_background_images[image])) { if (this.id.match(et2_button.default_background_images[image])) {
@ -90,35 +71,35 @@ var et2_button = /** @class */ (function (_super) {
break; break;
} }
} }
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
}; }
et2_button.prototype.set_accesskey = function (key) { set_accesskey(key) {
jQuery(this.node).attr("accesskey", key); jQuery(this.node).attr("accesskey", key);
}; }
/** /**
* Set image and update current image * Set image and update current image
* *
* @param _image * @param _image
*/ */
et2_button.prototype.set_image = function (_image) { set_image(_image) {
this.options.image = _image; this.options.image = _image;
this.update_image(); this.update_image();
}; }
/** /**
* Set readonly image and update current image * Set readonly image and update current image
* *
* @param _image * @param _image
*/ */
et2_button.prototype.set_ro_image = function (_image) { set_ro_image(_image) {
this.options.ro_image = _image; this.options.ro_image = _image;
this.update_image(); this.update_image();
}; }
/** /**
* Set current image (dont update options.image) * Set current image (dont update options.image)
* *
* @param _image * @param _image
*/ */
et2_button.prototype.update_image = function (_image) { update_image(_image) {
if (!this.isInTree() || !this.options.background_image && this.image == null) if (!this.isInTree() || !this.options.background_image && this.image == null)
return; return;
if (typeof _image == 'undefined') if (typeof _image == 'undefined')
@ -155,13 +136,13 @@ var et2_button = /** @class */ (function (_super) {
this.btn.removeClass('et2_button_with_image'); this.btn.removeClass('et2_button_with_image');
} }
} }
}; }
/** /**
* Set options.readonly and update image * Set options.readonly and update image
* *
* @param {boolean} _ro * @param {boolean} _ro
*/ */
et2_button.prototype.set_readonly = function (_ro) { set_readonly(_ro) {
if (_ro != this.options.readonly) { if (_ro != this.options.readonly) {
this.options.readonly = _ro; this.options.readonly = _ro;
if (this.options.image || this.options.ro_image) { if (this.options.image || this.options.ro_image) {
@ -175,9 +156,9 @@ var et2_button = /** @class */ (function (_super) {
.css('cursor', _ro ? 'default' : 'pointer'); // temp. 'til it is removed from et2_button .css('cursor', _ro ? 'default' : 'pointer'); // temp. 'til it is removed from et2_button
} }
} }
}; }
et2_button.prototype.attachToDOM = function () { attachToDOM() {
var ret = _super.prototype.attachToDOM.call(this); let ret = super.attachToDOM();
if (this.options.readonly && (this.btn || this.image)) { if (this.options.readonly && (this.btn || this.image)) {
(this.btn || this.image) (this.btn || this.image)
.removeClass('et2_clickable') .removeClass('et2_clickable')
@ -185,17 +166,17 @@ var et2_button = /** @class */ (function (_super) {
.css('cursor', 'default'); // temp. 'til it is removed from et2_button .css('cursor', 'default'); // temp. 'til it is removed from et2_button
} }
return ret; return ret;
}; }
et2_button.prototype.getDOMNode = function () { getDOMNode() {
return this.btn ? this.btn[0] : (this.image ? this.image[0] : null); return this.btn ? this.btn[0] : (this.image ? this.image[0] : null);
}; }
/** /**
* Overwritten to maintain an internal clicked attribute * Overwritten to maintain an internal clicked attribute
* *
* @param _ev * @param _ev
* @returns {Boolean} * @returns {Boolean}
*/ */
et2_button.prototype.click = function (_ev) { click(_ev) {
var _a, _b; var _a, _b;
// ignore click on readonly button // ignore click on readonly button
if (this.options.readonly) if (this.options.readonly)
@ -205,7 +186,7 @@ var et2_button = /** @class */ (function (_super) {
if ((_a = this.btn) === null || _a === void 0 ? void 0 : _a.hasClass("et2_button_cancel")) { if ((_a = this.btn) === null || _a === void 0 ? void 0 : _a.hasClass("et2_button_cancel")) {
this.getInstanceManager().skip_close_prompt(); this.getInstanceManager().skip_close_prompt();
} }
if (!_super.prototype.click.apply(this, arguments)) { if (!super.click.apply(this, arguments)) {
this.clicked = false; this.clicked = false;
return false; return false;
} }
@ -216,8 +197,8 @@ var et2_button = /** @class */ (function (_super) {
this.clicked = false; this.clicked = false;
(_b = this.getInstanceManager()) === null || _b === void 0 ? void 0 : _b.skip_close_prompt(false); (_b = this.getInstanceManager()) === null || _b === void 0 ? void 0 : _b.skip_close_prompt(false);
return true; return true;
}; }
et2_button.prototype.set_label = function (_value) { set_label(_value) {
if (this.btn) { if (this.btn) {
this.label = _value; this.label = _value;
this.btn.text(_value); this.btn.text(_value);
@ -233,52 +214,52 @@ var et2_button = /** @class */ (function (_super) {
this.image.attr("title", _value); this.image.attr("title", _value);
} }
} }
}; }
/** /**
* Set tab index * Set tab index
* *
* @param {number} index * @param {number} index
*/ */
et2_button.prototype.set_tabindex = function (index) { set_tabindex(index) {
jQuery(this.btn).attr("tabindex", index); jQuery(this.btn).attr("tabindex", index);
}; }
/** /**
* Implementation of the et2_IInput interface * Implementation of the et2_IInput interface
*/ */
/** /**
* Always return false as a button is never dirty * Always return false as a button is never dirty
*/ */
et2_button.prototype.isDirty = function () { isDirty() {
return false; return false;
}; }
et2_button.prototype.resetDirty = function () { resetDirty() {
}; }
et2_button.prototype.getValue = function () { getValue() {
if (this.clicked) { if (this.clicked) {
return true; return true;
} }
// If "null" is returned, the result is not added to the submitted // If "null" is returned, the result is not added to the submitted
// array. // array.
return null; return null;
}; }
et2_button.prototype.isValid = function () { isValid() {
return true; return true;
}; }
/** /**
* et2_IDetachedDOM * et2_IDetachedDOM
* *
* @param {array} _attrs * @param {array} _attrs
*/ */
et2_button.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("label", "value", "class", "image", "ro_image", "onclick", "background_image"); _attrs.push("label", "value", "class", "image", "ro_image", "onclick", "background_image");
}; }
et2_button.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [ return [
this.btn != null ? this.btn[0] : null, this.btn != null ? this.btn[0] : null,
this.image != null ? this.image[0] : null this.image != null ? this.image[0] : null
]; ];
}; }
et2_button.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
// Datagrid puts in the row for null // Datagrid puts in the row for null
this.btn = _nodes[0].nodeName[0] != '#' ? jQuery(_nodes[0]) : null; this.btn = _nodes[0].nodeName[0] != '#' ? jQuery(_nodes[0]) : null;
this.image = jQuery(_nodes[1]); this.image = jQuery(_nodes[1]);
@ -306,13 +287,14 @@ var et2_button = /** @class */ (function (_super) {
var attrs = jQuery.extend(_values, this.options); var attrs = jQuery.extend(_values, this.options);
var parent = this.getParent(); var parent = this.getParent();
jQuery(this.getDOMNode()).bind("click.et2_baseWidget", this, function (e) { jQuery(this.getDOMNode()).bind("click.et2_baseWidget", this, function (e) {
var widget = et2_core_widget_1.et2_createWidget(type, attrs, parent); var widget = et2_createWidget(type, attrs, parent);
e.data = widget; e.data = widget;
e.data.set_id(_values["id"]); e.data.set_id(_values["id"]);
return e.data.click.call(e.data, e); return e.data.click.call(e.data, e);
}); });
}; }
et2_button._attributes = { }
et2_button._attributes = {
"label": { "label": {
"name": "caption", "name": "caption",
"type": "string", "type": "string",
@ -361,12 +343,12 @@ var et2_button = /** @class */ (function (_super) {
"needed": { "needed": {
"ignore": true "ignore": true
} }
}; };
et2_button.legacyOptions = ["image", "ro_image"]; et2_button.legacyOptions = ["image", "ro_image"];
/** /**
* images to be used as background-image, if none is explicitly applied and id matches given regular expression * images to be used as background-image, if none is explicitly applied and id matches given regular expression
*/ */
et2_button.default_background_images = { et2_button.default_background_images = {
save: /save(&|\]|$)/, save: /save(&|\]|$)/,
apply: /apply(&|\]|$)/, apply: /apply(&|\]|$)/,
cancel: /cancel(&|\]|$)/, cancel: /cancel(&|\]|$)/,
@ -383,17 +365,14 @@ var et2_button = /** @class */ (function (_super) {
ok: /ok(&|\]|$)/, ok: /ok(&|\]|$)/,
close: /close(&|\]|$)/, close: /close(&|\]|$)/,
add: /(add(&|\]|$)|create)/ // customfields use create* add: /(add(&|\]|$)|create)/ // customfields use create*
}; };
/** /**
* Classnames added automatic to buttons to set certain hover background colors * Classnames added automatic to buttons to set certain hover background colors
*/ */
et2_button.default_classes = { et2_button.default_classes = {
et2_button_cancel: /cancel(&|\]|$)/, et2_button_cancel: /cancel(&|\]|$)/,
et2_button_question: /(yes|no)(&|\]|$)/, et2_button_question: /(yes|no)(&|\]|$)/,
et2_button_delete: /delete(&|\]|$)/ // red et2_button_delete: /delete(&|\]|$)/ // red
}; };
return et2_button; et2_register_widget(et2_button, ["button", "buttononly"]);
}(et2_core_baseWidget_1.et2_baseWidget));
exports.et2_button = et2_button;
et2_core_widget_1.et2_register_widget(et2_button, ["button", "buttononly"]);
//# sourceMappingURL=et2_widget_button.js.map //# sourceMappingURL=et2_widget_button.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
@ -14,10 +14,11 @@
et2_core_baseWidget; et2_core_baseWidget;
*/ */
import './et2_core_common'; import {et2_no_init} from "./et2_core_common";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_baseWidget} from './et2_core_baseWidget' import {et2_baseWidget} from './et2_core_baseWidget'
import {et2_IDetachedDOM, et2_IInput} from "./et2_core_interfaces";
/** /**
* Class which implements the "button" XET-Tag * Class which implements the "button" XET-Tag

View File

@ -1,80 +1,60 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Checkbox object * EGroupware eTemplate2 - JS Checkbox object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_checkbox = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_inputWidget; et2_core_inputWidget;
et2_core_valueWidget; et2_core_valueWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
/** /**
* Class which implements the "checkbox" XET-Tag * Class which implements the "checkbox" XET-Tag
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_checkbox = /** @class */ (function (_super) { export class et2_checkbox extends et2_inputWidget {
__extends(et2_checkbox, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_checkbox * @memberOf et2_checkbox
*/ */
function et2_checkbox(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_checkbox._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_checkbox._attributes, _child || {}));
_this.input = null; this.input = null;
_this.toggle = null; this.toggle = null;
_this.input = null; this.input = null;
_this.createInputWidget(); this.createInputWidget();
return _this;
} }
et2_checkbox.prototype.createInputWidget = function () { createInputWidget() {
this.input = jQuery(document.createElement("input")).attr("type", "checkbox"); this.input = jQuery(document.createElement("input")).attr("type", "checkbox");
this.input.addClass("et2_checkbox"); this.input.addClass("et2_checkbox");
if (this.options.toggle_on || this.options.toggle_off) { if (this.options.toggle_on || this.options.toggle_off) {
var self_1 = this; let self = this;
// checkbox container // checkbox container
this.toggle = jQuery(document.createElement('span')) this.toggle = jQuery(document.createElement('span'))
.addClass('et2_checkbox_slideSwitch') .addClass('et2_checkbox_slideSwitch')
.append(this.input); .append(this.input);
// update switch status on change // update switch status on change
this.input.change(function () { this.input.change(function () {
self_1.getValue(); self.getValue();
return true; return true;
}); });
// switch container // switch container
var area = jQuery(document.createElement('span')).addClass('slideSwitch_container').appendTo(this.toggle); let area = jQuery(document.createElement('span')).addClass('slideSwitch_container').appendTo(this.toggle);
// on span tag // on span tag
var on = jQuery(document.createElement('span')).addClass('on').appendTo(area); let on = jQuery(document.createElement('span')).addClass('on').appendTo(area);
// off span tag // off span tag
var off = jQuery(document.createElement('span')).addClass('off').appendTo(area); let off = jQuery(document.createElement('span')).addClass('off').appendTo(area);
on.text(this.options.toggle_on); on.text(this.options.toggle_on);
off.text(this.options.toggle_off); off.text(this.options.toggle_off);
// handle a tag // handle a tag
@ -84,25 +64,25 @@ var et2_checkbox = /** @class */ (function (_super) {
else { else {
this.setDOMNode(this.input[0]); this.setDOMNode(this.input[0]);
} }
}; }
/** /**
* Override default to place checkbox before label, if there is no %s in the label * Override default to place checkbox before label, if there is no %s in the label
* *
* @param {string} label * @param {string} label
*/ */
et2_checkbox.prototype.set_label = function (label) { set_label(label) {
if (label.length && label.indexOf('%s') < 0) { if (label.length && label.indexOf('%s') < 0) {
label = '%s' + label; label = '%s' + label;
} }
_super.prototype.set_label.call(this, label); super.set_label(label);
jQuery(this.getSurroundings().getWidgetSurroundings()).addClass('et2_checkbox_label'); jQuery(this.getSurroundings().getWidgetSurroundings()).addClass('et2_checkbox_label');
}; }
/** /**
* Override default to match against set/unset value * Override default to match against set/unset value
* *
* @param {string|boolean} _value * @param {string|boolean} _value
*/ */
et2_checkbox.prototype.set_value = function (_value) { set_value(_value) {
// in php, our database storage and et2_checkType(): "0" == false // in php, our database storage and et2_checkType(): "0" == false
if (_value === "0" && this.options.selected_value != "0") { if (_value === "0" && this.options.selected_value != "0") {
_value = false; _value = false;
@ -121,20 +101,20 @@ var et2_checkbox = /** @class */ (function (_super) {
this.toggle.removeClass('switchOn'); this.toggle.removeClass('switchOn');
} }
} }
}; }
/** /**
* Disable checkbox on runtime * Disable checkbox on runtime
* *
* @param {boolean} _ro * @param {boolean} _ro
*/ */
et2_checkbox.prototype.set_readonly = function (_ro) { set_readonly(_ro) {
jQuery(this.getDOMNode()).attr('disabled', _ro); jQuery(this.getDOMNode()).attr('disabled', _ro);
this.input.prop('disabled', _ro); this.input.prop('disabled', _ro);
}; }
/** /**
* Override default to return unchecked value * Override default to return unchecked value
*/ */
et2_checkbox.prototype.getValue = function () { getValue() {
if (this.input.prop("checked")) { if (this.input.prop("checked")) {
if (this.options.toggle_on || this.options.toggle_off) if (this.options.toggle_on || this.options.toggle_off)
this.toggle.addClass('switchOn'); this.toggle.addClass('switchOn');
@ -145,9 +125,9 @@ var et2_checkbox = /** @class */ (function (_super) {
this.toggle.removeClass('switchOn'); this.toggle.removeClass('switchOn');
return this.options.unselected_value; return this.options.unselected_value;
} }
}; }
et2_checkbox.prototype.set_disabled = function (_value) { set_disabled(_value) {
var parentNode = jQuery(this.getDOMNode()).parent(); let parentNode = jQuery(this.getDOMNode()).parent();
if (parentNode[0] && parentNode[0].nodeName == "label" && parentNode.hasClass('.et2_checkbox_label')) { if (parentNode[0] && parentNode[0].nodeName == "label" && parentNode.hasClass('.et2_checkbox_label')) {
if (_value) { if (_value) {
parentNode.hide(); parentNode.hide();
@ -156,9 +136,10 @@ var et2_checkbox = /** @class */ (function (_super) {
parentNode.show(); parentNode.show();
} }
} }
_super.prototype.set_disabled.call(this, _value); super.set_disabled(_value);
}; }
et2_checkbox._attributes = { }
et2_checkbox._attributes = {
"selected_value": { "selected_value": {
"name": "Set value", "name": "Set value",
"type": "string", "type": "string",
@ -201,33 +182,27 @@ var et2_checkbox = /** @class */ (function (_super) {
"description": "String caption to show OFF status", "description": "String caption to show OFF status",
"translate": true "translate": true
} }
}; };
et2_checkbox.legacyOptions = ["selected_value", "unselected_value", "ro_true", "ro_false"]; et2_checkbox.legacyOptions = ["selected_value", "unselected_value", "ro_true", "ro_false"];
return et2_checkbox; et2_register_widget(et2_checkbox, ["checkbox"]);
}(et2_core_inputWidget_1.et2_inputWidget));
exports.et2_checkbox = et2_checkbox;
et2_core_widget_1.et2_register_widget(et2_checkbox, ["checkbox"]);
/** /**
* et2_checkbox_ro is the dummy readonly implementation of the checkbox * et2_checkbox_ro is the dummy readonly implementation of the checkbox
* @augments et2_checkbox * @augments et2_checkbox
*/ */
var et2_checkbox_ro = /** @class */ (function (_super) { export class et2_checkbox_ro extends et2_checkbox {
__extends(et2_checkbox_ro, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_checkbox_ro * @memberOf et2_checkbox_ro
*/ */
function et2_checkbox_ro(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_checkbox_ro._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_checkbox_ro._attributes, _child || {}));
_this.span = null; this.span = null;
_this.value = ""; this.value = "";
_this.span = jQuery(document.createElement("span")) this.span = jQuery(document.createElement("span"))
.addClass("et2_checkbox_ro"); .addClass("et2_checkbox_ro");
_this.setDOMNode(_this.span[0]); this.setDOMNode(this.span[0]);
return _this;
} }
/** /**
* note: checkbox is checked if even there is a value but not only if the _value is only "true" * note: checkbox is checked if even there is a value but not only if the _value is only "true"
@ -235,7 +210,7 @@ var et2_checkbox_ro = /** @class */ (function (_super) {
* *
* @param {string|boolean} _value * @param {string|boolean} _value
*/ */
et2_checkbox_ro.prototype.set_value = function (_value) { set_value(_value) {
if (_value == this.options.selected_value || _value && this.options.selected_value == this.attributes["selected_value"]["default"] && if (_value == this.options.selected_value || _value && this.options.selected_value == this.attributes["selected_value"]["default"] &&
_value != this.options.unselected_value) { _value != this.options.unselected_value) {
this.span.text(this.options.ro_true); this.span.text(this.options.ro_true);
@ -244,19 +219,19 @@ var et2_checkbox_ro = /** @class */ (function (_super) {
else { else {
this.span.text(this.options.ro_false); this.span.text(this.options.ro_false);
} }
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
* *
* @param {array} _attrs * @param {array} _attrs
*/ */
et2_checkbox_ro.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value", "class"); _attrs.push("value", "class");
}; }
et2_checkbox_ro.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.span[0]]; return [this.span[0]];
}; }
et2_checkbox_ro.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
// Update the properties // Update the properties
if (typeof _values["value"] != "undefined") { if (typeof _values["value"] != "undefined") {
this.span = jQuery(_nodes[0]); this.span = jQuery(_nodes[0]);
@ -265,16 +240,15 @@ var et2_checkbox_ro = /** @class */ (function (_super) {
if (typeof _values["class"] != "undefined") { if (typeof _values["class"] != "undefined") {
_nodes[0].setAttribute("class", _values["class"]); _nodes[0].setAttribute("class", _values["class"]);
} }
}; }
/** }
/**
* Ignore unset value * Ignore unset value
*/ */
et2_checkbox_ro._attributes = { et2_checkbox_ro._attributes = {
"unselected_value": { "unselected_value": {
"ignore": true "ignore": true
} }
}; };
return et2_checkbox_ro; et2_register_widget(et2_checkbox_ro, ["checkbox_ro"]);
}(et2_checkbox));
et2_core_widget_1.et2_register_widget(et2_checkbox_ro, ["checkbox_ro"]);
//# sourceMappingURL=et2_widget_checkbox.js.map //# sourceMappingURL=et2_widget_checkbox.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 2011
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -19,6 +18,7 @@
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
/** /**
* Class which implements the "checkbox" XET-Tag * Class which implements the "checkbox" XET-Tag
@ -214,7 +214,7 @@ et2_register_widget(et2_checkbox, ["checkbox"]);
* et2_checkbox_ro is the dummy readonly implementation of the checkbox * et2_checkbox_ro is the dummy readonly implementation of the checkbox
* @augments et2_checkbox * @augments et2_checkbox
*/ */
class et2_checkbox_ro extends et2_checkbox implements et2_IDetachedDOM export class et2_checkbox_ro extends et2_checkbox implements et2_IDetachedDOM
{ {
/** /**
* Ignore unset value * Ignore unset value

View File

@ -1,142 +1,115 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Color picker object * EGroupware eTemplate2 - JS Color picker object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_color_ro = exports.et2_color = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_inputWidget; et2_core_inputWidget;
et2_core_valueWidget; et2_core_valueWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
/** /**
* Class which implements the "colorpicker" XET-Tag * Class which implements the "colorpicker" XET-Tag
* *
*/ */
var et2_color = /** @class */ (function (_super) { export class et2_color extends et2_inputWidget {
__extends(et2_color, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_color(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_color._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_color._attributes, _child || {}));
_this.cleared = true; this.cleared = true;
// included via etemplate2.css // included via etemplate2.css
//this.egw().includeCSS("phpgwapi/js/jquery/jpicker/css/jPicker-1.1.6.min.css"); //this.egw().includeCSS("phpgwapi/js/jquery/jpicker/css/jPicker-1.1.6.min.css");
_this.span = jQuery("<span class='et2_color'/>"); this.span = jQuery("<span class='et2_color'/>");
_this.image = jQuery("<img src='" + _this.egw().image("non_loaded_bg") + "'/>") this.image = jQuery("<img src='" + this.egw().image("non_loaded_bg") + "'/>")
.appendTo(_this.span) .appendTo(this.span)
.on("click", function () { .on("click", function () {
this.input.trigger('click'); this.input.trigger('click');
}.bind(_this)); }.bind(this));
_this.input = jQuery("<input type='color'/>").appendTo(_this.span) this.input = jQuery("<input type='color'/>").appendTo(this.span)
.on('change', function () { .on('change', function () {
this.cleared = false; this.cleared = false;
this.image.hide(); this.image.hide();
}.bind(_this)); }.bind(this));
if (!_this.options.readonly && !_this.options.needed) { if (!this.options.readonly && !this.options.needed) {
_this.clear = jQuery("<span class='ui-icon clear'/>") this.clear = jQuery("<span class='ui-icon clear'/>")
.appendTo(_this.span) .appendTo(this.span)
.on("click", function () { .on("click", function () {
this.set_value(''); this.set_value('');
return false; return false;
}.bind(_this)); }.bind(this));
} }
_this.setDOMNode(_this.span[0]); this.setDOMNode(this.span[0]);
return _this;
} }
et2_color.prototype.getValue = function () { getValue() {
var value = this.input.val(); var value = this.input.val();
if (this.cleared || value === '#FFFFFF' || value === '#ffffff') { if (this.cleared || value === '#FFFFFF' || value === '#ffffff') {
return ''; return '';
} }
return value; return value;
}; }
et2_color.prototype.set_value = function (color) { set_value(color) {
if (!color) { if (!color) {
color = ''; color = '';
} }
this.cleared = !color; this.cleared = !color;
this.image.toggle(!color); this.image.toggle(!color);
this.input.val(color); this.input.val(color);
}; }
return et2_color; }
}(et2_core_inputWidget_1.et2_inputWidget)); et2_register_widget(et2_color, ["colorpicker"]);
exports.et2_color = et2_color;
et2_core_widget_1.et2_register_widget(et2_color, ["colorpicker"]);
/** /**
* et2_textbox_ro is the dummy readonly implementation of the textbox. * et2_textbox_ro is the dummy readonly implementation of the textbox.
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_color_ro = /** @class */ (function (_super) { export class et2_color_ro extends et2_valueWidget {
__extends(et2_color_ro, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_color_ro * @memberOf et2_color_ro
*/ */
function et2_color_ro(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, _child || {}) || this; super(_parent, _attrs, _child || {});
_this.value = ""; this.value = "";
_this.$node = jQuery(document.createElement("div")) this.$node = jQuery(document.createElement("div"))
.addClass("et2_color"); .addClass("et2_color");
_this.setDOMNode(_this.$node[0]); this.setDOMNode(this.$node[0]);
return _this;
} }
et2_color_ro.prototype.set_value = function (_value) { set_value(_value) {
this.value = _value; this.value = _value;
if (!_value) if (!_value)
_value = "inherit"; _value = "inherit";
this.$node.css("background-color", _value); this.$node.css("background-color", _value);
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
* *
* @param {array} _attrs array to add further attributes to * @param {array} _attrs array to add further attributes to
*/ */
et2_color_ro.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value"); _attrs.push("value");
}; }
et2_color_ro.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.node]; return [this.node];
}; }
et2_color_ro.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
this.$node = jQuery(_nodes[0]); this.$node = jQuery(_nodes[0]);
if (typeof _values["value"] != 'undefined') { if (typeof _values["value"] != 'undefined') {
this.set_value(_values["value"]); this.set_value(_values["value"]);
} }
}; }
return et2_color_ro; }
}(et2_core_valueWidget_1.et2_valueWidget)); et2_register_widget(et2_color_ro, ["colorpicker_ro"]);
exports.et2_color_ro = et2_color_ro;
et2_core_widget_1.et2_register_widget(et2_color_ro, ["colorpicker_ro"]);
//# sourceMappingURL=et2_widget_color.js.map //# sourceMappingURL=et2_widget_color.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -20,6 +19,7 @@ import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
/** /**
* Class which implements the "colorpicker" XET-Tag * Class which implements the "colorpicker" XET-Tag

View File

@ -1,36 +1,21 @@
"use strict";
/** /**
* EGroupware eTemplate2 - Countdown timer widget * EGroupware eTemplate2 - Countdown timer widget
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh * @author Hadi Nategh
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_countdown = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_baseWidget; et2_core_baseWidget;
*/ */
require("./et2_core_common"); import { et2_no_init } from "./et2_core_common";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
import { egw } from "../jsapi/egw_global";
/** /**
* Class which implements the "countdown" XET-Tag * Class which implements the "countdown" XET-Tag
* *
@ -38,42 +23,39 @@ var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
* *
* The duration has the benefit, that it does not depend on the correct set time and timezone of the browser / computer of the user. * The duration has the benefit, that it does not depend on the correct set time and timezone of the browser / computer of the user.
*/ */
var et2_countdown = /** @class */ (function (_super) { export class et2_countdown extends et2_valueWidget {
__extends(et2_countdown, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_countdown(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_countdown._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_countdown._attributes, _child || {}));
_this.timer = null; this.timer = null;
_this.container = null; this.container = null;
_this.days = null; this.days = null;
_this.hours = null; this.hours = null;
_this.minutes = null; this.minutes = null;
_this.seconds = null; this.seconds = null;
// Build countdown dom container // Build countdown dom container
_this.container = jQuery(document.createElement("div")) this.container = jQuery(document.createElement("div"))
.addClass("et2_countdown"); .addClass("et2_countdown");
_this.days = jQuery(document.createElement("span")) this.days = jQuery(document.createElement("span"))
.addClass("et2_countdown_days").appendTo(_this.container); .addClass("et2_countdown_days").appendTo(this.container);
_this.hours = jQuery(document.createElement("span")) this.hours = jQuery(document.createElement("span"))
.addClass("et2_countdown_hours").appendTo(_this.container); .addClass("et2_countdown_hours").appendTo(this.container);
_this.minutes = jQuery(document.createElement("span")) this.minutes = jQuery(document.createElement("span"))
.addClass("et2_countdown_minutes").appendTo(_this.container); .addClass("et2_countdown_minutes").appendTo(this.container);
_this.seconds = jQuery(document.createElement("span")) this.seconds = jQuery(document.createElement("span"))
.addClass("et2_countdown_seconds").appendTo(_this.container); .addClass("et2_countdown_seconds").appendTo(this.container);
_this.setDOMNode(_this.container[0]); this.setDOMNode(this.container[0]);
return _this;
} }
et2_countdown.prototype.set_value = function (_time) { set_value(_time) {
if (isNaN(_time)) if (isNaN(_time))
return; return;
_super.prototype.set_value.call(this, _time); super.set_value(_time);
this.time = new Date(); this.time = new Date();
this.time.setSeconds(this.time.getSeconds() + parseInt(_time)); this.time.setSeconds(this.time.getSeconds() + parseInt(_time));
var self = this; let self = this;
this.timer = setInterval(function () { this.timer = setInterval(function () {
if (self._updateTimer() <= 0) { if (self._updateTimer() <= 0) {
clearInterval(self.timer); clearInterval(self.timer);
@ -81,16 +63,16 @@ var et2_countdown = /** @class */ (function (_super) {
self.onFinish(); self.onFinish();
} }
}, 1000); }, 1000);
}; }
et2_countdown.prototype._updateTimer = function () { _updateTimer() {
var now = new Date(); let now = new Date();
var distance = this.time.getTime() - now.getTime(); let distance = this.time.getTime() - now.getTime();
if (distance < 0) if (distance < 0)
return 0; return 0;
if (this.options.alarm > 0 && this.options.alarm == distance / 1000 && typeof this.onAlarm == 'function') { if (this.options.alarm > 0 && this.options.alarm == distance / 1000 && typeof this.onAlarm == 'function') {
this.onAlarm(); this.onAlarm();
} }
var values = { let values = {
days: Math.floor(distance / (1000 * 60 * 60 * 24)), days: Math.floor(distance / (1000 * 60 * 60 * 24)),
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
minutes: Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)), minutes: Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)),
@ -114,10 +96,10 @@ var et2_countdown = /** @class */ (function (_super) {
} }
} }
if (this.options.precision) { if (this.options.precision) {
var units = ['days', 'hours', 'minutes', 'seconds']; const units = ['days', 'hours', 'minutes', 'seconds'];
for (var u = 0; u < 4; ++u) { for (let u = 0; u < 4; ++u) {
if (values[units[u]]) { if (values[units[u]]) {
for (var n = u + this.options.precision; n < 4; n++) { for (let n = u + this.options.precision; n < 4; n++) {
this[units[n]].hide(); this[units[n]].hide();
} }
break; break;
@ -128,11 +110,12 @@ var et2_countdown = /** @class */ (function (_super) {
} }
} }
return distance; return distance;
}; }
et2_countdown.prototype._getIndicator = function (_v) { _getIndicator(_v) {
return this.options.format == 's' ? egw.lang(_v).substr(0, 1) : egw.lang(_v); return this.options.format == 's' ? egw.lang(_v).substr(0, 1) : egw.lang(_v);
}; }
et2_countdown._attributes = { }
et2_countdown._attributes = {
format: { format: {
name: "display format", name: "display format",
type: "string", type: "string",
@ -169,9 +152,6 @@ var et2_countdown = /** @class */ (function (_super) {
default: "", default: "",
description: "Defines a callback to gets called at alarm - timer. This only will work if there's an alarm set." description: "Defines a callback to gets called at alarm - timer. This only will work if there's an alarm set."
} }
}; };
return et2_countdown; et2_register_widget(et2_countdown, ["countdown"]);
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_countdown = et2_countdown;
et2_core_widget_1.et2_register_widget(et2_countdown, ["countdown"]);
//# sourceMappingURL=et2_widget_countdown.js.map //# sourceMappingURL=et2_widget_countdown.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Hadi Nategh * @author Hadi Nategh
*/ */
@ -13,12 +13,11 @@
et2_core_baseWidget; et2_core_baseWidget;
*/ */
import './et2_core_common'; import {et2_no_init} from "./et2_core_common";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_date} from "./et2_widget_date";
import {et2_baseWidget} from "./et2_core_baseWidget";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {egw} from "../jsapi/egw_global";
/** /**
* Class which implements the "countdown" XET-Tag * Class which implements the "countdown" XET-Tag

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 2011
*/ */
@ -17,13 +17,16 @@
et2_core_valueWidget; et2_core_valueWidget;
*/ */
import './et2_core_common'; import {et2_csvSplit, et2_no_init} from "./et2_core_common";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget";
import {et2_valueWidget} from './et2_core_valueWidget' import {et2_valueWidget} from './et2_core_valueWidget'
import {et2_inputWidget} from './et2_core_inputWidget' import {et2_inputWidget} from './et2_core_inputWidget'
import {et2_selectbox} from './et2_widget_selectbox' import {et2_selectbox} from './et2_widget_selectbox'
import {et2_DOMWidget} from "./et2_core_DOMWidget"; import {et2_DOMWidget} from "./et2_core_DOMWidget";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
import {egw} from "../jsapi/egw_global";
import {date} from "./lib/date.js";
// lib/date.js: // lib/date.js:
declare function date (format : string, timestamp? : string | number | Date); declare function date (format : string, timestamp? : string | number | Date);

View File

@ -1,84 +1,61 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Description object * EGroupware eTemplate2 - JS Description object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_description = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_baseWidget; et2_core_baseWidget;
expose; expose;
*/ */
require("./et2_core_common"); import { et2_activateLinks, et2_csvSplit, et2_insertLinkText, et2_no_init } from "./et2_core_common";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_baseWidget_1 = require("./et2_core_baseWidget"); import { et2_baseWidget } from './et2_core_baseWidget';
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
import { expose } from "./expose";
import { egw } from "../jsapi/egw_global";
/** /**
* Class which implements the "description" XET-Tag * Class which implements the "description" XET-Tag
*/ */
var et2_description = /** @class */ (function (_super) { export class et2_description extends expose((_a = class et2_description extends et2_baseWidget {
__extends(et2_description, _super);
function et2_description() {
return _super !== null && _super.apply(this, arguments) || this;
}
return et2_description;
}(expose((_a = /** @class */ (function (_super) {
__extends(et2_description, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_description(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_description._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_description._attributes, _child || {}));
_this._labelContainer = null; this._labelContainer = null;
// Create the span/label tag which contains the label text // Create the span/label tag which contains the label text
_this.span = jQuery(document.createElement(_this.options["for"] ? "label" : "span")) this.span = jQuery(document.createElement(this.options["for"] ? "label" : "span"))
.addClass("et2_label"); .addClass("et2_label");
et2_insertLinkText(_this._parseText(_this.options.value), _this.span[0], _this.options.href ? _this.options.extra_link_target : '_blank'); et2_insertLinkText(this._parseText(this.options.value), this.span[0], this.options.href ? this.options.extra_link_target : '_blank');
_this.setDOMNode(_this.span[0]); this.setDOMNode(this.span[0]);
return _this;
} }
et2_description.prototype.transformAttributes = function (_attrs) { transformAttributes(_attrs) {
_super.prototype.transformAttributes.call(this, _attrs); super.transformAttributes(_attrs);
if (this.id) { if (this.id) {
var val = this.getArrayMgr("content").getEntry(this.id); var val = this.getArrayMgr("content").getEntry(this.id);
if (val) { if (val) {
_attrs["value"] = val; _attrs["value"] = val;
} }
} }
}; }
et2_description.prototype.doLoadingFinished = function () { doLoadingFinished() {
_super.prototype.doLoadingFinished.call(this); super.doLoadingFinished();
// Get the real id of the 'for' widget // Get the real id of the 'for' widget
var for_widget = null; var for_widget = null;
var for_id = ""; let for_id = "";
if (this.options["for"] && ((for_widget = this.getParent().getWidgetById(this.options.for)) || if (this.options["for"] && ((for_widget = this.getParent().getWidgetById(this.options.for)) ||
(for_widget = this.getRoot().getWidgetById(this.options.for))) && for_widget && for_widget.id) { (for_widget = this.getRoot().getWidgetById(this.options.for))) && for_widget && for_widget.id) {
if (for_widget.dom_id) { if (for_widget.dom_id) {
for_id = for_widget.dom_id; for_id = for_widget.dom_id;
if (for_widget.instanceOf(et2_core_inputWidget_1.et2_inputWidget) && for_widget.getInputNode() && for_widget.dom_id !== for_widget.getInputNode().id) { if (for_widget.instanceOf(et2_inputWidget) && for_widget.getInputNode() && for_widget.dom_id !== for_widget.getInputNode().id) {
for_id = for_widget.getInputNode().id; for_id = for_widget.getInputNode().id;
} }
this.span.attr("for", for_id); this.span.attr("for", for_id);
@ -89,7 +66,7 @@ var et2_description = /** @class */ (function (_super) {
window.setTimeout(function () { window.setTimeout(function () {
var _a; var _a;
for_id = for_widget.dom_id; for_id = for_widget.dom_id;
if (for_widget.instanceOf(et2_core_inputWidget_1.et2_inputWidget) && for_widget.getInputNode() && for_widget.dom_id !== ((_a = for_widget.getInputNode()) === null || _a === void 0 ? void 0 : _a.id)) { if (for_widget.instanceOf(et2_inputWidget) && for_widget.getInputNode() && for_widget.dom_id !== ((_a = for_widget.getInputNode()) === null || _a === void 0 ? void 0 : _a.id)) {
for_id = for_widget.getInputNode().id; for_id = for_widget.getInputNode().id;
} }
this.span.attr("for", for_id); this.span.attr("for", for_id);
@ -99,8 +76,8 @@ var et2_description = /** @class */ (function (_super) {
} }
} }
return true; return true;
}; }
et2_description.prototype.set_label = function (_value) { set_label(_value) {
// Abort if ther was no change in the label // Abort if ther was no change in the label
if (_value == this.label) { if (_value == this.label) {
return; return;
@ -142,15 +119,15 @@ var et2_description = /** @class */ (function (_super) {
this.getSurroundings().update(); this.getSurroundings().update();
// Copy the given value // Copy the given value
this.label = _value; this.label = _value;
}; }
/** /**
* Function to get media content to feed the expose * Function to get media content to feed the expose
* @param {type} _value * @param {type} _value
* @returns {Array|Array.getMedia.mediaContent} * @returns {Array|Array.getMedia.mediaContent}
*/ */
et2_description.prototype.getMedia = function (_value) { getMedia(_value) {
var base_url = egw.webserverUrl.match(new RegExp(/^\//, 'ig')) ? egw(window).window.location.origin : ''; let base_url = egw.webserverUrl.match(new RegExp(/^\//, 'ig')) ? egw(window).window.location.origin : '';
var mediaContent = []; let mediaContent = [];
if (_value) { if (_value) {
mediaContent = [{ mediaContent = [{
title: this.options.label, title: this.options.label,
@ -162,8 +139,8 @@ var et2_description = /** @class */ (function (_super) {
mediaContent[0]["download_href"] = base_url + _value + '?download'; mediaContent[0]["download_href"] = base_url + _value + '?download';
} }
return mediaContent; return mediaContent;
}; }
et2_description.prototype.set_value = function (_value) { set_value(_value) {
if (!_value) if (!_value)
_value = ""; _value = "";
if (!this.options.no_lang) if (!this.options.no_lang)
@ -192,8 +169,8 @@ var et2_description = /** @class */ (function (_super) {
return false; return false;
}); });
} }
}; }
et2_description.prototype._parseText = function (_value) { _parseText(_value) {
if (this.options.href) { if (this.options.href) {
var href = this.options.href; var href = this.options.href;
if (href.indexOf('/') == -1 && href.split('.').length >= 3 && if (href.indexOf('/') == -1 && href.split('.').length >= 3 &&
@ -215,24 +192,24 @@ var et2_description = /** @class */ (function (_super) {
else { else {
return [_value]; return [_value];
} }
}; }
et2_description.prototype.set_font_style = function (_value) { set_font_style(_value) {
this.font_style = _value; this.font_style = _value;
this.span.toggleClass("et2_bold", _value.indexOf("b") >= 0); this.span.toggleClass("et2_bold", _value.indexOf("b") >= 0);
this.span.toggleClass("et2_italic", _value.indexOf("i") >= 0); this.span.toggleClass("et2_italic", _value.indexOf("i") >= 0);
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
* *
* @param {array} _attrs * @param {array} _attrs
*/ */
et2_description.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value", "class", "href"); _attrs.push("value", "class", "href");
}; }
et2_description.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.span[0]]; return [this.span[0]];
}; }
et2_description.prototype.setDetachedAttributes = function (_nodes, _values, _data) { setDetachedAttributes(_nodes, _values, _data) {
// Update the properties // Update the properties
var updateLink = false; var updateLink = false;
if (typeof _values["href"] != "undefined") { if (typeof _values["href"] != "undefined") {
@ -250,12 +227,12 @@ var et2_description = /** @class */ (function (_super) {
if (this.options.hover_action) { if (this.options.hover_action) {
this._build_hover_action(_data); this._build_hover_action(_data);
} }
}; }
/** /**
* Builds button for hover action * Builds button for hover action
* @param {object} _data * @param {object} _data
*/ */
et2_description.prototype._build_hover_action = function (_data) { _build_hover_action(_data) {
var content = _data && _data.content ? _data.content : undefined; var content = _data && _data.content ? _data.content : undefined;
var widget = this; var widget = this;
this.span.off().on('mouseenter', jQuery.proxy(function (event) { this.span.off().on('mouseenter', jQuery.proxy(function (event) {
@ -265,14 +242,14 @@ var et2_description = /** @class */ (function (_super) {
items: 'span.et2_label', items: 'span.et2_label',
position: { my: "right top", at: "left top", collision: "flipfit" }, position: { my: "right top", at: "left top", collision: "flipfit" },
tooltipClass: "et2_email_popup", tooltipClass: "et2_email_popup",
content: function () { content() {
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="' + widget.egw().lang(widget.options.hover_action_title) + '"><img src="' return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="' + widget.egw().lang(widget.options.hover_action_title) + '"><img src="'
+ egw.image("edit") + '"/></a>') + egw.image("edit") + '"/></a>')
.on('click', function () { .on('click', function () {
widget.options.hover_action.call(self, self.widget, content); widget.options.hover_action.call(self, self.widget, content);
}); });
}, },
close: function (event, ui) { close(event, ui) {
ui.tooltip.hover(function () { ui.tooltip.hover(function () {
jQuery(this).stop(true).fadeTo(400, 1); jQuery(this).stop(true).fadeTo(400, 1);
}, function () { }, function () {
@ -282,9 +259,8 @@ var et2_description = /** @class */ (function (_super) {
}) })
.tooltip("open"); .tooltip("open");
}, { widget: this, span: this.span })); }, { widget: this, span: this.span }));
}; }
return et2_description; },
}(et2_core_baseWidget_1.et2_baseWidget)),
_a._attributes = { _a._attributes = {
"label": { "label": {
"name": "Label", "name": "Label",
@ -370,8 +346,8 @@ var et2_description = /** @class */ (function (_super) {
}, },
_a.legacyOptions = ["font_style", "href", "activate_links", "for", _a.legacyOptions = ["font_style", "href", "activate_links", "for",
"extra_link_target", "extra_link_popup", "statustext"], "extra_link_target", "extra_link_popup", "statustext"],
_a)))); _a)) {
exports.et2_description = et2_description; }
; ;
et2_core_widget_1.et2_register_widget(et2_description, ["description", "label"]); et2_register_widget(et2_description, ["description", "label"]);
//# sourceMappingURL=et2_widget_description.js.map //# sourceMappingURL=et2_widget_description.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
*/ */
@ -14,11 +14,14 @@
expose; expose;
*/ */
import './et2_core_common'; import {et2_activateLinks, et2_csvSplit, et2_insertLinkText, et2_no_init} from "./et2_core_common";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_baseWidget} from './et2_core_baseWidget' import {et2_baseWidget} from './et2_core_baseWidget'
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {expose} from "./expose";
import {et2_IDetachedDOM, et2_IExposable} from "./et2_core_interfaces";
import {egw} from "../jsapi/egw_global";
/** /**
* Class which implements the "description" XET-Tag * Class which implements the "description" XET-Tag

View File

@ -1,38 +1,23 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Dialog Widget class * EGroupware eTemplate2 - JS Dialog Widget class
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dialog = void 0;
/*egw:uses /*egw:uses
et2_core_widget; et2_core_widget;
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
var et2_core_widget_2 = require("./et2_core_widget"); import { et2_widget } from "./et2_core_widget";
var et2_widget_button_1 = require("./et2_widget_button"); import { et2_button } from "./et2_widget_button";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var etemplate2_1 = require("./etemplate2"); import { etemplate2 } from "./etemplate2";
import { egw } from "../jsapi/egw_global";
import { et2_no_init } from "./et2_core_common";
/** /**
* A common dialog widget that makes it easy to imform users or prompt for information. * A common dialog widget that makes it easy to imform users or prompt for information.
* *
@ -106,14 +91,13 @@ var etemplate2_1 = require("./etemplate2");
* @augments et2_widget * @augments et2_widget
* @see http://api.jqueryui.com/dialog/ * @see http://api.jqueryui.com/dialog/
*/ */
var et2_dialog = /** @class */ (function (_super) { export class et2_dialog extends et2_widget {
__extends(et2_dialog, _super); constructor(_parent, _attrs, _child) {
function et2_dialog(_parent, _attrs, _child) { super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_dialog._attributes, _child || {}));
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_dialog._attributes, _child || {})) || this;
/** /**
* Details for dialog type options * Details for dialog type options
*/ */
_this._dialog_types = [ this._dialog_types = [
//PLAIN_MESSAGE: 0 //PLAIN_MESSAGE: 0
"", "",
//INFORMATION_MESSAGE: 1, //INFORMATION_MESSAGE: 1,
@ -125,7 +109,7 @@ var et2_dialog = /** @class */ (function (_super) {
//ERROR_MESSAGE: 4, //ERROR_MESSAGE: 4,
"dialog_error" "dialog_error"
]; ];
_this._buttons = [ this._buttons = [
/* /*
Pre-defined Button combos Pre-defined Button combos
- button ids copied from et2_dialog static, since the constants are not defined yet - button ids copied from et2_dialog static, since the constants are not defined yet
@ -150,32 +134,31 @@ var et2_dialog = /** @class */ (function (_super) {
{ "button_id": 0, "text": 'cancel', id: 'dialog[cancel]', image: 'cancel' } { "button_id": 0, "text": 'cancel', id: 'dialog[cancel]', image: 'cancel' }
] ]
]; ];
_this.div = null; this.div = null;
_this.template = null; this.template = null;
// Define this as null to avoid breaking any hierarchies (eg: destroy()) // Define this as null to avoid breaking any hierarchies (eg: destroy())
if (_this.getParent() != null) if (this.getParent() != null)
_this.getParent().removeChild(_this); this.getParent().removeChild(this);
// Button callbacks need a reference to this // Button callbacks need a reference to this
var self = _this; let self = this;
for (var i = 0; i < _this._buttons.length; i++) { for (let i = 0; i < this._buttons.length; i++) {
for (var j = 0; j < _this._buttons[i].length; j++) { for (let j = 0; j < this._buttons[i].length; j++) {
_this._buttons[i][j].click = (function (id) { this._buttons[i][j].click = (function (id) {
return function (event) { return function (event) {
self.click(event.target, id); self.click(event.target, id);
}; };
})(_this._buttons[i][j].button_id); })(this._buttons[i][j].button_id);
// translate button texts, as translations are not available before // translate button texts, as translations are not available before
_this._buttons[i][j].text = egw.lang(_this._buttons[i][j].text); this._buttons[i][j].text = egw.lang(this._buttons[i][j].text);
} }
} }
_this.div = jQuery(document.createElement("div")); this.div = jQuery(document.createElement("div"));
_this._createDialog(); this._createDialog();
return _this;
} }
/** /**
* Clean up dialog * Clean up dialog
*/ */
et2_dialog.prototype.destroy = function () { destroy() {
if (this.div != null) { if (this.div != null) {
// Un-dialog the dialog // Un-dialog the dialog
this.div.dialog("destroy"); this.div.dialog("destroy");
@ -186,8 +169,8 @@ var et2_dialog = /** @class */ (function (_super) {
this.div = null; this.div = null;
} }
// Call the inherited constructor // Call the inherited constructor
_super.prototype.destroy.call(this); super.destroy();
}; }
/** /**
* Internal callback registered on all standard buttons. * Internal callback registered on all standard buttons.
* The provided callback is called after the dialog is closed. * The provided callback is called after the dialog is closed.
@ -195,60 +178,60 @@ var et2_dialog = /** @class */ (function (_super) {
* @param target DOMNode The clicked button * @param target DOMNode The clicked button
* @param button_id integer The ID of the clicked button * @param button_id integer The ID of the clicked button
*/ */
et2_dialog.prototype.click = function (target, button_id) { click(target, button_id) {
if (this.options.callback) { if (this.options.callback) {
if (this.options.callback.call(this, button_id, this.get_value()) === false) if (this.options.callback.call(this, button_id, this.get_value()) === false)
return; return;
} }
// Triggers destroy too // Triggers destroy too
this.div.dialog("close"); this.div.dialog("close");
}; }
/** /**
* Returns the values of any widgets in the dialog. This does not include * Returns the values of any widgets in the dialog. This does not include
* the buttons, which are only supplied for the callback. * the buttons, which are only supplied for the callback.
*/ */
et2_dialog.prototype.get_value = function () { get_value() {
var value = this.options.value; var value = this.options.value;
if (this.template) { if (this.template) {
value = this.template.getValues(this.template.widgetContainer); value = this.template.getValues(this.template.widgetContainer);
} }
return value; return value;
}; }
/** /**
* Set the displayed prompt message * Set the displayed prompt message
* *
* @param {string} message New message for the dialog * @param {string} message New message for the dialog
*/ */
et2_dialog.prototype.set_message = function (message) { set_message(message) {
this.options.message = message; this.options.message = message;
this.div.empty() this.div.empty()
.append("<img class='dialog_icon' />") .append("<img class='dialog_icon' />")
.append(jQuery('<div/>').text(message)); .append(jQuery('<div/>').text(message));
}; }
/** /**
* Set the dialog type to a pre-defined type * Set the dialog type to a pre-defined type
* *
* @param {integer} type constant from et2_dialog * @param {integer} type constant from et2_dialog
*/ */
et2_dialog.prototype.set_dialog_type = function (type) { set_dialog_type(type) {
if (this.options.dialog_type != type && typeof this._dialog_types[type] == "string") { if (this.options.dialog_type != type && typeof this._dialog_types[type] == "string") {
this.options.dialog_type = type; this.options.dialog_type = type;
} }
this.set_icon(this._dialog_types[type] ? egw.image(this._dialog_types[type]) : ""); this.set_icon(this._dialog_types[type] ? egw.image(this._dialog_types[type]) : "");
}; }
/** /**
* Set the icon for the dialog * Set the icon for the dialog
* *
* @param {string} icon_url * @param {string} icon_url
*/ */
et2_dialog.prototype.set_icon = function (icon_url) { set_icon(icon_url) {
if (icon_url == "") { if (icon_url == "") {
jQuery("img.dialog_icon", this.div).hide(); jQuery("img.dialog_icon", this.div).hide();
} }
else { else {
jQuery("img.dialog_icon", this.div).show().attr("src", icon_url); jQuery("img.dialog_icon", this.div).show().attr("src", icon_url);
} }
}; }
/** /**
* Set the dialog buttons * Set the dialog buttons
* *
@ -256,7 +239,7 @@ var et2_dialog = /** @class */ (function (_super) {
* @see http://api.jqueryui.com/dialog/#option-buttons * @see http://api.jqueryui.com/dialog/#option-buttons
* @param {array} buttons * @param {array} buttons
*/ */
et2_dialog.prototype.set_buttons = function (buttons) { set_buttons(buttons) {
this.options.buttons = buttons; this.options.buttons = buttons;
if (buttons instanceof Array) { if (buttons instanceof Array) {
for (var i = 0; i < buttons.length; i++) { for (var i = 0; i < buttons.length; i++) {
@ -266,16 +249,16 @@ var et2_dialog = /** @class */ (function (_super) {
} }
// set a default background image and css class based on buttons id // set a default background image and css class based on buttons id
if (button.id && typeof button.class == 'undefined') { if (button.id && typeof button.class == 'undefined') {
for (var name in et2_widget_button_1.et2_button.default_classes) { for (var name in et2_button.default_classes) {
if (button.id.match(et2_widget_button_1.et2_button.default_classes[name])) { if (button.id.match(et2_button.default_classes[name])) {
button.class = (typeof button.class == 'undefined' ? '' : button.class + ' ') + name; button.class = (typeof button.class == 'undefined' ? '' : button.class + ' ') + name;
break; break;
} }
} }
} }
if (button.id && typeof button.image == 'undefined' && typeof button.style == 'undefined') { if (button.id && typeof button.image == 'undefined' && typeof button.style == 'undefined') {
for (var name in et2_widget_button_1.et2_button.default_background_images) { for (var name in et2_button.default_background_images) {
if (button.id.match(et2_widget_button_1.et2_button.default_background_images[name])) { if (button.id.match(et2_button.default_background_images[name])) {
button.image = name; button.image = name;
break; break;
} }
@ -296,35 +279,35 @@ var et2_dialog = /** @class */ (function (_super) {
// Focus default button so enter works // Focus default button so enter works
jQuery('.ui-dialog-buttonpane button[default]', this.div.parent()).focus(); jQuery('.ui-dialog-buttonpane button[default]', this.div.parent()).focus();
} }
}; }
/** /**
* Set the dialog title * Set the dialog title
* *
* @param {string} title New title for the dialog * @param {string} title New title for the dialog
*/ */
et2_dialog.prototype.set_title = function (title) { set_title(title) {
this.options.title = title; this.options.title = title;
this.div.dialog("option", "title", title); this.div.dialog("option", "title", title);
}; }
/** /**
* Block interaction with the page behind the dialog * Block interaction with the page behind the dialog
* *
* @param {boolean} modal Block page behind dialog * @param {boolean} modal Block page behind dialog
*/ */
et2_dialog.prototype.set_modal = function (modal) { set_modal(modal) {
this.options.modal = modal; this.options.modal = modal;
this.div.dialog("option", "modal", modal); this.div.dialog("option", "modal", modal);
}; }
/** /**
* Load an etemplate into the dialog * Load an etemplate into the dialog
* *
* @param template String etemplate file name * @param template String etemplate file name
*/ */
et2_dialog.prototype.set_template = function (template) { set_template(template) {
if (this.template && this.options.template != template) { if (this.template && this.options.template != template) {
this.template.clear(); this.template.clear();
} }
this.template = new etemplate2_1.etemplate2(this.div[0], false); this.template = new etemplate2(this.div[0]);
if (template.indexOf('.xet') > 0) { if (template.indexOf('.xet') > 0) {
// File name provided, fetch from server // File name provided, fetch from server
this.template.load("", template, this.options.value || { content: {} }, jQuery.proxy(function () { this.template.load("", template, this.options.value || { content: {} }, jQuery.proxy(function () {
@ -340,8 +323,7 @@ var et2_dialog = /** @class */ (function (_super) {
} }
// Don't let dialog closing destroy the parent session // Don't let dialog closing destroy the parent session
if (this.template.etemplate_exec_id && this.template.app) { if (this.template.etemplate_exec_id && this.template.app) {
for (var _i = 0, _a = etemplate2_1.etemplate2.getByApplication(this.template.app); _i < _a.length; _i++) { for (let et of etemplate2.getByApplication(this.template.app)) {
var et = _a[_i];
if (et !== this.template && et.etemplate_exec_id === this.template.etemplate_exec_id) { if (et !== this.template && et.etemplate_exec_id === this.template.etemplate_exec_id) {
// Found another template using that exec_id, don't destroy when dialog closes. // Found another template using that exec_id, don't destroy when dialog closes.
this.template.unbind_unload(); this.template.unbind_unload();
@ -351,11 +333,11 @@ var et2_dialog = /** @class */ (function (_super) {
} }
// set template-name as id, to allow to style dialogs // set template-name as id, to allow to style dialogs
this.div.children().attr('id', template.replace(/^(.*\/)?([^/]+)(\.xet)?$/, '$2').replace(/\./g, '-')); this.div.children().attr('id', template.replace(/^(.*\/)?([^/]+)(\.xet)?$/, '$2').replace(/\./g, '-'));
}; }
/** /**
* Actually create and display the dialog * Actually create and display the dialog
*/ */
et2_dialog.prototype._createDialog = function () { _createDialog() {
if (this.options.template) { if (this.options.template) {
this.set_template(this.options.template); this.set_template(this.options.template);
} }
@ -364,13 +346,13 @@ var et2_dialog = /** @class */ (function (_super) {
this.set_dialog_type(this.options.dialog_type); this.set_dialog_type(this.options.dialog_type);
} }
this.set_buttons(typeof this.options.buttons == "number" ? this._buttons[this.options.buttons] : this.options.buttons); this.set_buttons(typeof this.options.buttons == "number" ? this._buttons[this.options.buttons] : this.options.buttons);
var position_my, position_at = ''; let position_my, position_at = '';
if (this.options.position) { if (this.options.position) {
var positions = this.options.position.split(','); let positions = this.options.position.split(',');
position_my = positions[0] ? positions[0].trim() : 'center'; position_my = positions[0] ? positions[0].trim() : 'center';
position_at = positions[1] ? positions[1].trim() : position_my; position_at = positions[1] ? positions[1].trim() : position_my;
} }
var options = { let options = {
// Pass the internal object, not the option // Pass the internal object, not the option
buttons: this.options.buttons, buttons: this.options.buttons,
modal: this.options.modal, modal: this.options.modal,
@ -409,24 +391,24 @@ var et2_dialog = /** @class */ (function (_super) {
this.div.dialog(options); this.div.dialog(options);
// Make sure dialog is wide enough for the title // Make sure dialog is wide enough for the title
// Arbitrary numbers that seem to work nicely. // Arbitrary numbers that seem to work nicely.
var title_width = 20 + 10 * this.options.title.length; let title_width = 20 + 10 * this.options.title.length;
if (this.div.width() < title_width && this.options.title.trim()) { if (this.div.width() < title_width && this.options.title.trim()) {
// Auto-sizing chopped the title // Auto-sizing chopped the title
this.div.dialog('option', 'width', title_width); this.div.dialog('option', 'width', title_width);
} }
}; }
/** /**
* Create a parent to inject application specific egw object with loaded translations into et2_dialog * Create a parent to inject application specific egw object with loaded translations into et2_dialog
* *
* @param {string|egw} _egw_or_appname egw object with already loaded translations or application name to load translations for * @param {string|egw} _egw_or_appname egw object with already loaded translations or application name to load translations for
*/ */
et2_dialog._create_parent = function (_egw_or_appname) { static _create_parent(_egw_or_appname) {
if (typeof _egw_or_appname == 'undefined') { if (typeof _egw_or_appname == 'undefined') {
// @ts-ignore // @ts-ignore
_egw_or_appname = egw_appName; _egw_or_appname = egw_appName;
} }
// create a dummy parent with a correct reference to an application specific egw object // create a dummy parent with a correct reference to an application specific egw object
var parent = new et2_core_widget_2.et2_widget(); let parent = new et2_widget();
// if egw object is passed in because called from et2, just use it // if egw object is passed in because called from et2, just use it
if (typeof _egw_or_appname != 'string') { if (typeof _egw_or_appname != 'string') {
parent.setApiInstance(_egw_or_appname); parent.setApiInstance(_egw_or_appname);
@ -437,7 +419,7 @@ var et2_dialog = /** @class */ (function (_super) {
parent.egw().langRequireApp(parent.egw().window, _egw_or_appname); parent.egw().langRequireApp(parent.egw().window, _egw_or_appname);
} }
return parent; return parent;
}; }
/** /**
* Show a confirmation dialog * Show a confirmation dialog
* *
@ -450,10 +432,10 @@ var et2_dialog = /** @class */ (function (_super) {
* @param {string} _icon URL of an icon to display. If not provided, a type-specific icon will be used. * @param {string} _icon URL of an icon to display. If not provided, a type-specific icon will be used.
* @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for * @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for
*/ */
et2_dialog.show_dialog = function (_callback, _message, _title, _value, _buttons, _type, _icon, _egw_or_appname) { static show_dialog(_callback, _message, _title, _value, _buttons, _type, _icon, _egw_or_appname) {
var parent = et2_dialog._create_parent(_egw_or_appname); let parent = et2_dialog._create_parent(_egw_or_appname);
// Just pass them along, widget handles defaults & missing // Just pass them along, widget handles defaults & missing
return et2_core_widget_1.et2_createWidget("dialog", { return et2_createWidget("dialog", {
callback: _callback || function () { callback: _callback || function () {
}, },
message: _message, message: _message,
@ -464,7 +446,7 @@ var et2_dialog = /** @class */ (function (_super) {
value: _value, value: _value,
width: 'auto' width: 'auto'
}, parent); }, parent);
}; }
; ;
/** /**
* Show an alert message with OK button * Show an alert message with OK button
@ -473,9 +455,9 @@ var et2_dialog = /** @class */ (function (_super) {
* @param {string} _title Text in the top bar of the dialog. * @param {string} _title Text in the top bar of the dialog.
* @param {integer} _type One of the message constants. This defines the style of the message. * @param {integer} _type One of the message constants. This defines the style of the message.
*/ */
et2_dialog.alert = function (_message, _title, _type) { static alert(_message, _title, _type) {
var parent = et2_dialog._create_parent(et2_dialog._create_parent().egw()); let parent = et2_dialog._create_parent(et2_dialog._create_parent().egw());
et2_core_widget_1.et2_createWidget("dialog", { et2_createWidget("dialog", {
callback: function () { callback: function () {
}, },
message: _message, message: _message,
@ -483,7 +465,7 @@ var et2_dialog = /** @class */ (function (_super) {
buttons: et2_dialog.BUTTONS_OK, buttons: et2_dialog.BUTTONS_OK,
dialog_type: _type || et2_dialog.INFORMATION_MESSAGE dialog_type: _type || et2_dialog.INFORMATION_MESSAGE
}, parent); }, parent);
}; }
/** /**
* Show a prompt dialog * Show a prompt dialog
* *
@ -494,10 +476,10 @@ var et2_dialog = /** @class */ (function (_super) {
* @param {integer|array} _buttons One of the BUTTONS_ constants defining the set of buttons at the bottom of the box * @param {integer|array} _buttons One of the BUTTONS_ constants defining the set of buttons at the bottom of the box
* @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for * @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for
*/ */
et2_dialog.show_prompt = function (_callback, _message, _title, _value, _buttons, _egw_or_appname) { static show_prompt(_callback, _message, _title, _value, _buttons, _egw_or_appname) {
var callback = _callback; var callback = _callback;
// Just pass them along, widget handles defaults & missing // Just pass them along, widget handles defaults & missing
return et2_core_widget_1.et2_createWidget("dialog", { return et2_createWidget("dialog", {
callback: function (_button_id, _value) { callback: function (_button_id, _value) {
if (typeof callback == "function") { if (typeof callback == "function") {
callback.call(this, _button_id, _value.value); callback.call(this, _button_id, _value.value);
@ -514,7 +496,7 @@ var et2_dialog = /** @class */ (function (_super) {
template: egw.webserverUrl + '/api/templates/default/prompt.xet', template: egw.webserverUrl + '/api/templates/default/prompt.xet',
class: "et2_prompt" class: "et2_prompt"
}, et2_dialog._create_parent(_egw_or_appname)); }, et2_dialog._create_parent(_egw_or_appname));
}; }
/** /**
* Method to build a confirmation dialog only with * Method to build a confirmation dialog only with
* YES OR NO buttons and submit content back to server * YES OR NO buttons and submit content back to server
@ -526,18 +508,18 @@ var et2_dialog = /** @class */ (function (_super) {
* *
* @description submit the form contents including the button that has been pressed * @description submit the form contents including the button that has been pressed
*/ */
et2_dialog.confirm = function (_senders, _dialogMsg, _titleMsg, _postSubmit) { static confirm(_senders, _dialogMsg, _titleMsg, _postSubmit) {
var senders = _senders; var senders = _senders;
var buttonId = _senders.id; var buttonId = _senders.id;
var dialogMsg = (typeof _dialogMsg != "undefined") ? _dialogMsg : ''; var dialogMsg = (typeof _dialogMsg != "undefined") ? _dialogMsg : '';
var titleMsg = (typeof _titleMsg != "undefined") ? _titleMsg : ''; var titleMsg = (typeof _titleMsg != "undefined") ? _titleMsg : '';
var egw = _senders instanceof et2_core_widget_2.et2_widget ? _senders.egw() : et2_dialog._create_parent().egw(); var egw = _senders instanceof et2_widget ? _senders.egw() : et2_dialog._create_parent().egw();
var callbackDialog = function (button_id) { var callbackDialog = function (button_id) {
if (button_id == et2_dialog.YES_BUTTON) { if (button_id == et2_dialog.YES_BUTTON) {
if (_postSubmit) { if (_postSubmit) {
senders.getRoot().getInstanceManager().postSubmit(buttonId); senders.getRoot().getInstanceManager().postSubmit(buttonId);
} }
else if (senders.instanceOf(et2_widget_button_1.et2_button) && senders.getType() !== "buttononly") { else if (senders.instanceOf(et2_button) && senders.getType() !== "buttononly") {
senders.clicked = true; senders.clicked = true;
senders.getInstanceManager().submit(senders, false, senders.options.novalidate); senders.getInstanceManager().submit(senders, false, senders.options.novalidate);
senders.clicked = false; senders.clicked = false;
@ -548,7 +530,7 @@ var et2_dialog = /** @class */ (function (_super) {
} }
}; };
et2_dialog.show_dialog(callbackDialog, egw.lang(dialogMsg), egw.lang(titleMsg), {}, et2_dialog.BUTTONS_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw); et2_dialog.show_dialog(callbackDialog, egw.lang(dialogMsg), egw.lang(titleMsg), {}, et2_dialog.BUTTONS_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw);
}; }
; ;
/** /**
* Show a dialog for a long-running, multi-part task * Show a dialog for a long-running, multi-part task
@ -577,11 +559,11 @@ var et2_dialog = /** @class */ (function (_super) {
* *
* @return {et2_dialog} * @return {et2_dialog}
*/ */
et2_dialog.long_task = function (_callback, _message, _title, _menuaction, _list, _egw_or_appname) { static long_task(_callback, _message, _title, _menuaction, _list, _egw_or_appname) {
var parent = et2_dialog._create_parent(_egw_or_appname); let parent = et2_dialog._create_parent(_egw_or_appname);
var egw = parent.egw(); let egw = parent.egw();
// Special action for cancel // Special action for cancel
var buttons = [ let buttons = [
{ "button_id": et2_dialog.OK_BUTTON, "text": egw.lang('ok'), "default": true, "disabled": true }, { "button_id": et2_dialog.OK_BUTTON, "text": egw.lang('ok'), "default": true, "disabled": true },
{ {
"button_id": et2_dialog.CANCEL_BUTTON, "text": egw.lang('cancel'), click: function () { "button_id": et2_dialog.CANCEL_BUTTON, "text": egw.lang('cancel'), click: function () {
@ -592,7 +574,7 @@ var et2_dialog = /** @class */ (function (_super) {
} }
} }
]; ];
var dialog = et2_core_widget_1.et2_createWidget("dialog", { let dialog = et2_createWidget("dialog", {
template: egw.webserverUrl + '/api/templates/default/long_task.xet', template: egw.webserverUrl + '/api/templates/default/long_task.xet',
value: { value: {
content: { content: {
@ -612,19 +594,19 @@ var et2_dialog = /** @class */ (function (_super) {
}, parent); }, parent);
// OK starts disabled // OK starts disabled
jQuery("button[button_id=" + et2_dialog.OK_BUTTON + "]", dialog.div.parent()).button("disable"); jQuery("button[button_id=" + et2_dialog.OK_BUTTON + "]", dialog.div.parent()).button("disable");
var log = null; let log = null;
var progressbar = null; let progressbar = null;
var cancel = false; let cancel = false;
var totals = { let totals = {
success: 0, success: 0,
skipped: 0, skipped: 0,
failed: 0, failed: 0,
widget: null widget: null
}; };
// Updates progressbar & log, calls next step // Updates progressbar & log, calls next step
var update = function (response) { let update = function (response) {
// context is index // context is index
var index = this || 0; let index = this || 0;
progressbar.set_value(100 * (index / _list.length)); progressbar.set_value(100 * (index / _list.length));
progressbar.set_label(index + ' / ' + _list.length); progressbar.set_label(index + ' / ' + _list.length);
// Display response information // Display response information
@ -635,7 +617,7 @@ var et2_dialog = /** @class */ (function (_super) {
.appendTo(log); .appendTo(log);
totals.failed++; totals.failed++;
// Ask to retry / ignore / abort // Ask to retry / ignore / abort
et2_core_widget_1.et2_createWidget("dialog", { et2_createWidget("dialog", {
callback: function (button) { callback: function (button) {
switch (button) { switch (button) {
case 'dialog[cancel]': case 'dialog[cancel]':
@ -676,7 +658,7 @@ var et2_dialog = /** @class */ (function (_super) {
} }
} }
// Scroll to bottom // Scroll to bottom
var height = log[0].scrollHeight; let height = log[0].scrollHeight;
log.scrollTop(height); log.scrollTop(height);
// Update totals // Update totals
totals.widget.set_value(egw.lang("Total: %1 Successful: %2 Failed: %3 Skipped: %4", _list.length, totals.success, totals.failed, totals.skipped)); totals.widget.set_value(egw.lang("Total: %1 Successful: %2 Failed: %3 Skipped: %4", _list.length, totals.success, totals.failed, totals.skipped));
@ -712,8 +694,9 @@ var et2_dialog = /** @class */ (function (_super) {
}, 0); }, 0);
}); });
return dialog; return dialog;
}; }
et2_dialog._attributes = { }
et2_dialog._attributes = {
callback: { callback: {
name: "Callback", name: "Callback",
type: "js", type: "js",
@ -837,28 +820,25 @@ var et2_dialog = /** @class */ (function (_super) {
description: "Add css classed into dialog container", description: "Add css classed into dialog container",
default: '' default: ''
} }
}; };
/** /**
* Types * Types
* @constant * @constant
*/ */
et2_dialog.PLAIN_MESSAGE = 0; et2_dialog.PLAIN_MESSAGE = 0;
et2_dialog.INFORMATION_MESSAGE = 1; et2_dialog.INFORMATION_MESSAGE = 1;
et2_dialog.QUESTION_MESSAGE = 2; et2_dialog.QUESTION_MESSAGE = 2;
et2_dialog.WARNING_MESSAGE = 3; et2_dialog.WARNING_MESSAGE = 3;
et2_dialog.ERROR_MESSAGE = 4; et2_dialog.ERROR_MESSAGE = 4;
/* Pre-defined Button combos */ /* Pre-defined Button combos */
et2_dialog.BUTTONS_OK = 0; et2_dialog.BUTTONS_OK = 0;
et2_dialog.BUTTONS_OK_CANCEL = 1; et2_dialog.BUTTONS_OK_CANCEL = 1;
et2_dialog.BUTTONS_YES_NO = 2; et2_dialog.BUTTONS_YES_NO = 2;
et2_dialog.BUTTONS_YES_NO_CANCEL = 3; et2_dialog.BUTTONS_YES_NO_CANCEL = 3;
/* Button constants */ /* Button constants */
et2_dialog.CANCEL_BUTTON = 0; et2_dialog.CANCEL_BUTTON = 0;
et2_dialog.OK_BUTTON = 1; et2_dialog.OK_BUTTON = 1;
et2_dialog.YES_BUTTON = 2; et2_dialog.YES_BUTTON = 2;
et2_dialog.NO_BUTTON = 3; et2_dialog.NO_BUTTON = 3;
return et2_dialog; et2_register_widget(et2_dialog, ["dialog"]);
}(et2_core_widget_2.et2_widget));
exports.et2_dialog = et2_dialog;
et2_core_widget_1.et2_register_widget(et2_dialog, ["dialog"]);
//# sourceMappingURL=et2_widget_dialog.js.map //# sourceMappingURL=et2_widget_dialog.js.map

View File

@ -3,10 +3,9 @@
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -18,8 +17,9 @@ import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_wi
import {et2_widget} from "./et2_core_widget"; import {et2_widget} from "./et2_core_widget";
import {et2_button} from "./et2_widget_button"; import {et2_button} from "./et2_widget_button";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_DOMWidget} from "./et2_core_DOMWidget";
import {etemplate2} from "./etemplate2"; import {etemplate2} from "./etemplate2";
import {egw, IegwAppLocal} from "../jsapi/egw_global";
import {et2_no_init} from "./et2_core_common";
/** /**
* A common dialog widget that makes it easy to imform users or prompt for information. * A common dialog widget that makes it easy to imform users or prompt for information.
@ -479,7 +479,7 @@ export class et2_dialog extends et2_widget {
this.template.clear(); this.template.clear();
} }
this.template = new etemplate2(this.div[0], false); this.template = new etemplate2(this.div[0]);
if (template.indexOf('.xet') > 0) { if (template.indexOf('.xet') > 0) {
// File name provided, fetch from server // File name provided, fetch from server
this.template.load("", template, this.options.value || {content: {}}, jQuery.proxy(function () { this.template.load("", template, this.options.value || {content: {}}, jQuery.proxy(function () {
@ -612,11 +612,12 @@ export class et2_dialog extends et2_widget {
* @param {string} _icon URL of an icon to display. If not provided, a type-specific icon will be used. * @param {string} _icon URL of an icon to display. If not provided, a type-specific icon will be used.
* @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for * @param {string|egw} _egw_or_appname egw object with already laoded translations or application name to load translations for
*/ */
static show_dialog(_callback? : Function, _message? : string, _title? : string, _value? : object, _buttons?, _type? : number, _icon? : string, _egw_or_appname? : string | IegwAppLocal) { static show_dialog(_callback? : Function, _message? : string, _title? : string, _value? : object, _buttons?, _type? : number, _icon? : string, _egw_or_appname? : string | IegwAppLocal)
{
let parent = et2_dialog._create_parent(_egw_or_appname); let parent = et2_dialog._create_parent(_egw_or_appname);
// Just pass them along, widget handles defaults & missing // Just pass them along, widget handles defaults & missing
return et2_createWidget("dialog", { return <et2_dialog>et2_createWidget("dialog", {
callback: _callback || function () { callback: _callback || function () {
}, },
message: _message, message: _message,
@ -636,7 +637,8 @@ export class et2_dialog extends et2_widget {
* @param {string} _title Text in the top bar of the dialog. * @param {string} _title Text in the top bar of the dialog.
* @param {integer} _type One of the message constants. This defines the style of the message. * @param {integer} _type One of the message constants. This defines the style of the message.
*/ */
static alert(_message? : string, _title? : string, _type?) { static alert(_message? : string, _title? : string, _type?)
{
let parent = et2_dialog._create_parent(et2_dialog._create_parent().egw()); let parent = et2_dialog._create_parent(et2_dialog._create_parent().egw());
et2_createWidget("dialog", { et2_createWidget("dialog", {
callback: function () { callback: function () {

View File

@ -1,61 +1,41 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Diff object * EGroupware eTemplate2 - JS Diff object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_diff = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
/vendor/bower-asset/diff2html/dist/diff2html.min.js; /vendor/bower-asset/diff2html/dist/diff2html.min.js;
et2_core_valueWidget; et2_core_valueWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
/** /**
* Class that displays the diff between two [text] values * Class that displays the diff between two [text] values
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_diff = /** @class */ (function (_super) { export class et2_diff extends et2_valueWidget {
__extends(et2_diff, _super);
/** /**
* Constructor * Constructor
*/ */
function et2_diff(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_diff._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_diff._attributes, _child || {}));
_this.mini = true; this.mini = true;
// included via etemplate2.css // included via etemplate2.css
//this.egw().includeCSS('../../../vendor/bower-asset/dist/dist2html.css'); //this.egw().includeCSS('../../../vendor/bower-asset/dist/dist2html.css');
_this.div = document.createElement("div"); this.div = document.createElement("div");
jQuery(_this.div).addClass('et2_diff'); jQuery(this.div).addClass('et2_diff');
return _this;
} }
et2_diff.prototype.set_value = function (value) { set_value(value) {
jQuery(this.div).empty(); jQuery(this.div).empty();
if (typeof value == 'string') { if (typeof value == 'string') {
// Diff2Html likes to have files, we don't have them // Diff2Html likes to have files, we don't have them
@ -72,8 +52,8 @@ var et2_diff = /** @class */ (function (_super) {
jQuery(this.div).append(value); jQuery(this.div).append(value);
} }
this.check_mini(); this.check_mini();
}; }
et2_diff.prototype.check_mini = function () { check_mini() {
if (!this.mini) { if (!this.mini) {
return false; return false;
} }
@ -94,13 +74,13 @@ var et2_diff = /** @class */ (function (_super) {
width: 'auto', width: 'auto',
modal: true, modal: true,
buttons: [{ text: self.egw().lang('ok'), click: function () { jQuery(this).dialog("close"); } }], buttons: [{ text: self.egw().lang('ok'), click: function () { jQuery(this).dialog("close"); } }],
open: function () { open() {
if (jQuery(this).parent().height() > jQuery(window).height()) { if (jQuery(this).parent().height() > jQuery(window).height()) {
jQuery(this).height(jQuery(window).height() * 0.7); jQuery(this).height(jQuery(window).height() * 0.7);
} }
jQuery(this).addClass('et2_diff').dialog({ position: "center" }); jQuery(this).addClass('et2_diff').dialog({ position: "center" });
}, },
close: function (event, ui) { close(event, ui) {
// Need to destroy the dialog, etemplate widget needs divs back where they were // Need to destroy the dialog, etemplate widget needs divs back where they were
dialog_div.dialog("destroy"); dialog_div.dialog("destroy");
self.minify(this); self.minify(this);
@ -109,16 +89,16 @@ var et2_diff = /** @class */ (function (_super) {
} }
}); });
}); });
}; }
et2_diff.prototype.set_label = function (_label) { set_label(_label) {
this.options.label = _label; this.options.label = _label;
}; }
/** /**
* Make the diff into a mini-diff * Make the diff into a mini-diff
* *
* @param {DOMNode|String} view * @param {DOMNode|String} view
*/ */
et2_diff.prototype.minify = function (view) { minify(view) {
view = jQuery(view) view = jQuery(view)
.addClass('mini') .addClass('mini')
// Dialog changes these, if resized // Dialog changes these, if resized
@ -127,17 +107,17 @@ var et2_diff = /** @class */ (function (_super) {
jQuery('th', view).hide(); jQuery('th', view).hide();
jQuery('td.equal', view).hide() jQuery('td.equal', view).hide()
.prevAll().hide(); .prevAll().hide();
}; }
/** /**
* Expand mini-diff * Expand mini-diff
* *
* @param {DOMNode|String} view * @param {DOMNode|String} view
*/ */
et2_diff.prototype.un_minify = function (view) { un_minify(view) {
jQuery(view).removeClass('mini').show(); jQuery(view).removeClass('mini').show();
jQuery('th', view).show(); jQuery('th', view).show();
jQuery('td.equal', view).show(); jQuery('td.equal', view).show();
}; }
/** /**
* Code for implementing et2_IDetachedDOM * Code for implementing et2_IDetachedDOM
* Fast-clonable read-only widget that only deals with DOM nodes, not the widget tree * Fast-clonable read-only widget that only deals with DOM nodes, not the widget tree
@ -149,16 +129,16 @@ var et2_diff = /** @class */ (function (_super) {
* *
* @param {object} _attrs * @param {object} _attrs
*/ */
et2_diff.prototype.getDetachedAttributes = function (_attrs) { getDetachedAttributes(_attrs) {
_attrs.push("value", "label"); _attrs.push("value", "label");
}; }
/** /**
* Returns an array of DOM nodes. The (relativly) same DOM-Nodes have to be * Returns an array of DOM nodes. The (relativly) same DOM-Nodes have to be
* passed to the "setDetachedAttributes" function in the same order. * passed to the "setDetachedAttributes" function in the same order.
*/ */
et2_diff.prototype.getDetachedNodes = function () { getDetachedNodes() {
return [this.div]; return [this.div];
}; }
/** /**
* Sets the given associative attribute->value array and applies the * Sets the given associative attribute->value array and applies the
* attributes to the given DOM-Node. * attributes to the given DOM-Node.
@ -169,7 +149,7 @@ var et2_diff = /** @class */ (function (_super) {
* returned by the "getDetachedAttributes" function and sets them to the * returned by the "getDetachedAttributes" function and sets them to the
* given values. * given values.
*/ */
et2_diff.prototype.setDetachedAttributes = function (_nodes, _values) { setDetachedAttributes(_nodes, _values) {
this.div = _nodes[0]; this.div = _nodes[0];
if (typeof _values['label'] != 'undefined') { if (typeof _values['label'] != 'undefined') {
this.set_label(_values['label']); this.set_label(_values['label']);
@ -177,14 +157,12 @@ var et2_diff = /** @class */ (function (_super) {
if (typeof _values['value'] != 'undefined') { if (typeof _values['value'] != 'undefined') {
this.set_value(_values['value']); this.set_value(_values['value']);
} }
}; }
et2_diff._attributes = { }
et2_diff._attributes = {
"value": { "value": {
"type": "any" "type": "any"
} }
}; };
return et2_diff; et2_register_widget(et2_diff, ["diff"]);
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_diff = et2_diff;
et2_core_widget_1.et2_register_widget(et2_diff, ["diff"]);
//# sourceMappingURL=et2_widget_diff.js.map //# sourceMappingURL=et2_widget_diff.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2012 * @copyright Nathan Gray 2012
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -20,6 +19,7 @@
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {et2_IDetachedDOM} from "./et2_core_interfaces";
/** /**
* Class that displays the diff between two [text] values * Class that displays the diff between two [text] values

View File

@ -1,38 +1,23 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Dropdown Button object * EGroupware eTemplate2 - JS Dropdown Button object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
* @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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dropdown_button = void 0;
/*egw:uses /*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
et2_baseWidget; et2_baseWidget;
*/ */
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from './et2_core_inputWidget';
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_no_init } from "./et2_core_common";
import { egw } from "../jsapi/egw_global";
/** /**
* A split button - a button with a dropdown list * A split button - a button with a dropdown list
* *
@ -47,33 +32,32 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_dropdown_button = /** @class */ (function (_super) { export class et2_dropdown_button extends et2_inputWidget {
__extends(et2_dropdown_button, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_dropdown_button * @memberOf et2_dropdown_button
*/ */
function et2_dropdown_button(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_dropdown_button._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_dropdown_button._attributes, _child || {}));
_this.internal_ids = { this.internal_ids = {
div: "", div: "",
button: "", button: "",
menu: "" menu: ""
}; };
_this.div = null; this.div = null;
_this.buttons = null; this.buttons = null;
_this.button = null; this.button = null;
_this.arrow = null; this.arrow = null;
_this.menu = null; this.menu = null;
_this.image = null; this.image = null;
_this.clicked = false; this.clicked = false;
_this.label_updates = true; this.label_updates = true;
_this.value = null; this.value = null;
/** /**
* Default menu, so there is something for the widget browser / editor to show * Default menu, so there is something for the widget browser / editor to show
*/ */
_this.default_menu = '<ul> \ this.default_menu = '<ul> \
<li data-id="opt_1.1"><a href="#">Option-1.1</a></li>\ <li data-id="opt_1.1"><a href="#">Option-1.1</a></li>\
<li data-id="opt_1.2"><a href="#">Option-1.2</a></li>\ <li data-id="opt_1.2"><a href="#">Option-1.2</a></li>\
<li data-id="opt_1.3"><a href="#">Option-1.3</a></li>\ <li data-id="opt_1.3"><a href="#">Option-1.3</a></li>\
@ -82,32 +66,32 @@ var et2_dropdown_button = /** @class */ (function (_super) {
</a></li>\ </a></li>\
<li data-id="opt_1.5"><a href="#">Option-1.5</a></li>\ <li data-id="opt_1.5"><a href="#">Option-1.5</a></li>\
</ul>'; </ul>';
_this.clicked = false; this.clicked = false;
var self = _this; let self = this;
// Create the individual UI elements // Create the individual UI elements
// Menu is a UL // Menu is a UL
_this.menu = jQuery(_this.default_menu).attr("id", _this.internal_ids.menu) this.menu = jQuery(this.default_menu).attr("id", this.internal_ids.menu)
.hide() .hide()
.menu({ .menu({
select: function (event, ui) { select: function (event, ui) {
self.onselect.call(self, event, ui.item); self.onselect.call(self, event, ui.item);
} }
}); });
_this.buttons = jQuery(document.createElement("div")) this.buttons = jQuery(document.createElement("div"))
.addClass("et2_dropdown"); .addClass("et2_dropdown");
// Main "wrapper" div // Main "wrapper" div
_this.div = jQuery(document.createElement("div")) this.div = jQuery(document.createElement("div"))
.attr("id", _this.internal_ids.div) .attr("id", this.internal_ids.div)
.append(_this.buttons) .append(this.buttons)
.append(_this.menu); .append(this.menu);
// Left side - activates click action // Left side - activates click action
_this.button = jQuery(document.createElement("button")) this.button = jQuery(document.createElement("button"))
.attr("id", _this.internal_ids.button) .attr("id", this.internal_ids.button)
.attr("type", "button") .attr("type", "button")
.addClass("ui-widget ui-corner-left").removeClass("ui-corner-all") .addClass("ui-widget ui-corner-left").removeClass("ui-corner-all")
.appendTo(_this.buttons); .appendTo(this.buttons);
// Right side - shows dropdown // Right side - shows dropdown
_this.arrow = jQuery(document.createElement("button")) this.arrow = jQuery(document.createElement("button"))
.addClass("ui-widget ui-corner-right").removeClass("ui-corner-all") .addClass("ui-widget ui-corner-right").removeClass("ui-corner-all")
.attr("type", "button") .attr("type", "button")
.click(function () { .click(function () {
@ -133,17 +117,16 @@ var et2_dropdown_button = /** @class */ (function (_super) {
}) })
// This is the actual down arrow icon // This is the actual down arrow icon
.append("<div class='ui-icon ui-icon-triangle-1-s'/>") .append("<div class='ui-icon ui-icon-triangle-1-s'/>")
.appendTo(_this.buttons); .appendTo(this.buttons);
// Common button UI // Common button UI
_this.buttons.children("button") this.buttons.children("button")
.addClass("ui-state-default") .addClass("ui-state-default")
.hover(function () { jQuery(this).addClass("ui-state-hover"); }, function () { jQuery(this).removeClass("ui-state-hover"); }); .hover(function () { jQuery(this).addClass("ui-state-hover"); }, function () { jQuery(this).removeClass("ui-state-hover"); });
// Icon // Icon
_this.image = jQuery(document.createElement("img")); this.image = jQuery(document.createElement("img"));
_this.setDOMNode(_this.div[0]); this.setDOMNode(this.div[0]);
return _this;
} }
et2_dropdown_button.prototype.destroy = function () { destroy() {
// Destroy widget // Destroy widget
if (this.menu && this.menu.data('ui-menu')) if (this.menu && this.menu.data('ui-menu'))
this.menu.menu("destroy"); this.menu.menu("destroy");
@ -155,9 +138,9 @@ var et2_dropdown_button = /** @class */ (function (_super) {
this.menu = null; this.menu = null;
// Remove // Remove
this.div.empty().remove(); this.div.empty().remove();
}; }
et2_dropdown_button.prototype.set_id = function (_id) { set_id(_id) {
_super.prototype.set_id.call(this, _id); super.set_id(_id);
// Update internal IDs - not really needed since we refer by internal // Update internal IDs - not really needed since we refer by internal
// javascript reference, but good to keep up to date // javascript reference, but good to keep up to date
this.internal_ids = { this.internal_ids = {
@ -165,29 +148,29 @@ var et2_dropdown_button = /** @class */ (function (_super) {
button: this.dom_id, button: this.dom_id,
menu: this.dom_id + "_menu" menu: this.dom_id + "_menu"
}; };
for (var key in this.internal_ids) { for (let key in this.internal_ids) {
if (this[key] == null) if (this[key] == null)
continue; continue;
this[key].attr("id", this.internal_ids[key]); this[key].attr("id", this.internal_ids[key]);
} }
}; }
/** /**
* Set if the button label changes to match the selected option * Set if the button label changes to match the selected option
* *
* @param updates boolean Turn updating on or off * @param updates boolean Turn updating on or off
*/ */
et2_dropdown_button.prototype.set_label_updates = function (updates) { set_label_updates(updates) {
this.label_updates = updates; this.label_updates = updates;
}; }
et2_dropdown_button.prototype.set_accesskey = function (key) { set_accesskey(key) {
jQuery(this.node).attr("accesskey", key); jQuery(this.node).attr("accesskey", key);
}; }
et2_dropdown_button.prototype.set_ro_image = function (_image) { set_ro_image(_image) {
if (this.options.readonly) { if (this.options.readonly) {
this.set_image(_image); this.set_image(_image);
} }
}; }
et2_dropdown_button.prototype.set_image = function (_image) { set_image(_image) {
if (!this.isInTree() || this.image == null) if (!this.isInTree() || this.image == null)
return; return;
if (!_image.trim()) { if (!_image.trim()) {
@ -196,7 +179,7 @@ var et2_dropdown_button = /** @class */ (function (_super) {
else { else {
this.image.show(); this.image.show();
} }
var src = this.egw().image(_image); let src = this.egw().image(_image);
if (src) { if (src) {
this.image.attr("src", src); this.image.attr("src", src);
} }
@ -207,60 +190,60 @@ var et2_dropdown_button = /** @class */ (function (_super) {
else { else {
this.image.hide(); this.image.hide();
} }
}; }
/** /**
* Overwritten to maintain an internal clicked attribute * Overwritten to maintain an internal clicked attribute
* *
* @param _ev * @param _ev
* @returns {Boolean} * @returns {Boolean}
*/ */
et2_dropdown_button.prototype.click = function (_ev) { click(_ev) {
// ignore click on readonly button // ignore click on readonly button
if (this.options.readonly) if (this.options.readonly)
return false; return false;
this.clicked = true; this.clicked = true;
if (!_super.prototype.click.call(this, _ev)) { if (!super.click(_ev)) {
this.clicked = false; this.clicked = false;
return false; return false;
} }
this.clicked = false; this.clicked = false;
return true; return true;
}; }
et2_dropdown_button.prototype.onselect = function (event, selected_node) { onselect(event, selected_node) {
this.set_value(selected_node.attr("data-id")); this.set_value(selected_node.attr("data-id"));
this.change(selected_node); this.change(selected_node);
}; }
et2_dropdown_button.prototype.attachToDOM = function () { attachToDOM() {
var res = _super.prototype.attachToDOM.call(this); let res = super.attachToDOM();
// Move the parent's handler to the button, or we can't tell the difference between the clicks // Move the parent's handler to the button, or we can't tell the difference between the clicks
jQuery(this.node).unbind("click.et2_baseWidget"); jQuery(this.node).unbind("click.et2_baseWidget");
this.button.off().bind("click.et2_baseWidget", this, function (e) { this.button.off().bind("click.et2_baseWidget", this, function (e) {
return e.data.click.call(e.data, this); return e.data.click.call(e.data, this);
}); });
return res; return res;
}; }
et2_dropdown_button.prototype.set_label = function (_value) { set_label(_value) {
if (this.button) { if (this.button) {
this.label = _value; this.label = _value;
this.button.text(_value) this.button.text(_value)
.prepend(this.image); .prepend(this.image);
} }
}; }
/** /**
* Set the options for the dropdown * Set the options for the dropdown
* *
* @param options Object ID => Label pairs * @param options Object ID => Label pairs
*/ */
et2_dropdown_button.prototype.set_select_options = function (options) { set_select_options(options) {
this.menu.first().empty(); this.menu.first().empty();
// Allow more complicated content, if passed // Allow more complicated content, if passed
if (typeof options == "string") { if (typeof options == "string") {
this.menu.append(options); this.menu.append(options);
} }
else { else {
var add_complex_1 = function (node, options) { let add_complex = function (node, options) {
for (var key in options) { for (let key in options) {
var item = void 0; let item;
if (typeof options[key] == "string") { if (typeof options[key] == "string") {
item = jQuery("<li data-id='" + key + "'><a href='#'>" + options[key] + "</a></li>"); item = jQuery("<li data-id='" + key + "'><a href='#'>" + options[key] + "</a></li>");
} }
@ -270,7 +253,7 @@ var et2_dropdown_button = /** @class */ (function (_super) {
// Optgroup // Optgroup
else { else {
item = jQuery("<li><a href='#'>" + key + "</a></li>"); item = jQuery("<li><a href='#'>" + key + "</a></li>");
add_complex_1(node.append("<ul>"), options[key]); add_complex(node.append("<ul>"), options[key]);
} }
node.append(item); node.append(item);
if (item && options[key].icon) { if (item && options[key].icon) {
@ -279,18 +262,18 @@ var et2_dropdown_button = /** @class */ (function (_super) {
} }
} }
}; };
add_complex_1(this.menu.first(), options); add_complex(this.menu.first(), options);
} }
this.menu.menu("refresh"); this.menu.menu("refresh");
}; }
/** /**
* Set tab index * Set tab index
*/ */
et2_dropdown_button.prototype.set_tabindex = function (index) { set_tabindex(index) {
jQuery(this.button).attr("tabindex", index); jQuery(this.button).attr("tabindex", index);
}; }
et2_dropdown_button.prototype.set_value = function (new_value) { set_value(new_value) {
var menu_item = jQuery("[data-id='" + new_value + "']", this.menu); let menu_item = jQuery("[data-id='" + new_value + "']", this.menu);
if (menu_item.length) { if (menu_item.length) {
this.value = new_value; this.value = new_value;
if (this.label_updates) { if (this.label_updates) {
@ -303,16 +286,16 @@ var et2_dropdown_button = /** @class */ (function (_super) {
this.set_label(this.options.label); this.set_label(this.options.label);
} }
} }
}; }
et2_dropdown_button.prototype.getValue = function () { getValue() {
return this.value; return this.value;
}; }
/** /**
* Set options.readonly * Set options.readonly
* *
* @param {boolean} _ro * @param {boolean} _ro
*/ */
et2_dropdown_button.prototype.set_readonly = function (_ro) { set_readonly(_ro) {
if (_ro != this.options.readonly) { if (_ro != this.options.readonly) {
this.options.readonly = _ro; this.options.readonly = _ro;
// don't make readonly dropdown buttons clickable // don't make readonly dropdown buttons clickable
@ -323,8 +306,9 @@ var et2_dropdown_button = /** @class */ (function (_super) {
.css('cursor', _ro ? 'default' : 'pointer'); .css('cursor', _ro ? 'default' : 'pointer');
} }
} }
}; }
et2_dropdown_button.attributes = { }
et2_dropdown_button.attributes = {
"label": { "label": {
"name": "caption", "name": "caption",
"type": "string", "type": "string",
@ -375,9 +359,6 @@ var et2_dropdown_button = /** @class */ (function (_super) {
"required": { "required": {
"ignore": true "ignore": true
} }
}; };
return et2_dropdown_button; et2_register_widget(et2_dropdown_button, ["dropdown_button"]);
}(et2_core_inputWidget_1.et2_inputWidget));
exports.et2_dropdown_button = et2_dropdown_button;
et2_core_widget_1.et2_register_widget(et2_dropdown_button, ["dropdown_button"]);
//# sourceMappingURL=et2_widget_dropdown_button.js.map //# sourceMappingURL=et2_widget_dropdown_button.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -19,6 +18,8 @@
import {et2_inputWidget} from './et2_core_inputWidget'; import {et2_inputWidget} from './et2_core_inputWidget';
import {WidgetConfig, et2_register_widget} from "./et2_core_widget"; import {WidgetConfig, et2_register_widget} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_no_init} from "./et2_core_common";
import {egw} from "../jsapi/egw_global";
/** /**
* A split button - a button with a dropdown list * A split button - a button with a dropdown list

View File

@ -1,28 +1,25 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Dynheight object * EGroupware eTemplate2 - JS Dynheight object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dynheight = void 0;
/*egw:use /*egw:use
/vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery/dist/jquery.js;
et2_core_inheritance; et2_core_inheritance;
*/ */
import { egw } from "../jsapi/egw_global";
/** /**
* Object which resizes an inner node to the maximum extend of an outer node * Object which resizes an inner node to the maximum extend of an outer node
* (without creating a scrollbar) - it achieves that by performing some very * (without creating a scrollbar) - it achieves that by performing some very
* nasty and time consuming calculations. * nasty and time consuming calculations.
*/ */
var et2_dynheight = /** @class */ (function () { export class et2_dynheight {
function et2_dynheight(_outerNode, _innerNode, _minHeight) { constructor(_outerNode, _innerNode, _minHeight) {
this.initialized = false; this.initialized = false;
this.minHeight = 0; this.minHeight = 0;
this.bottomNodes = []; this.bottomNodes = [];
@ -32,11 +29,11 @@ var et2_dynheight = /** @class */ (function () {
this.innerNode = jQuery(_innerNode); this.innerNode = jQuery(_innerNode);
this.minHeight = _minHeight; this.minHeight = _minHeight;
} }
et2_dynheight.prototype.destroy = function () { destroy() {
this.outerNode = null; this.outerNode = null;
this.innerNode = null; this.innerNode = null;
this.bottomNodes = []; this.bottomNodes = [];
}; }
/** /**
* Resizes the inner node. When this is done, the callback function is * Resizes the inner node. When this is done, the callback function is
* called. * called.
@ -44,21 +41,21 @@ var et2_dynheight = /** @class */ (function () {
* @param {function} _callback * @param {function} _callback
* @param {object} _context * @param {object} _context
*/ */
et2_dynheight.prototype.update = function (_callback, _context) { update(_callback, _context) {
// Check whether the inner node is actually visible - if not, don't // Check whether the inner node is actually visible - if not, don't
// trigger the callback function // trigger the callback function
if (this.innerNode.is(":visible")) { if (this.innerNode.is(":visible")) {
// Initialize the height calculation // Initialize the height calculation
this._initialize(); this._initialize();
// Get the outer container height and offset, if available // Get the outer container height and offset, if available
var oh = this.outerNode.height(); const oh = this.outerNode.height();
var ot = this.outerNode.offset() ? this.outerNode.offset().top : 0; const ot = this.outerNode.offset() ? this.outerNode.offset().top : 0;
// Get top and height of the inner node // Get top and height of the inner node
var it = this.innerNode.offset().top; const it = this.innerNode.offset().top;
// Calculate the height of the "bottomNodes" // Calculate the height of the "bottomNodes"
var bminTop = this.bottomNodes.length ? Infinity : 0; let bminTop = this.bottomNodes.length ? Infinity : 0;
var bmaxBot = 0; let bmaxBot = 0;
for (var i = 0; i < this.bottomNodes.length; i++) { for (let i = 0; i < this.bottomNodes.length; i++) {
// Ignore hidden popups // Ignore hidden popups
if (this.bottomNodes[i].find('.action_popup').length) { if (this.bottomNodes[i].find('.action_popup').length) {
egw.debug('warn', "Had to skip a hidden popup - it should be removed", this.bottomNodes[i].find('.action_popup')); egw.debug('warn', "Had to skip a hidden popup - it should be removed", this.bottomNodes[i].find('.action_popup'));
@ -68,9 +65,9 @@ var et2_dynheight = /** @class */ (function () {
if (!this.bottomNodes[i].is(':visible')) if (!this.bottomNodes[i].is(':visible'))
continue; continue;
// Get height, top and bottom and calculate the maximum/minimum // Get height, top and bottom and calculate the maximum/minimum
var bh_1 = this.bottomNodes[i].outerHeight(true); let bh = this.bottomNodes[i].outerHeight(true);
var bt = this.bottomNodes[i].offset().top; let bt = this.bottomNodes[i].offset().top;
var bb = bh_1 + bt; const bb = bh + bt;
if (i == 0 || bminTop > bt) { if (i == 0 || bminTop > bt) {
bminTop = bt; bminTop = bt;
} }
@ -79,15 +76,15 @@ var et2_dynheight = /** @class */ (function () {
} }
} }
// Get the height of the bottom container // Get the height of the bottom container
var bh = Math.max(0, bmaxBot - bminTop); const bh = Math.max(0, bmaxBot - bminTop);
// Calculate the new height of the inner container // Calculate the new height of the inner container
var h = Math.max(this.minHeight, oh + ot - it - bh - const h = Math.max(this.minHeight, oh + ot - it - bh -
this.innerMargin - this.outerMargin); this.innerMargin - this.outerMargin);
this.innerNode.height(h); this.innerNode.height(h);
// Update the width // Update the width
// Some checking to make sure it doesn't overflow the width when user // Some checking to make sure it doesn't overflow the width when user
// resizes the window // resizes the window
var w = this.outerNode.width(); let w = this.outerNode.width();
if (w > jQuery(window).width()) { if (w > jQuery(window).width()) {
// 50px border, totally arbitrary, but we just need to make sure it's inside // 50px border, totally arbitrary, but we just need to make sure it's inside
w = jQuery(window).width() - 50; w = jQuery(window).width() - 50;
@ -100,7 +97,7 @@ var et2_dynheight = /** @class */ (function () {
_callback.call(_context, w, h); _callback.call(_context, w, h);
} }
} }
}; }
/** /**
* Function used internally which collects all DOM-Nodes which are located * Function used internally which collects all DOM-Nodes which are located
* below this element. * below this element.
@ -108,51 +105,49 @@ var et2_dynheight = /** @class */ (function () {
* @param {HTMLElement} _node * @param {HTMLElement} _node
* @param {number} _bottom * @param {number} _bottom
*/ */
et2_dynheight.prototype._collectBottomNodes = function (_node, _bottom) { _collectBottomNodes(_node, _bottom) {
// Calculate the bottom position of the inner node // Calculate the bottom position of the inner node
if (typeof _bottom == "undefined") { if (typeof _bottom == "undefined") {
_bottom = this.innerNode.offset().top + this.innerNode.height(); _bottom = this.innerNode.offset().top + this.innerNode.height();
} }
if (_node) { if (_node) {
// Accumulate the outer margin of the parent elements // Accumulate the outer margin of the parent elements
var node = jQuery(_node); const node = jQuery(_node);
var ooh = node.outerHeight(true); const ooh = node.outerHeight(true);
var oh = node.height(); const oh = node.height();
this.outerMargin += (ooh - oh) / 2; // Divide by 2 as the value contains margin-top and -bottom this.outerMargin += (ooh - oh) / 2; // Divide by 2 as the value contains margin-top and -bottom
// Iterate over the children of the given node and do the same // Iterate over the children of the given node and do the same
// recursively to the parent nodes until the _outerNode or body is // recursively to the parent nodes until the _outerNode or body is
// reached. // reached.
var self_1 = this; const self = this;
jQuery(_node).children().each(function () { jQuery(_node).children().each(function () {
var $this = jQuery(this); const $this = jQuery(this);
var top = $this.offset().top; const top = $this.offset().top;
if (this != self_1.innerNode[0] && top >= _bottom) { if (this != self.innerNode[0] && top >= _bottom) {
self_1.bottomNodes.push($this); self.bottomNodes.push($this);
} }
}); });
if (_node != this.outerNode[0] && _node != jQuery("body")[0]) { if (_node != this.outerNode[0] && _node != jQuery("body")[0]) {
this._collectBottomNodes(_node.parentNode, _bottom); this._collectBottomNodes(_node.parentNode, _bottom);
} }
} }
}; }
/** /**
* Used internally to calculate some information which will not change over * Used internally to calculate some information which will not change over
* the time. * the time.
*/ */
et2_dynheight.prototype._initialize = function () { _initialize() {
if (!this.initialized) { if (!this.initialized) {
// Collect all bottomNodes and calculates the outer margin // Collect all bottomNodes and calculates the outer margin
this.bottomNodes = []; this.bottomNodes = [];
this.outerMargin = 0; this.outerMargin = 0;
this._collectBottomNodes(this.innerNode[0].parentNode); this._collectBottomNodes(this.innerNode[0].parentNode);
// Calculate the inner margin // Calculate the inner margin
var ioh = this.innerNode.outerHeight(true); const ioh = this.innerNode.outerHeight(true);
var ih = this.innerNode.height(); const ih = this.innerNode.height();
this.innerMargin = ioh - ih; this.innerMargin = ioh - ih;
this.initialized = true; this.initialized = true;
} }
}; }
return et2_dynheight; }
}());
exports.et2_dynheight = et2_dynheight;
//# sourceMappingURL=et2_widget_dynheight.js.map //# sourceMappingURL=et2_widget_dynheight.js.map

View File

@ -4,10 +4,9 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Andreas Stöckel * @author Andreas Stöckel
* @copyright Stylite 2011 * @copyright EGroupware GmbH 2011-2021
* @version $Id$
*/ */
/*egw:use /*egw:use
@ -15,6 +14,8 @@
et2_core_inheritance; et2_core_inheritance;
*/ */
import {egw} from "../jsapi/egw_global";
/** /**
* Object which resizes an inner node to the maximum extend of an outer node * Object which resizes an inner node to the maximum extend of an outer node
* (without creating a scrollbar) - it achieves that by performing some very * (without creating a scrollbar) - it achieves that by performing some very

View File

@ -1,32 +1,18 @@
"use strict";
/* /*
* Egroupware etemplate2 JS Entry widget * Egroupware etemplate2 JS Entry widget
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/*egw:uses /*egw:uses
et2_core_valueWidget; et2_core_valueWidget;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); import { et2_valueWidget } from "./et2_core_valueWidget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_no_init } from "./et2_core_common";
/** /**
* A widget to display a value from an entry * A widget to display a value from an entry
* *
@ -41,44 +27,41 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_entry = /** @class */ (function (_super) { export class et2_entry extends et2_valueWidget {
__extends(et2_entry, _super); constructor(_parent, _attrs, _child) {
function et2_entry(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {}));
_this.widget = null; this.widget = null;
// Often the ID conflicts, so check prefix // Often the ID conflicts, so check prefix
if (_attrs.id && _attrs.id.indexOf(et2_entry.prefix) < 0) { if (_attrs.id && _attrs.id.indexOf(et2_entry.prefix) < 0) {
_attrs.id = et2_entry.prefix + _attrs.id; _attrs.id = et2_entry.prefix + _attrs.id;
} }
var value = _attrs.value; let value = _attrs.value;
_this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {}));
// Save value from parsing, but only if set // Save value from parsing, but only if set
if (value) { if (value) {
_this.options.value = value; this.options.value = value;
} }
_this.widget = null; this.widget = null;
_this.setDOMNode(document.createElement('span')); this.setDOMNode(document.createElement('span'));
return _this;
} }
et2_entry.prototype.loadFromXML = function (_node) { loadFromXML(_node) {
// Load the nodes as usual // Load the nodes as usual
_super.prototype.loadFromXML.call(this, _node); super.loadFromXML(_node);
// Do the magic // Do the magic
this.loadField(); this.loadField();
}; }
/** /**
* Initialize widget for entry field * Initialize widget for entry field
*/ */
et2_entry.prototype.loadField = function () { loadField() {
// Create widget of correct type // Create widget of correct type
var attrs = { let attrs = {
id: this.id + (this.options.field ? '[' + this.options.field + ']' : ''), id: this.id + (this.options.field ? '[' + this.options.field + ']' : ''),
type: 'label', type: 'label',
readonly: this.options.readonly readonly: this.options.readonly
}; };
var modifications = this.getArrayMgr("modifications"); let modifications = this.getArrayMgr("modifications");
if (modifications && this.options.field) { if (modifications && this.options.field) {
jQuery.extend(attrs, modifications.getEntry(attrs.id)); jQuery.extend(attrs, modifications.getEntry(attrs.id));
} }
@ -87,7 +70,7 @@ var et2_entry = /** @class */ (function (_super) {
this.egw().debug('log', "Surpressed label on <" + this.getType() + ' label="' + this.options.label + '" id="' + this.id + '"...>'); this.egw().debug('log', "Surpressed label on <" + this.getType() + ' label="' + this.options.label + '" id="' + this.id + '"...>');
this.options.label = ''; this.options.label = '';
} }
var widget = et2_createWidget(attrs.type, attrs, this); let widget = et2_createWidget(attrs.type, attrs, this);
// If value is not set, etemplate takes care of everything // If value is not set, etemplate takes care of everything
// If value was set, find the record explicitly. // If value was set, find the record explicitly.
if (typeof this.options.value == 'string') { if (typeof this.options.value == 'string') {
@ -101,11 +84,11 @@ var et2_entry = /** @class */ (function (_super) {
widget.options.value = widget.options.value == this.options.compare ? 'X' : ''; widget.options.value = widget.options.value == this.options.compare ? 'X' : '';
} }
if (this.options.alternate_fields) { if (this.options.alternate_fields) {
var sum = 0; let sum = 0;
var fields = this.options.alternate_fields.split(':'); let fields = this.options.alternate_fields.split(':');
for (var i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
var negate = (fields[i][0] == "-"); let negate = (fields[i][0] == "-");
var value = this.getArrayMgr('content').getEntry(fields[i].replace('-', '')); let value = this.getArrayMgr('content').getEntry(fields[i].replace('-', ''));
sum += typeof value === 'undefined' ? 0 : (parseFloat(value) * (negate ? -1 : 1)); sum += typeof value === 'undefined' ? 0 : (parseFloat(value) * (negate ? -1 : 1));
if (value && this.options.field !== 'sum') { if (value && this.options.field !== 'sum') {
widget.options.value = value; widget.options.value = value;
@ -118,8 +101,9 @@ var et2_entry = /** @class */ (function (_super) {
widget.options.value = sum; widget.options.value = sum;
} }
} }
}; }
et2_entry._attributes = { }
et2_entry._attributes = {
field: { field: {
'name': 'Fields', 'name': 'Fields',
'description': 'Which entry field to display, or "sum" to add up the alternate_fields', 'description': 'Which entry field to display, or "sum" to add up the alternate_fields',
@ -161,10 +145,8 @@ var et2_entry = /** @class */ (function (_super) {
readonly: { readonly: {
default: true default: true
} }
}; };
et2_entry.legacyOptions = ["field", "compare", "alternate_fields"]; et2_entry.legacyOptions = ["field", "compare", "alternate_fields"];
et2_entry.prefix = '~'; et2_entry.prefix = '~';
return et2_entry; et2_register_widget(et2_entry, ["entry", 'contact-value', 'contact-account', 'contact-template', 'infolog-value', 'tracker-value', 'records-value']);
}(et2_core_valueWidget_1.et2_valueWidget));
et2_core_widget_1.et2_register_widget(et2_entry, ["entry", 'contact-value', 'contact-account', 'contact-template', 'infolog-value', 'tracker-value', 'records-value']);
//# sourceMappingURL=et2_widget_entry.js.map //# sourceMappingURL=et2_widget_entry.js.map

View File

@ -3,7 +3,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
*/ */
@ -12,9 +12,10 @@
et2_core_valueWidget; et2_core_valueWidget;
*/ */
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_valueWidget} from "./et2_core_valueWidget"; import {et2_valueWidget} from "./et2_core_valueWidget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_no_init} from "./et2_core_common";
/** /**
* A widget to display a value from an entry * A widget to display a value from an entry
@ -30,7 +31,7 @@ import {ClassWithAttributes} from "./et2_core_inheritance";
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
class et2_entry extends et2_valueWidget export class et2_entry extends et2_valueWidget
{ {
static readonly _attributes : any = { static readonly _attributes : any = {
field: { field: {

View File

@ -1,36 +1,21 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Favorite widget * EGroupware eTemplate2 - JS Favorite widget
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
*/ */
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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_favorites = void 0;
/*egw:uses /*egw:uses
et2_dropdown_button; et2_dropdown_button;
et2_extension_nextmatch; et2_extension_nextmatch;
*/ */
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_widget_dropdown_button_1 = require("./et2_widget_dropdown_button"); import { et2_dropdown_button } from "./et2_widget_dropdown_button";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
import { app, egw, egw_getFramework } from "../jsapi/egw_global";
/** /**
* Favorites widget, designed for use with a nextmatch widget * Favorites widget, designed for use with a nextmatch widget
* *
@ -58,49 +43,48 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
* *
* @augments et2_dropdown_button * @augments et2_dropdown_button
*/ */
var et2_favorites = /** @class */ (function (_super) { export class et2_favorites extends et2_dropdown_button {
__extends(et2_favorites, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_favorites * @memberOf et2_favorites
*/ */
function et2_favorites(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_favorites._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_favorites._attributes, _child || {}));
// Some convenient variables, used in closures / event handlers // Some convenient variables, used in closures / event handlers
_this.header = null; this.header = null;
_this.nextmatch = null; this.nextmatch = null;
_this.favSortedList = null; this.favSortedList = null;
_this.sidebox_target = null; this.sidebox_target = null;
// If filter was set server side, we need to remember it until nm is created // If filter was set server side, we need to remember it until nm is created
_this.nm_filter = false; this.nm_filter = false;
_this.sidebox_target = jQuery("#" + _this.options.sidebox_target); this.sidebox_target = jQuery("#" + this.options.sidebox_target);
if (_this.sidebox_target.length == 0 && egw_getFramework() != null) { if (this.sidebox_target.length == 0 && egw_getFramework() != null) {
var egw_fw = egw_getFramework(); let egw_fw = egw_getFramework();
_this.sidebox_target = jQuery("#" + _this.options.sidebox_target, egw_fw.sidemenuDiv); this.sidebox_target = jQuery("#" + this.options.sidebox_target, egw_fw.sidemenuDiv);
} }
// Store array of sorted items // Store array of sorted items
_this.favSortedList = ['blank']; this.favSortedList = ['blank'];
var apps = egw().user('apps'); let apps = egw().user('apps');
et2_favorites.is_admin = (typeof apps['admin'] != "undefined"); et2_favorites.is_admin = (typeof apps['admin'] != "undefined");
// Make sure we have an app // Make sure we have an app
if (!_this.options.app) { if (!this.options.app) {
_this.options.app = _this.getInstanceManager().app; this.options.app = this.getInstanceManager().app;
} }
_this.stored_filters = _this.load_favorites(_this.options.app); this.stored_filters = this.load_favorites(this.options.app);
_this.preferred = egw.preference(_this.options.default_pref, _this.options.app); this.preferred = egw.preference(this.options.default_pref, this.options.app);
if (!_this.preferred || typeof _this.stored_filters[_this.preferred] == "undefined") { if (!this.preferred || typeof this.stored_filters[this.preferred] == "undefined") {
_this.preferred = "blank"; this.preferred = "blank";
} }
// It helps to have the ID properly set before we get too far // It helps to have the ID properly set before we get too far
_this.set_id(_this.id); this.set_id(this.id);
_this.init_filters(_this); this.init_filters(this);
_this.menu.addClass("favorites"); this.menu.addClass("favorites");
// Set the default (button) value // Set the default (button) value
_this.set_value(_this.preferred, true); this.set_value(this.preferred, true);
var self = _this; let self = this;
// Add a listener on the radio buttons to set default filter // Add a listener on the radio buttons to set default filter
jQuery(_this.menu).on("click", "input:radio", function (event) { jQuery(this.menu).on("click", "input:radio", function (event) {
// Don't do the menu // Don't do the menu
event.stopImmediatePropagation(); event.stopImmediatePropagation();
// Save as default favorite - used when you click the button // Save as default favorite - used when you click the button
@ -121,14 +105,14 @@ var et2_favorites = /** @class */ (function (_super) {
}); });
}); });
//Sort DomNodes of sidebox fav. menu //Sort DomNodes of sidebox fav. menu
var sideBoxDOMNodeSort = function (_favSList) { let sideBoxDOMNodeSort = function (_favSList) {
var favS = jQuery.isArray(_favSList) ? _favSList.slice(0).reverse() : []; let favS = jQuery.isArray(_favSList) ? _favSList.slice(0).reverse() : [];
for (var i = 0; i < favS.length; i++) { for (let i = 0; i < favS.length; i++) {
self.sidebox_target.children().find('[data-id$="' + favS[i] + '"]').prependTo(self.sidebox_target.children()); self.sidebox_target.children().find('[data-id$="' + favS[i] + '"]').prependTo(self.sidebox_target.children());
} }
}; };
//Add Sortable handler to nm fav. menu //Add Sortable handler to nm fav. menu
jQuery(_this.menu).sortable({ jQuery(this.menu).sortable({
items: 'li:not([data-id$="add"])', items: 'li:not([data-id$="add"])',
placeholder: 'ui-fav-sortable-placeholder', placeholder: 'ui-fav-sortable-placeholder',
delay: 250, delay: 250,
@ -139,7 +123,7 @@ var et2_favorites = /** @class */ (function (_super) {
} }
}); });
// Add a listener on the delete to remove // Add a listener on the delete to remove
_this.menu.on("click", "div.ui-icon-trash", app[self.options.app], function () { this.menu.on("click", "div.ui-icon-trash", app[self.options.app], function () {
// App instance might not be ready yet, so don't bind directly // App instance might not be ready yet, so don't bind directly
app[self.options.app].delete_favorite.apply(this, arguments); app[self.options.app].delete_favorite.apply(this, arguments);
}) })
@ -149,30 +133,29 @@ var et2_favorites = /** @class */ (function (_super) {
.on("mouseleave", "div.ui-icon-trash", function () { jQuery(this).unwrap(); }); .on("mouseleave", "div.ui-icon-trash", function () { jQuery(this).unwrap(); });
// Trigger refresh of menu options now that events are registered // Trigger refresh of menu options now that events are registered
// to update sidebox // to update sidebox
if (_this.sidebox_target.length > 0) { if (this.sidebox_target.length > 0) {
_this.init_filters(_this); this.init_filters(this);
} }
return _this;
} }
/** /**
* Load favorites from preferences * Load favorites from preferences
* *
* @param app String Load favorites from this application * @param app String Load favorites from this application
*/ */
et2_favorites.prototype.load_favorites = function (app) { load_favorites(app) {
// Default blank filter // Default blank filter
var stored_filters = { let stored_filters = {
'blank': { 'blank': {
name: this.egw().lang("No filters"), name: this.egw().lang("No filters"),
state: {} state: {}
} }
}; };
// Load saved favorites // Load saved favorites
var preferences = egw.preference("*", app); let preferences = egw.preference("*", app);
for (var pref_name in preferences) { for (let pref_name in preferences) {
if (pref_name.indexOf(et2_favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object') { if (pref_name.indexOf(et2_favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object') {
var name_1 = pref_name.substr(et2_favorites.PREFIX.length); let name = pref_name.substr(et2_favorites.PREFIX.length);
stored_filters[name_1] = preferences[pref_name]; stored_filters[name] = preferences[pref_name];
// Keep older favorites working - they used to store nm filters in 'filters',not state // Keep older favorites working - they used to store nm filters in 'filters',not state
if (preferences[pref_name]["filters"]) { if (preferences[pref_name]["filters"]) {
stored_filters[pref_name]["state"] = preferences[pref_name]["filters"]; stored_filters[pref_name]["state"] = preferences[pref_name]["filters"];
@ -189,15 +172,15 @@ var et2_favorites = /** @class */ (function (_super) {
stored_filters = {}; stored_filters = {};
} }
else { else {
for (var name_2 in stored_filters) { for (let name in stored_filters) {
if (this.favSortedList.indexOf(name_2) < 0) { if (this.favSortedList.indexOf(name) < 0) {
this.favSortedList.push(name_2); this.favSortedList.push(name);
} }
} }
this.egw().set_preference(this.options.app, 'fav_sort_pref', this.favSortedList); this.egw().set_preference(this.options.app, 'fav_sort_pref', this.favSortedList);
if (this.favSortedList.length > 0) { if (this.favSortedList.length > 0) {
var sortedListObj = {}; let sortedListObj = {};
for (var i = 0; i < this.favSortedList.length; i++) { for (let i = 0; i < this.favSortedList.length; i++) {
if (typeof stored_filters[this.favSortedList[i]] != 'undefined') { if (typeof stored_filters[this.favSortedList[i]] != 'undefined') {
sortedListObj[this.favSortedList[i]] = stored_filters[this.favSortedList[i]]; sortedListObj[this.favSortedList[i]] = stored_filters[this.favSortedList[i]];
} }
@ -210,18 +193,18 @@ var et2_favorites = /** @class */ (function (_super) {
} }
} }
return stored_filters; return stored_filters;
}; }
// Create & set filter options for dropdown menu // Create & set filter options for dropdown menu
et2_favorites.prototype.init_filters = function (widget, filters) { init_filters(widget, filters) {
if (typeof filters == "undefined") { if (typeof filters == "undefined") {
filters = this.stored_filters; filters = this.stored_filters;
} }
var options = {}; let options = {};
for (var name_3 in filters) { for (let name in filters) {
options[name_3] = "<input type='radio' name='" + this.internal_ids.menu + "[button][favorite]' value='" + name_3 + "' title='" + options[name] = "<input type='radio' name='" + this.internal_ids.menu + "[button][favorite]' value='" + name + "' title='" +
this.egw().lang('Set as default') + "'/>" + this.egw().lang('Set as default') + "'/>" +
(filters[name_3].name != undefined ? filters[name_3].name : name_3) + (filters[name].name != undefined ? filters[name].name : name) +
(filters[name_3].group != false && !et2_favorites.is_admin || name_3 == 'blank' ? "" : (filters[name].group != false && !et2_favorites.is_admin || name == 'blank' ? "" :
"<div class='ui-icon ui-icon-trash' title='" + this.egw().lang('Delete') + "'/>"); "<div class='ui-icon ui-icon-trash' title='" + this.egw().lang('Delete') + "'/>");
} }
// Only add 'Add current' if we have a nextmatch // Only add 'Add current' if we have a nextmatch
@ -231,16 +214,16 @@ var et2_favorites = /** @class */ (function (_super) {
widget.set_select_options.call(widget, options); widget.set_select_options.call(widget, options);
// Set radio to current value // Set radio to current value
jQuery("input[value='" + this.preferred + "']:radio", this.menu).attr("checked", 1); jQuery("input[value='" + this.preferred + "']:radio", this.menu).attr("checked", 1);
}; }
et2_favorites.prototype.set_nm_filters = function (filters) { set_nm_filters(filters) {
if (this.nextmatch) { if (this.nextmatch) {
this.nextmatch.applyFilters(filters); this.nextmatch.applyFilters(filters);
} }
else { else {
console.log(filters); console.log(filters);
} }
}; }
et2_favorites.prototype.onclick = function (node) { onclick(node) {
// Apply preferred filter - make sure it's an object, and not a reference // Apply preferred filter - make sure it's an object, and not a reference
if (this.preferred && this.stored_filters[this.preferred]) { if (this.preferred && this.stored_filters[this.preferred]) {
// use app[appname].setState if available to allow app to overwrite it (eg. change to non-listview in calendar) // use app[appname].setState if available to allow app to overwrite it (eg. change to non-listview in calendar)
@ -254,15 +237,15 @@ var et2_favorites = /** @class */ (function (_super) {
else { else {
alert(this.egw().lang("No default set")); alert(this.egw().lang("No default set"));
} }
}; }
// Apply the favorite when you pick from the list // Apply the favorite when you pick from the list
et2_favorites.prototype.change = function (selected_node) { change(selected_node) {
this.value = jQuery(selected_node).attr("data-id"); this.value = jQuery(selected_node).attr("data-id");
if (this.value == "add" && this.nextmatch) { if (this.value == "add" && this.nextmatch) {
// Get current filters // Get current filters
var current_filters = jQuery.extend({}, this.nextmatch.activeFilters); let current_filters = jQuery.extend({}, this.nextmatch.activeFilters);
// Add in extras // Add in extras
for (var extra in this.options.filters) { for (let extra in this.options.filters) {
// Don't overwrite what nm has, chances are nm has more up-to-date value // Don't overwrite what nm has, chances are nm has more up-to-date value
if (typeof current_filters == 'undefined') { if (typeof current_filters == 'undefined') {
current_filters[extra] = this.nextmatch.options.settings[extra]; current_filters[extra] = this.nextmatch.options.settings[extra];
@ -272,7 +255,7 @@ var et2_favorites = /** @class */ (function (_super) {
delete current_filters.selcolumns; delete current_filters.selcolumns;
// Add in application's settings // Add in application's settings
if (this.filters != true) { if (this.filters != true) {
for (var i = 0; i < this.filters.length; i++) { for (let i = 0; i < this.filters.length; i++) {
current_filters[this.options.filters[i]] = this.nextmatch.options.settings[this.options.filters[i]]; current_filters[this.options.filters[i]] = this.nextmatch.options.settings[this.options.filters[i]];
} }
} }
@ -285,26 +268,26 @@ var et2_favorites = /** @class */ (function (_super) {
// Reset filters when select no filters // Reset filters when select no filters
this.set_nm_filters({}); this.set_nm_filters({});
} }
}; }
et2_favorites.prototype.set_value = function (filter_name, parent) { set_value(filter_name, parent) {
if (parent) { if (parent) {
return _super.prototype.set_value.call(this, filter_name); return super.set_value(filter_name);
} }
if (filter_name == 'add') if (filter_name == 'add')
return false; return false;
app[this.options.app].setState(this.stored_filters[filter_name]); app[this.options.app].setState(this.stored_filters[filter_name]);
return false; return false;
}; }
et2_favorites.prototype.getValue = function () { getValue() {
return null; return null;
}; }
/** /**
* Set the nextmatch to filter * Set the nextmatch to filter
* From et2_INextmatchHeader interface * From et2_INextmatchHeader interface
* *
* @param {et2_nextmatch} nextmatch * @param {et2_nextmatch} nextmatch
*/ */
et2_favorites.prototype.setNextmatch = function (nextmatch) { setNextmatch(nextmatch) {
this.nextmatch = nextmatch; this.nextmatch = nextmatch;
if (this.nm_filter) { if (this.nm_filter) {
this.set_value(this.nm_filter); this.set_value(this.nm_filter);
@ -312,8 +295,9 @@ var et2_favorites = /** @class */ (function (_super) {
} }
// Re-generate filter list so we can add 'Add current' // Re-generate filter list so we can add 'Add current'
this.init_filters(this); this.init_filters(this);
}; }
et2_favorites._attributes = { }
et2_favorites._attributes = {
"default_pref": { "default_pref": {
"name": "Default preference key", "name": "Default preference key",
"type": "string", "type": "string",
@ -341,10 +325,7 @@ var et2_favorites = /** @class */ (function (_super) {
label_updates: { "default": false }, label_updates: { "default": false },
image: { "default": egw().image('fav_filter') }, image: { "default": egw().image('fav_filter') },
statustext: { "default": "Favorite queries", "type": "string" } statustext: { "default": "Favorite queries", "type": "string" }
}; };
et2_favorites.PREFIX = "favorite_"; et2_favorites.PREFIX = "favorite_";
return et2_favorites; et2_register_widget(et2_favorites, ["favorites"]);
}(et2_widget_dropdown_button_1.et2_dropdown_button));
exports.et2_favorites = et2_favorites;
et2_core_widget_1.et2_register_widget(et2_favorites, ["favorites"]);
//# sourceMappingURL=et2_widget_favorites.js.map //# sourceMappingURL=et2_widget_favorites.js.map

View File

@ -4,7 +4,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2013 * @copyright Nathan Gray 2013
*/ */
@ -18,6 +18,7 @@ import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_INextmatchHeader} from "./et2_extension_nextmatch"; import {et2_INextmatchHeader} from "./et2_extension_nextmatch";
import {et2_dropdown_button} from "./et2_widget_dropdown_button"; import {et2_dropdown_button} from "./et2_widget_dropdown_button";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {app, egw, egw_getFramework} from "../jsapi/egw_global";
/** /**
* Favorites widget, designed for use with a nextmatch widget * Favorites widget, designed for use with a nextmatch widget

View File

@ -1,103 +1,86 @@
"use strict";
/** /**
* EGroupware eTemplate2 - JS Number object * EGroupware eTemplate2 - JS Number object
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 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);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_file = void 0;
/*egw:uses /*egw:uses
et2_core_inputWidget; et2_core_inputWidget;
phpgwapi.Resumable.resumable; api.Resumable.resumable;
*/ */
var et2_core_inputWidget_1 = require("./et2_core_inputWidget"); import { et2_inputWidget } from "./et2_core_inputWidget";
var et2_core_widget_1 = require("./et2_core_widget"); import { et2_register_widget } from "./et2_core_widget";
var et2_core_inheritance_1 = require("./et2_core_inheritance"); import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_no_init } from "./et2_core_common";
import { et2_vfsSize } from "./et2_widget_vfs";
import "../Resumable/resumable.js";
/** /**
* Class which implements file upload * Class which implements file upload
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_file = /** @class */ (function (_super) { export class et2_file extends et2_inputWidget {
__extends(et2_file, _super);
/** /**
* Constructor * Constructor
* *
* @memberOf et2_file * @memberOf et2_file
*/ */
function et2_file(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_file._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_file._attributes, _child || {}));
_this.asyncOptions = {}; this.asyncOptions = {};
_this.input = null; this.input = null;
_this.progress = null; this.progress = null;
_this.span = null; this.span = null;
_this.node = null; this.node = null;
_this.input = null; this.input = null;
_this.progress = null; this.progress = null;
_this.span = null; this.span = null;
// Contains all submit buttons need to be disabled during upload process // Contains all submit buttons need to be disabled during upload process
_this.disabled_buttons = jQuery("input[type='submit'], button"); this.disabled_buttons = jQuery("input[type='submit'], button");
// Make sure it's an object, not an array, or values get lost when sent to server // Make sure it's an object, not an array, or values get lost when sent to server
_this.options.value = jQuery.extend({}, _this.options.value); this.options.value = jQuery.extend({}, this.options.value);
if (!_this.options.id) { if (!this.options.id) {
console.warn("File widget needs an ID. Used 'file_widget'."); console.warn("File widget needs an ID. Used 'file_widget'.");
_this.options.id = "file_widget"; this.options.id = "file_widget";
} }
// Legacy - id ending in [] means multiple // Legacy - id ending in [] means multiple
if (_this.options.id.substr(-2) == "[]") { if (this.options.id.substr(-2) == "[]") {
_this.options.multiple = true; this.options.multiple = true;
} }
// If ID ends in /, it's a directory - allow multiple // If ID ends in /, it's a directory - allow multiple
else if (_this.options.id.substr(-1) === "/") { else if (this.options.id.substr(-1) === "/") {
_this.options.multiple = true; this.options.multiple = true;
_attrs.multiple = true; _attrs.multiple = true;
} }
// Set up the URL to have the request ID & the widget ID // Set up the URL to have the request ID & the widget ID
var instance = _this.getInstanceManager(); var instance = this.getInstanceManager();
var self = _this; let self = this;
_this.asyncOptions = jQuery.extend({}, _this.getAsyncOptions(_this)); this.asyncOptions = jQuery.extend({}, this.getAsyncOptions(this));
_this.asyncOptions.fieldName = _this.options.id; this.asyncOptions.fieldName = this.options.id;
_this.createInputWidget(); this.createInputWidget();
_this.set_readonly(_this.options.readonly); this.set_readonly(this.options.readonly);
return _this;
} }
et2_file.prototype.destroy = function () { destroy() {
_super.prototype.destroy.call(this); super.destroy();
this.set_drop_target(null); this.set_drop_target(null);
this.node = null; this.node = null;
this.input = null; this.input = null;
this.span = null; this.span = null;
this.progress = null; this.progress = null;
}; }
et2_file.prototype.createInputWidget = function () { createInputWidget() {
this.node = jQuery(document.createElement("div")).addClass("et2_file"); this.node = jQuery(document.createElement("div")).addClass("et2_file");
this.span = jQuery(document.createElement("span")) this.span = jQuery(document.createElement("span"))
.addClass('et2_file_span et2_button') .addClass('et2_file_span et2_button')
.appendTo(this.node); .appendTo(this.node);
if (this.options.label != '') if (this.options.label != '')
this.span.addClass('et2_button_text'); this.span.addClass('et2_button_text');
var span = this.span; let span = this.span;
this.input = jQuery(document.createElement("input")) this.input = jQuery(document.createElement("input"))
.attr("type", "file").attr("placeholder", this.options.blur) .attr("type", "file").attr("placeholder", this.options.blur)
.addClass("et2_file_upload") .addClass("et2_file_upload")
@ -116,7 +99,7 @@ var et2_file = /** @class */ (function (_super) {
}); });
if (this.options.accept) if (this.options.accept)
this.input.attr('accept', this.options.accept); this.input.attr('accept', this.options.accept);
var self = this; let self = this;
// trigger native input upload file // trigger native input upload file
if (!this.options.readonly) if (!this.options.readonly)
this.span.click(function () { self.input.click(); }); this.span.click(function () { self.input.click(); });
@ -133,7 +116,7 @@ var et2_file = /** @class */ (function (_super) {
// This may be a problem submitting via ajax // This may be a problem submitting via ajax
} }
if (this.options.progress) { if (this.options.progress) {
var widget = this.getRoot().getWidgetById(this.options.progress); let widget = this.getRoot().getWidgetById(this.options.progress);
if (widget) { if (widget) {
//may be not available at createInputWidget time //may be not available at createInputWidget time
this.progress = jQuery(widget.getDOMNode()); this.progress = jQuery(widget.getDOMNode());
@ -150,11 +133,11 @@ var et2_file = /** @class */ (function (_super) {
// set drop target to widget dom node if no target option is specified // set drop target to widget dom node if no target option is specified
if (!this.options.drop_target) if (!this.options.drop_target)
this.resumable.assignDrop([this.getDOMNode()]); this.resumable.assignDrop([this.getDOMNode()]);
}; }
/** /**
* Get any specific async upload options * Get any specific async upload options
*/ */
et2_file.prototype.getAsyncOptions = function (self) { getAsyncOptions(self) {
return { return {
// Callbacks // Callbacks
onStart: function (event, file_count) { onStart: function (event, file_count) {
@ -175,43 +158,43 @@ var et2_file = /** @class */ (function (_super) {
// Disable checking for already uploaded chunks // Disable checking for already uploaded chunks
testChunks: false testChunks: false
}; };
}; }
/** /**
* Set a widget or DOM node as a HTML5 file drop target * Set a widget or DOM node as a HTML5 file drop target
* *
* @param {string} new_target widget ID or DOM node ID to be used as a new target * @param {string} new_target widget ID or DOM node ID to be used as a new target
*/ */
et2_file.prototype.set_drop_target = function (new_target) { set_drop_target(new_target) {
// Cancel old drop target // Cancel old drop target
if (this.options.drop_target) { if (this.options.drop_target) {
var widget_1 = this.getRoot().getWidgetById(this.options.drop_target); let widget = this.getRoot().getWidgetById(this.options.drop_target);
var drop_target_1 = widget_1 && widget_1.getDOMNode() || document.getElementById(this.options.drop_target); let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
if (drop_target_1) { if (drop_target) {
this.resumable.unAssignDrop(drop_target_1); this.resumable.unAssignDrop(drop_target);
} }
} }
this.options.drop_target = new_target; this.options.drop_target = new_target;
if (!this.options.drop_target) if (!this.options.drop_target)
return; return;
// Set up new drop target // Set up new drop target
var widget = this.getRoot().getWidgetById(this.options.drop_target); let widget = this.getRoot().getWidgetById(this.options.drop_target);
var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
if (drop_target) { if (drop_target) {
this.resumable.assignDrop([drop_target]); this.resumable.assignDrop([drop_target]);
} }
else { else {
this.egw().debug("warn", "Did not find file drop target %s", this.options.drop_target); this.egw().debug("warn", "Did not find file drop target %s", this.options.drop_target);
} }
}; }
et2_file.prototype.attachToDOM = function () { attachToDOM() {
var res = _super.prototype.attachToDOM.call(this); let res = super.attachToDOM();
// Override parent's change, file widget will fire change when finished uploading // Override parent's change, file widget will fire change when finished uploading
this.input.unbind("change.et2_inputWidget"); this.input.unbind("change.et2_inputWidget");
return res; return res;
}; }
et2_file.prototype.getValue = function () { getValue() {
return this.options.value ? this.options.value : this.input.val(); return this.options.value ? this.options.value : this.input.val();
}; }
/** /**
* Set the value of the file widget. * Set the value of the file widget.
* *
@ -221,7 +204,7 @@ var et2_file = /** @class */ (function (_super) {
* @param {Event} event Most browsers require the user to initiate file transfers in some way. * @param {Event} event Most browsers require the user to initiate file transfers in some way.
* Pass the event in, if you have it. * Pass the event in, if you have it.
*/ */
et2_file.prototype.set_value = function (value, event) { set_value(value, event) {
if (!value || typeof value == "undefined") { if (!value || typeof value == "undefined") {
value = {}; value = {};
} }
@ -234,7 +217,7 @@ var et2_file = /** @class */ (function (_super) {
this.input.unwrap(); this.input.unwrap();
return; return;
} }
var addFile = jQuery.proxy(function (i, file) { let addFile = jQuery.proxy(function (i, file) {
this.resumable.addFile(file, event); this.resumable.addFile(file, event);
}, this); }, this);
if (typeof value == 'object' && value.length && typeof value[0] == 'object' && value[0].name) { if (typeof value == 'object' && value.length && typeof value[0] == 'object' && value[0].name) {
@ -248,24 +231,24 @@ var et2_file = /** @class */ (function (_super) {
jQuery.each(value, addFile); jQuery.each(value, addFile);
} }
} }
}; }
/** /**
* Set the value for label * Set the value for label
* The label is used as caption for span tag which customize the HTML file upload styling * The label is used as caption for span tag which customize the HTML file upload styling
* *
* @param {string} value text value of label * @param {string} value text value of label
*/ */
et2_file.prototype.set_label = function (value) { set_label(value) {
if (this.span != null && value != null) { if (this.span != null && value != null) {
this.span.text(value); this.span.text(value);
} }
}; }
et2_file.prototype.getInputNode = function () { getInputNode() {
if (typeof this.input == 'undefined') if (typeof this.input == 'undefined')
return false; return false;
return this.input[0]; return this.input[0];
}; }
et2_file.prototype.set_mime = function (mime) { set_mime(mime) {
if (!mime) { if (!mime) {
this.options.mime = null; this.options.mime = null;
} }
@ -276,24 +259,24 @@ var et2_file = /** @class */ (function (_super) {
else { else {
this.options.mime = mime; this.options.mime = mime;
} }
}; }
et2_file.prototype.set_multiple = function (_multiple) { set_multiple(_multiple) {
this.options.multiple = _multiple; this.options.multiple = _multiple;
if (_multiple) { if (_multiple) {
return this.input.attr("multiple", "multiple"); return this.input.attr("multiple", "multiple");
} }
return this.input.removeAttr("multiple"); return this.input.removeAttr("multiple");
}; }
/** /**
* Check to see if the provided file's mimetype matches * Check to see if the provided file's mimetype matches
* *
* @param f File object * @param f File object
* @return boolean * @return boolean
*/ */
et2_file.prototype.checkMime = function (f) { checkMime(f) {
if (!this.options.mime) if (!this.options.mime)
return true; return true;
var mime = ''; let mime = '';
if (this.options.mime.indexOf("/") != 0) { if (this.options.mime.indexOf("/") != 0) {
// Lower case it now, if it's not a regex // Lower case it now, if it's not a regex
mime = this.options.mime.toLowerCase(); mime = this.options.mime.toLowerCase();
@ -312,8 +295,8 @@ var et2_file = /** @class */ (function (_super) {
} }
// Not right mime // Not right mime
return false; return false;
}; }
et2_file.prototype._fileAdded = function (file, event) { _fileAdded(file, event) {
// Manual additions have no event // Manual additions have no event
if (typeof event == 'undefined') { if (typeof event == 'undefined') {
event = {}; event = {};
@ -341,21 +324,21 @@ var et2_file = /** @class */ (function (_super) {
// Wrong mime type - show in the list of files // Wrong mime type - show in the list of files
return this.createStatus(this.egw().lang("File is of wrong type (%1 != %2)!", file.file.type, this.options.mime), file); return this.createStatus(this.egw().lang("File is of wrong type (%1 != %2)!", file.file.type, this.options.mime), file);
} }
}; }
/** /**
* Add in the request id * Add in the request id
*/ */
et2_file.prototype.beforeSend = function (form) { beforeSend(form) {
var instance = this.getInstanceManager(); var instance = this.getInstanceManager();
return { return {
request_id: instance.etemplate_exec_id, request_id: instance.etemplate_exec_id,
widget_id: this.id widget_id: this.id
}; };
}; }
/** /**
* Disables submit buttons while uploading * Disables submit buttons while uploading
*/ */
et2_file.prototype.onStart = function (event, file_count) { onStart(event, file_count) {
// Hide any previous errors // Hide any previous errors
this.hideMessage(); this.hideMessage();
event.data = this; event.data = this;
@ -367,11 +350,11 @@ var et2_file = /** @class */ (function (_super) {
if (this.options.onStart) if (this.options.onStart)
return et2_call(this.options.onStart, event, file_count); return et2_call(this.options.onStart, event, file_count);
return true; return true;
}; }
/** /**
* Re-enables submit buttons when done * Re-enables submit buttons when done
*/ */
et2_file.prototype.onFinish = function () { onFinish() {
this.disabled_buttons.removeAttr("disabled").css('cursor', 'pointer').removeClass('et2_button_ro'); this.disabled_buttons.removeAttr("disabled").css('cursor', 'pointer').removeClass('et2_button_ro');
var file_count = this.resumable.files.length; var file_count = this.resumable.files.length;
// Remove files from list // Remove files from list
@ -397,13 +380,13 @@ var et2_file = /** @class */ (function (_super) {
// Fire legacy change action when done // Fire legacy change action when done
this.change(this.input); this.change(this.input);
} }
}; }
/** /**
* Build up dropdown progress with total count indicator * Build up dropdown progress with total count indicator
* *
* @todo Implement totalProgress bar instead of ajax-loader, in order to show how much percent of uploading is completed * @todo Implement totalProgress bar instead of ajax-loader, in order to show how much percent of uploading is completed
*/ */
et2_file.prototype._build_progressDropDownList = function () { _build_progressDropDownList() {
this.progress.addClass("progress_dropDown_fileList"); this.progress.addClass("progress_dropDown_fileList");
//Add uploading indicator and bind hover handler on it //Add uploading indicator and bind hover handler on it
jQuery(this.node).find('span').addClass('totalProgress_loader'); jQuery(this.node).find('span').addClass('totalProgress_loader');
@ -416,14 +399,14 @@ var et2_file = /** @class */ (function (_super) {
jQuery('.progress_dropDown_fileList').hide(); jQuery('.progress_dropDown_fileList').hide();
} }
}); });
}; }
/** /**
* Creates the elements used for displaying the file, and it's upload status, and * Creates the elements used for displaying the file, and it's upload status, and
* attaches them to the DOM * attaches them to the DOM
* *
* @param _event Either the event, or an error message * @param _event Either the event, or an error message
*/ */
et2_file.prototype.createStatus = function (_event, file) { createStatus(_event, file) {
var error = (typeof _event == "object" ? "" : _event); var error = (typeof _event == "object" ? "" : _event);
if (this.options.max_file_size && file.size > this.options.max_file_size) { if (this.options.max_file_size && file.size > this.options.max_file_size) {
error = this.egw().lang("File too large. Maximum %1", et2_vfsSize.prototype.human_size(this.options.max_file_size)); error = this.egw().lang("File too large. Maximum %1", et2_vfsSize.prototype.human_size(this.options.max_file_size));
@ -448,20 +431,20 @@ var et2_file = /** @class */ (function (_super) {
} }
} }
return error == ""; return error == "";
}; }
et2_file.prototype._fileProgress = function (file) { _fileProgress(file) {
if (this.progress) { if (this.progress) {
jQuery("li[data-file='" + file.fileName.replace(/'/g, '&quot') + "'] > span.progressBar > p").css("width", Math.ceil(file.progress() * 100) + "%"); jQuery("li[data-file='" + file.fileName.replace(/'/g, '&quot') + "'] > span.progressBar > p").css("width", Math.ceil(file.progress() * 100) + "%");
} }
return true; return true;
}; }
et2_file.prototype.onError = function (event, name, error) { onError(event, name, error) {
console.warn(event, name, error); console.warn(event, name, error);
}; }
/** /**
* A file upload is finished, update the UI * A file upload is finished, update the UI
*/ */
et2_file.prototype.finishUpload = function (file, response) { finishUpload(file, response) {
var name = file.fileName || 'file'; var name = file.fileName || 'file';
if (typeof response == 'string') if (typeof response == 'string')
response = jQuery.parseJSON(response); response = jQuery.parseJSON(response);
@ -502,13 +485,13 @@ var et2_file = /** @class */ (function (_super) {
this.onFinishOne(event, response, name); this.onFinishOne(event, response, name);
} }
return true; return true;
}; }
/** /**
* Remove a file from the list of values * Remove a file from the list of values
* *
* @param {File|string} File object, or file name, to remove * @param {File|string} File object, or file name, to remove
*/ */
et2_file.prototype.remove_file = function (file) { remove_file(file) {
//console.info(filename); //console.info(filename);
if (typeof file == 'string') { if (typeof file == 'string') {
file = { fileName: file }; file = { fileName: file };
@ -522,11 +505,11 @@ var et2_file = /** @class */ (function (_super) {
} }
if (file.isComplete && !file.isComplete() && file.cancel) if (file.isComplete && !file.isComplete() && file.cancel)
file.cancel(); file.cancel();
}; }
/** /**
* Cancel a file - event callback * Cancel a file - event callback
*/ */
et2_file.prototype.cancel = function (e) { cancel(e) {
e.preventDefault(); e.preventDefault();
// Look for file name in list // Look for file name in list
var target = jQuery(e.target).parents("li"); var target = jQuery(e.target).parents("li");
@ -534,13 +517,13 @@ var et2_file = /** @class */ (function (_super) {
// In case it didn't make it to the list (error) // In case it didn't make it to the list (error)
target.remove(); target.remove();
jQuery(e.target).remove(); jQuery(e.target).remove();
}; }
/** /**
* Set readonly * Set readonly
* *
* @param {boolean} _ro boolean readonly state, true means readonly * @param {boolean} _ro boolean readonly state, true means readonly
*/ */
et2_file.prototype.set_readonly = function (_ro) { set_readonly(_ro) {
if (typeof _ro != "undefined") { if (typeof _ro != "undefined") {
this.options.readonly = _ro; this.options.readonly = _ro;
this.span.toggleClass('et2_file_ro', _ro); this.span.toggleClass('et2_file_ro', _ro);
@ -552,8 +535,9 @@ var et2_file = /** @class */ (function (_super) {
this.span.off().bind('click', function () { self.input.click(); }); this.span.off().bind('click', function () { self.input.click(); });
} }
} }
}; }
et2_file._attributes = { }
et2_file._attributes = {
"multiple": { "multiple": {
"name": "Multiple files", "name": "Multiple files",
"type": "boolean", "type": "boolean",
@ -632,9 +616,6 @@ var et2_file = /** @class */ (function (_super) {
"default": 1024 * 1024, "default": 1024 * 1024,
"description": "Max chunk size, gets set from server-side PHP (max_upload_size-1M)/2" // last chunk can be up to 2*chunk_size! "description": "Max chunk size, gets set from server-side PHP (max_upload_size-1M)/2" // last chunk can be up to 2*chunk_size!
} }
}; };
return et2_file; et2_register_widget(et2_file, ["file"]);
}(et2_core_inputWidget_1.et2_inputWidget));
exports.et2_file = et2_file;
et2_core_widget_1.et2_register_widget(et2_file, ["file"]);
//# sourceMappingURL=et2_widget_file.js.map //# sourceMappingURL=et2_widget_file.js.map

View File

@ -4,20 +4,23 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @copyright Nathan Gray 2011 * @copyright Nathan Gray 2011
* @version $Id$
*/ */
/*egw:uses /*egw:uses
et2_core_inputWidget; et2_core_inputWidget;
phpgwapi.Resumable.resumable; api.Resumable.resumable;
*/ */
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_no_init} from "./et2_core_common";
import {et2_DOMWidget} from "./et2_core_DOMWidget";
import {et2_vfsSize} from "./et2_widget_vfs";
import "../Resumable/resumable.js";
/** /**
* Class which implements file upload * Class which implements file upload
@ -293,7 +296,7 @@ export class et2_file extends et2_inputWidget
if(!this.options.drop_target) return; if(!this.options.drop_target) return;
// Set up new drop target // Set up new drop target
let widget = this.getRoot().getWidgetById(this.options.drop_target); let widget = <et2_DOMWidget>this.getRoot().getWidgetById(this.options.drop_target);
let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target); let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
if(drop_target) if(drop_target)
{ {
@ -603,7 +606,7 @@ export class et2_file extends et2_inputWidget
if(this.options.progress) if(this.options.progress)
{ {
var widget = this.getRoot().getWidgetById(this.options.progress); var widget = <et2_DOMWidget>this.getRoot().getWidgetById(this.options.progress);
if(widget) if(widget)
{ {
this.progress = jQuery(widget.getDOMNode()); this.progress = jQuery(widget.getDOMNode());

Some files were not shown because too many files have changed in this diff Show More