mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
got et2 mostly working: timesheet.edit renders
This commit is contained in:
parent
592b7fb97d
commit
f91bca83e1
@ -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_links.js';\n\n";
|
||||
$content .= 'window.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_configs('.$config.", 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
|
||||
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))
|
||||
|
@ -48,7 +48,7 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
|
||||
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
|
||||
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))
|
||||
|
@ -6,7 +6,8 @@
|
||||
* @copyright 2011 by Andreas Stöckel
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @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
|
||||
@ -125,7 +126,7 @@ function _egwSetMenuOnClick(_elements, _onClick)
|
||||
* The currently available implementation is the "egwDhtmlxMenu.js" which is based
|
||||
* upon the dhtmlxmenu component.
|
||||
*/
|
||||
function egwMenu()
|
||||
export function egwMenu()
|
||||
{
|
||||
//The "items" variable contains all menu items of the menu
|
||||
this.children = [];
|
||||
@ -373,7 +374,7 @@ egwMenu.prototype.setGlobalOnClick = function(_onClick)
|
||||
* Constructor for the egwMenuItem. Each entry in a menu (including seperators)
|
||||
* is represented by a menu item.
|
||||
*/
|
||||
function egwMenuItem(_parent, _id)
|
||||
export function egwMenuItem(_parent, _id)
|
||||
{
|
||||
this.id = _id;
|
||||
this.caption = "";
|
||||
|
@ -1,38 +1,23 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS DOM Widget class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
et2_core_interfaces;
|
||||
et2_core_widget;
|
||||
/api/js/egw_action/egw_action.js;
|
||||
*/
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
require("./et2_core_interfaces");
|
||||
require("./et2_core_common");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
require("../egw_action/egw_action.js");
|
||||
import { ClassWithAttributes } from './et2_core_inheritance';
|
||||
import { et2_IDOMNode } from "./et2_core_interfaces";
|
||||
import { et2_hasChild, et2_no_init } from "./et2_core_common";
|
||||
import { et2_widget } from "./et2_core_widget";
|
||||
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
|
||||
* deriving from this class have to care about implementing the "getDOMNode"
|
||||
@ -40,32 +25,29 @@ require("../egw_action/egw_action.js");
|
||||
*
|
||||
* @augments et2_widget
|
||||
*/
|
||||
var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_DOMWidget, _super);
|
||||
export class et2_DOMWidget extends et2_widget {
|
||||
/**
|
||||
* When the DOMWidget is initialized, it grabs the DOM-Node of the parent
|
||||
* object (if available) and passes it to its own "createDOMNode" function
|
||||
*
|
||||
* @memberOf et2_DOMWidget
|
||||
*/
|
||||
function et2_DOMWidget(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_DOMWidget._attributes, _child || {})) || this;
|
||||
_this.parentNode = null;
|
||||
_this.disabled = false;
|
||||
_this._attachSet = {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_DOMWidget._attributes, _child || {}));
|
||||
this.parentNode = null;
|
||||
this.disabled = false;
|
||||
this._attachSet = {
|
||||
"node": null,
|
||||
"parent": null
|
||||
};
|
||||
_this._surroundingsMgr = null;
|
||||
return _this;
|
||||
this._surroundingsMgr = null;
|
||||
}
|
||||
/**
|
||||
* Detatches the node from the DOM and clears all references to the parent
|
||||
* node or the dom node of this widget.
|
||||
*/
|
||||
et2_DOMWidget.prototype.destroy = function () {
|
||||
destroy() {
|
||||
this.detachFromDOM();
|
||||
this.parentNode = null;
|
||||
this._attachSet = {};
|
||||
@ -83,12 +65,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
this._surroundingsMgr.destroy();
|
||||
this._surroundingsMgr = null;
|
||||
}
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
super.destroy();
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
// yes, grab the DOM node and create our own.
|
||||
if (this.getParent() && this.getParent().implements(et2_IDOMNode)) {
|
||||
@ -100,12 +82,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Detaches the widget from the DOM tree, if it had been attached to the
|
||||
* DOM-Tree using the attachToDOM method.
|
||||
*/
|
||||
et2_DOMWidget.prototype.detachFromDOM = function () {
|
||||
detachFromDOM() {
|
||||
if (this._attachSet && this._attachSet.node && this._attachSet.parent) {
|
||||
// Remove the current node from the parent node
|
||||
try {
|
||||
@ -122,13 +104,13 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* defined.
|
||||
*/
|
||||
et2_DOMWidget.prototype.attachToDOM = function () {
|
||||
attachToDOM() {
|
||||
// Attach the DOM node of this widget (if existing) to the new parent
|
||||
var node = this.getDOMNode(this);
|
||||
if (node && this.parentNode &&
|
||||
@ -155,7 +137,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Inserts a child at the given index.
|
||||
*
|
||||
@ -163,8 +145,8 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
* of et2_widget
|
||||
* @param _idx is the position at which the element should be added.
|
||||
*/
|
||||
et2_DOMWidget.prototype.insertChild = function (_node, _idx) {
|
||||
_super.prototype.insertChild.call(this, _node, _idx);
|
||||
insertChild(_node, _idx) {
|
||||
super.insertChild(_node, _idx);
|
||||
if (_node.instanceOf(et2_DOMWidget) && typeof _node.hasOwnProperty('parentNode') && this.getDOMNode(this)) {
|
||||
try {
|
||||
_node.setParentDOMNode(this.getDOMNode(_node));
|
||||
@ -174,16 +156,16 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
// will probably try again in doLoadingFinished()
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.isAttached = function () {
|
||||
}
|
||||
isAttached() {
|
||||
return this.parentNode != null;
|
||||
};
|
||||
et2_DOMWidget.prototype.getSurroundings = function () {
|
||||
}
|
||||
getSurroundings() {
|
||||
if (!this._surroundingsMgr) {
|
||||
this._surroundingsMgr = new et2_surroundingsMgr(this);
|
||||
}
|
||||
return this._surroundingsMgr;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_DOMWidget.prototype.get_tab_info = function () {
|
||||
get_tab_info() {
|
||||
var parent = this;
|
||||
do {
|
||||
parent = parent.getParent();
|
||||
@ -204,7 +186,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
if (parent === this.getRoot()) {
|
||||
return null;
|
||||
}
|
||||
var tabbox = parent;
|
||||
let tabbox = parent;
|
||||
// Find the tab index
|
||||
for (var i = 0; i < tabbox.tabData.length; i++) {
|
||||
// Find the tab by DOM heritage
|
||||
@ -226,19 +208,19 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
// Fallback
|
||||
var fallback = this.getParent();
|
||||
let fallback = this.getParent();
|
||||
if (typeof fallback.get_tab_info === 'function') {
|
||||
return fallback.get_tab_info();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the parent DOM node of this element. Takes a wider variety of types
|
||||
* 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.
|
||||
*/
|
||||
et2_DOMWidget.prototype.set_parent_node = function (_node) {
|
||||
set_parent_node(_node) {
|
||||
if (typeof _node == "string") {
|
||||
var parent = jQuery('#' + _node);
|
||||
if (parent.length === 0 && window.parent) {
|
||||
@ -256,14 +238,14 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.setParentDOMNode(_node);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the parent DOM node of this element. If another parent node is already
|
||||
* set, this widget removes itself from the DOM tree
|
||||
*
|
||||
* @param _node
|
||||
*/
|
||||
et2_DOMWidget.prototype.setParentDOMNode = function (_node) {
|
||||
setParentDOMNode(_node) {
|
||||
if (_node != this.parentNode) {
|
||||
// Detatch this element from the DOM tree
|
||||
this.detachFromDOM();
|
||||
@ -271,17 +253,17 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
// And attatch the element to the DOM tree
|
||||
this.attachToDOM();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*/
|
||||
et2_DOMWidget.prototype.getParentDOMNode = function () {
|
||||
getParentDOMNode() {
|
||||
return this.parentNode;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the index of this element in the DOM tree
|
||||
*/
|
||||
et2_DOMWidget.prototype.getDOMIndex = function () {
|
||||
getDOMIndex() {
|
||||
if (this.getParent()) {
|
||||
var idx = 0;
|
||||
var children = this.getParent().getChildren();
|
||||
@ -298,7 +280,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the id of the DOM-Node.
|
||||
*
|
||||
@ -306,7 +288,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
*
|
||||
* @param {string} _value id to set
|
||||
*/
|
||||
et2_DOMWidget.prototype.set_id = function (_value) {
|
||||
set_id(_value) {
|
||||
this.id = _value;
|
||||
this.dom_id = _value ? this.getInstanceManager().uniqueId + '_' + _value.replace(/\./g, '-') : _value;
|
||||
var node = this.getDOMNode(this);
|
||||
@ -318,8 +300,8 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
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);
|
||||
if (node && this.disabled != _value) {
|
||||
this.disabled = _value;
|
||||
@ -330,22 +312,22 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
jQuery(node).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.set_width = function (_value) {
|
||||
}
|
||||
set_width(_value) {
|
||||
this.width = _value;
|
||||
var node = this.getDOMNode(this);
|
||||
if (node) {
|
||||
jQuery(node).css("width", _value);
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.set_height = function (_value) {
|
||||
}
|
||||
set_height(_value) {
|
||||
this.height = _value;
|
||||
var node = this.getDOMNode(this);
|
||||
if (node) {
|
||||
jQuery(node).css("height", _value);
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.set_class = function (_value) {
|
||||
}
|
||||
set_class(_value) {
|
||||
var node = this.getDOMNode(this);
|
||||
if (node) {
|
||||
if (this["class"]) {
|
||||
@ -354,15 +336,15 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
jQuery(node).addClass(_value);
|
||||
}
|
||||
this["class"] = _value;
|
||||
};
|
||||
et2_DOMWidget.prototype.set_overflow = function (_value) {
|
||||
}
|
||||
set_overflow(_value) {
|
||||
this.overflow = _value;
|
||||
var node = this.getDOMNode(this);
|
||||
if (node) {
|
||||
jQuery(node).css("overflow", _value);
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.set_data = function (_value) {
|
||||
}
|
||||
set_data(_value) {
|
||||
var node = this.getDOMNode(this);
|
||||
if (node && _value) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_DOMWidget.prototype.set_background = function (_value) {
|
||||
}
|
||||
set_background(_value) {
|
||||
var node = this.getDOMNode(this);
|
||||
var values = '';
|
||||
if (_value && node) {
|
||||
@ -384,7 +366,7 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
"background-scale": values[3]
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* @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") {
|
||||
this.egw().debug("warn", "Widget should have an ID if you want actions", this);
|
||||
return;
|
||||
@ -438,12 +420,12 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
this._actionManager.data = { widget: this };
|
||||
// Link the actions to the DOM
|
||||
this._link_actions(actions);
|
||||
};
|
||||
et2_DOMWidget.prototype.set_default_execute = function (_default_execute) {
|
||||
}
|
||||
set_default_execute(_default_execute) {
|
||||
this.options.default_execute = _default_execute;
|
||||
if (this._actionManager)
|
||||
this._actionManager.setDefaultExecute(null, _default_execute);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* @returns {Array}
|
||||
*/
|
||||
et2_DOMWidget.prototype._get_action_links = function (actions) {
|
||||
_get_action_links(actions) {
|
||||
var action_links = [];
|
||||
for (var i in actions) {
|
||||
var action = actions[i];
|
||||
action_links.push(typeof action.id != 'undefined' ? action.id : i);
|
||||
}
|
||||
return action_links;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Link the actions to the DOM nodes / widget bits.
|
||||
*
|
||||
* @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
|
||||
var objectManager = egw_getAppObjectManager(true);
|
||||
var widget_object = objectManager.getObjectById(this.id);
|
||||
@ -484,8 +466,9 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
// 'allowed' for this widget at this time
|
||||
var action_links = this._get_action_links(actions);
|
||||
widget_object.updateActionLinks(action_links);
|
||||
};
|
||||
et2_DOMWidget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_DOMWidget._attributes = {
|
||||
"disabled": {
|
||||
"name": "Disabled",
|
||||
"type": "boolean",
|
||||
@ -552,44 +535,39 @@ var et2_DOMWidget = /** @class */ (function (_super) {
|
||||
default: '',
|
||||
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
|
||||
* an widget node.
|
||||
*/
|
||||
var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
__extends(et2_surroundingsMgr, _super);
|
||||
export class et2_surroundingsMgr extends ClassWithAttributes {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_surroundingsMgr
|
||||
* @param _widget
|
||||
*/
|
||||
function et2_surroundingsMgr(_widget) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._widgetContainer = null;
|
||||
_this._widgetSurroundings = [];
|
||||
_this._widgetPlaceholder = null;
|
||||
_this._widgetNode = null;
|
||||
_this._ownPlaceholder = true;
|
||||
_this._surroundingsUpdated = false;
|
||||
_this.widget = _widget;
|
||||
return _this;
|
||||
constructor(_widget) {
|
||||
super();
|
||||
this._widgetContainer = null;
|
||||
this._widgetSurroundings = [];
|
||||
this._widgetPlaceholder = null;
|
||||
this._widgetNode = null;
|
||||
this._ownPlaceholder = true;
|
||||
this._surroundingsUpdated = false;
|
||||
this.widget = _widget;
|
||||
}
|
||||
et2_surroundingsMgr.prototype.destroy = function () {
|
||||
destroy() {
|
||||
this._widgetContainer = null;
|
||||
this._widgetSurroundings = null;
|
||||
this._widgetPlaceholder = null;
|
||||
this._widgetNode = null;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.prependDOMNode = function (_node) {
|
||||
}
|
||||
prependDOMNode(_node) {
|
||||
this._widgetSurroundings.unshift(_node);
|
||||
this._surroundingsUpdated = true;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.appendDOMNode = function (_node) {
|
||||
}
|
||||
appendDOMNode(_node) {
|
||||
// Append an placeholder first if none is existing yet
|
||||
if (this._ownPlaceholder && this._widgetPlaceholder == null) {
|
||||
this._widgetPlaceholder = document.createElement("span");
|
||||
@ -598,8 +576,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
// Append the given node
|
||||
this._widgetSurroundings.push(_node);
|
||||
this._surroundingsUpdated = true;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.insertDOMNode = function (_node) {
|
||||
}
|
||||
insertDOMNode(_node) {
|
||||
if (!this._ownPlaceholder || this._widgetPlaceholder == null) {
|
||||
this.appendDOMNode(_node);
|
||||
return;
|
||||
@ -611,8 +589,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
// Delete the reference to the own placeholder
|
||||
this._widgetPlaceholder = null;
|
||||
this._ownPlaceholder = false;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.removeDOMNode = function (_node) {
|
||||
}
|
||||
removeDOMNode(_node) {
|
||||
for (var i = 0; this._widgetSurroundings && i < this._widgetSurroundings.length; i++) {
|
||||
if (this._widgetSurroundings[i] == _node) {
|
||||
this._widgetSurroundings.splice(i, 1);
|
||||
@ -620,8 +598,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_surroundingsMgr.prototype.setWidgetPlaceholder = function (_node) {
|
||||
}
|
||||
setWidgetPlaceholder(_node) {
|
||||
if (_node != this._widgetPlaceholder) {
|
||||
if (_node != null && this._ownPlaceholder && this._widgetPlaceholder != null) {
|
||||
// Delete the current placeholder which was created by the
|
||||
@ -637,8 +615,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
this._widgetPlaceholder = _node;
|
||||
this._surroundingsUpdated = true;
|
||||
}
|
||||
};
|
||||
et2_surroundingsMgr.prototype._rebuildContainer = function () {
|
||||
}
|
||||
_rebuildContainer() {
|
||||
// Return if there has been no change in the "surroundings-data"
|
||||
if (!this._surroundingsUpdated) {
|
||||
return false;
|
||||
@ -679,8 +657,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
}
|
||||
this._surroundingsUpdated = false;
|
||||
return true;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.update = function () {
|
||||
}
|
||||
update() {
|
||||
if (this._surroundingsUpdated) {
|
||||
var attached = this.widget ? this.widget.isAttached() : false;
|
||||
// Reattach the widget - this will call the "getDOMNode" function
|
||||
@ -690,8 +668,8 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
this.widget.attachToDOM();
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_surroundingsMgr.prototype.getDOMNode = function (_widgetNode) {
|
||||
}
|
||||
getDOMNode(_widgetNode) {
|
||||
// Update the whole widgetContainer if this is not the first time this
|
||||
// function has been called but the widget node has changed.
|
||||
if (this._widgetNode != null && this._widgetNode != _widgetNode) {
|
||||
@ -716,12 +694,11 @@ var et2_surroundingsMgr = /** @class */ (function (_super) {
|
||||
}
|
||||
// Return the widget container
|
||||
return this._widgetContainer;
|
||||
};
|
||||
et2_surroundingsMgr.prototype.getWidgetSurroundings = function () {
|
||||
}
|
||||
getWidgetSurroundings() {
|
||||
return this._widgetSurroundings;
|
||||
};
|
||||
return et2_surroundingsMgr;
|
||||
}(et2_core_inheritance_1.ClassWithAttributes));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The egw_action system requires an egwActionObjectInterface Interface implementation
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
var et2_action_object_impl = /** @class */ (function () {
|
||||
function et2_action_object_impl(_widget, _node) {
|
||||
export class et2_action_object_impl {
|
||||
constructor(_widget, _node) {
|
||||
var widget = _widget;
|
||||
var objectNode = _node;
|
||||
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 et2_action_object_impl;
|
||||
}());
|
||||
exports.et2_action_object_impl = et2_action_object_impl;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_core_DOMWidget.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
@ -15,11 +15,13 @@
|
||||
*/
|
||||
|
||||
import {ClassWithAttributes} from './et2_core_inheritance';
|
||||
import './et2_core_interfaces';
|
||||
import './et2_core_common';
|
||||
import {et2_IDOMNode} from "./et2_core_interfaces";
|
||||
import {et2_hasChild, et2_no_init} from "./et2_core_common";
|
||||
import {et2_widget, WidgetConfig} from "./et2_core_widget";
|
||||
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
|
||||
@ -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
|
||||
* an widget node.
|
||||
*/
|
||||
class et2_surroundingsMgr extends ClassWithAttributes
|
||||
export class et2_surroundingsMgr extends ClassWithAttributes
|
||||
{
|
||||
widget: et2_DOMWidget;
|
||||
private _widgetContainer: any = null;
|
||||
|
@ -1,40 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS content array manager
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*
|
||||
|
||||
*/
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
egw_inheritance;
|
||||
et2_core_phpExpressionCompiler;
|
||||
*/
|
||||
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_arrayMgrs_expand = exports.et2_readonlysArrayMgr = exports.et2_arrayMgr = void 0;
|
||||
import { et2_evalBool } from "./et2_core_common";
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* Manage access to various template customisation arrays passed to etemplate->exec().
|
||||
*
|
||||
* This manages access to content, modifications and readonlys arrays
|
||||
*/
|
||||
var et2_arrayMgr = /** @class */ (function () {
|
||||
export class et2_arrayMgr {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -42,8 +27,7 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
* @param _data
|
||||
* @param _parentMgr
|
||||
*/
|
||||
function et2_arrayMgr(_data, _parentMgr) {
|
||||
if (_data === void 0) { _data = {}; }
|
||||
constructor(_data = {}, _parentMgr) {
|
||||
this.splitIds = true;
|
||||
// Holds information about the current perspective
|
||||
this.perspectiveData = {
|
||||
@ -68,14 +52,14 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
// Expanded: ${row}: Object{info_cat: ..value}
|
||||
if (this.splitIds) {
|
||||
// For each index, we need a key: {..} sub array
|
||||
for (var key in _data) {
|
||||
for (let key in _data) {
|
||||
// Split up indexes
|
||||
var indexes = key.replace(/[/g, "[").split('[');
|
||||
const indexes = key.replace(/[/g, "[").split('[');
|
||||
// Put data in the proper place
|
||||
if (indexes.length > 1) {
|
||||
var value = _data[key];
|
||||
var target = _data;
|
||||
for (var i = 0; i < indexes.length; i++) {
|
||||
const value = _data[key];
|
||||
let target = _data;
|
||||
for (let i = 0; i < indexes.length; i++) {
|
||||
indexes[i] = indexes[i].replace(/]/g, '').replace(']', '');
|
||||
if (typeof target[indexes[i]] == "undefined" || target[indexes[i]] === null) {
|
||||
target[indexes[i]] = i == indexes.length - 1 ? value : {};
|
||||
@ -91,24 +75,24 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
/**
|
||||
* Returns the root content array manager object
|
||||
*/
|
||||
et2_arrayMgr.prototype.getRoot = function () {
|
||||
getRoot() {
|
||||
if (this._parentMgr != null) {
|
||||
return this._parentMgr.getRoot();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
et2_arrayMgr.prototype.getParentMgr = function () {
|
||||
}
|
||||
getParentMgr() {
|
||||
return this._parentMgr;
|
||||
};
|
||||
et2_arrayMgr.prototype.getPerspectiveData = function () {
|
||||
}
|
||||
getPerspectiveData() {
|
||||
return this.perspectiveData;
|
||||
};
|
||||
et2_arrayMgr.prototype.setPerspectiveData = function (new_perspective) {
|
||||
}
|
||||
setPerspectiveData(new_perspective) {
|
||||
this.perspectiveData = new_perspective;
|
||||
};
|
||||
et2_arrayMgr.prototype.setRow = function (new_row) {
|
||||
}
|
||||
setRow(new_row) {
|
||||
this.perspectiveData.row = new_row;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Explodes compound keys (eg IDs) into a list of namespaces
|
||||
* This uses no internal values, just expands
|
||||
@ -121,11 +105,11 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
*
|
||||
* @return {string[]}
|
||||
*/
|
||||
et2_arrayMgr.prototype.explodeKey = function (_key) {
|
||||
explodeKey(_key) {
|
||||
if (!_key || typeof _key == 'string' && _key.trim() === "")
|
||||
return [];
|
||||
// Parse the given key by removing the "]"-chars and splitting at "["
|
||||
var indexes = [_key];
|
||||
let indexes = [_key];
|
||||
if (typeof _key === "string") {
|
||||
_key = _key.replace(/[/g, "[").replace(/]/g, "]");
|
||||
indexes = _key.split('[');
|
||||
@ -133,20 +117,20 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
if (indexes.length > 1) {
|
||||
indexes = [indexes.shift(), indexes.join('[')];
|
||||
indexes[1] = indexes[1].substring(0, indexes[1].length - 1);
|
||||
var children = indexes[1].split('][');
|
||||
const children = indexes[1].split('][');
|
||||
if (children.length) {
|
||||
indexes = jQuery.merge([indexes[0]], children);
|
||||
}
|
||||
}
|
||||
return indexes;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the path to this content array manager perspective as an array
|
||||
* containing the key values
|
||||
*
|
||||
* @param _path is used internally, do not supply it manually.
|
||||
*/
|
||||
et2_arrayMgr.prototype.getPath = function (_path) {
|
||||
getPath(_path) {
|
||||
if (typeof _path == "undefined") {
|
||||
_path = [];
|
||||
}
|
||||
@ -158,7 +142,7 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
_path = this._parentMgr.getPath(_path);
|
||||
}
|
||||
return _path;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get array entry is the equivalent to the boetemplate get_array function.
|
||||
* It returns a reference to the (sub) array with the given key. This also works
|
||||
@ -170,7 +154,7 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
* @param _skipEmpty returns null if _key is not present in this content array.
|
||||
* Defaults to false.
|
||||
*/
|
||||
et2_arrayMgr.prototype.getEntry = function (_key, _referenceInto, _skipEmpty) {
|
||||
getEntry(_key, _referenceInto, _skipEmpty) {
|
||||
if (typeof _referenceInto == "undefined") {
|
||||
_referenceInto = false;
|
||||
}
|
||||
@ -178,26 +162,26 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
_skipEmpty = false;
|
||||
}
|
||||
// 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)
|
||||
return null;
|
||||
var entry = this.data;
|
||||
for (var i = 0; i < indexes.length; i++) {
|
||||
let entry = this.data;
|
||||
for (let i = 0; i < indexes.length; i++) {
|
||||
// Abort if the current entry is not an object (associative array) and
|
||||
// we should descend further into it.
|
||||
var isObject = typeof entry === 'object';
|
||||
const isObject = typeof entry === 'object';
|
||||
if (!isObject && !_referenceInto || entry == null || jQuery.isEmptyObject(entry)) {
|
||||
return null;
|
||||
}
|
||||
// Check whether the entry actually exists
|
||||
var idx = indexes[i];
|
||||
const idx = indexes[i];
|
||||
if (_skipEmpty && (!isObject || typeof entry[idx] == "undefined")) {
|
||||
return null;
|
||||
}
|
||||
entry = entry[idx];
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Equivalent to the boetemplate::expand_name function.
|
||||
*
|
||||
@ -207,20 +191,20 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
* @param {string} _ident Key used to reference into managed array
|
||||
* @return {*}
|
||||
*/
|
||||
et2_arrayMgr.prototype.expandName = function (_ident) {
|
||||
expandName(_ident) {
|
||||
// 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
|
||||
var pos_var = _ident.indexOf('$');
|
||||
const pos_var = _ident.indexOf('$');
|
||||
if (pos_var >= 0 && (this.perspectiveData.row != null || !_ident.match(/\$\{?row\}?/))
|
||||
// Avoid messing with regex in validators
|
||||
&& pos_var !== _ident.indexOf("$/")) {
|
||||
// Get the content array for the current row
|
||||
var row = typeof this.perspectiveData.row == 'number' ? this.perspectiveData.row : '';
|
||||
var row_cont = this.data[row] || {};
|
||||
const row = typeof this.perspectiveData.row == 'number' ? this.perspectiveData.row : '';
|
||||
const row_cont = this.data[row] || {};
|
||||
// $cont is NOT root but current name-space in old eTemplate
|
||||
var cont = this.data; //getRoot().data;
|
||||
var _cont = this.data; // according to a grep only used in ImportExport just twice
|
||||
const cont = this.data; //getRoot().data;
|
||||
const _cont = this.data; // according to a grep only used in ImportExport just twice
|
||||
// Check whether the expression has already been compiled - if not,
|
||||
// try to compile it first. If an error occurs, the identifier
|
||||
// function is set to null
|
||||
@ -272,22 +256,22 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
return _ident;
|
||||
};
|
||||
et2_arrayMgr.prototype.parseBoolExpression = function (_expression) {
|
||||
}
|
||||
parseBoolExpression(_expression) {
|
||||
// If the first char of the expression is a '!' this means, that the value
|
||||
// is to be negated.
|
||||
if (_expression.charAt(0) == '!') {
|
||||
return !this.parseBoolExpression(_expression.substr(1));
|
||||
}
|
||||
// Split the expression at a possible "="
|
||||
var parts = _expression.split('=');
|
||||
const parts = _expression.split('=');
|
||||
// Expand the first value
|
||||
var val = this.expandName(parts[0]);
|
||||
let val = this.expandName(parts[0]);
|
||||
val = (typeof val == "undefined" || val === null) ? '' : '' + val;
|
||||
// If a second expression existed, test that one
|
||||
if (typeof parts[1] != "undefined") {
|
||||
// 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
|
||||
// checked whether the first value matches the regular expression
|
||||
if (checkVal.charAt(0) == '/') {
|
||||
@ -298,7 +282,7 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
return val == checkVal;
|
||||
}
|
||||
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 {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
|
||||
var root = typeof _root == "string" ? this.data[_root] :
|
||||
let root = typeof _root == "string" ? this.data[_root] :
|
||||
(_root == null ? this.data : _root);
|
||||
if (typeof root == "undefined" && typeof _root == "string")
|
||||
root = this.getEntry(_root);
|
||||
// Create a new content array manager with the given root
|
||||
var constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr;
|
||||
var mgr = new constructor(root, this);
|
||||
const constructor = this.readOnly ? et2_readonlysArrayMgr : et2_arrayMgr;
|
||||
const mgr = new constructor(root, this);
|
||||
// Set the owner
|
||||
mgr.perspectiveData.owner = _owner;
|
||||
// Set the root key
|
||||
@ -326,20 +310,16 @@ var et2_arrayMgr = /** @class */ (function () {
|
||||
mgr.perspectiveData.row = _row;
|
||||
}
|
||||
return mgr;
|
||||
};
|
||||
et2_arrayMgr.compiledExpressions = {};
|
||||
return et2_arrayMgr;
|
||||
}());
|
||||
exports.et2_arrayMgr = et2_arrayMgr;
|
||||
}
|
||||
}
|
||||
et2_arrayMgr.compiledExpressions = {};
|
||||
/**
|
||||
* @augments et2_arrayMgr
|
||||
*/
|
||||
var et2_readonlysArrayMgr = /** @class */ (function (_super) {
|
||||
__extends(et2_readonlysArrayMgr, _super);
|
||||
function et2_readonlysArrayMgr() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.readOnly = true;
|
||||
return _this;
|
||||
export class et2_readonlysArrayMgr extends et2_arrayMgr {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.readOnly = true;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* @returns
|
||||
*/
|
||||
et2_readonlysArrayMgr.prototype.isReadOnly = function (_id, _attr, _parent) {
|
||||
var entry = null;
|
||||
isReadOnly(_id, _attr, _parent) {
|
||||
let entry = null;
|
||||
if (_id != null) {
|
||||
if (_id.indexOf('$') >= 0 || _id.indexOf('@') >= 0) {
|
||||
_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
|
||||
// under current namespace, we look into 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)) {
|
||||
mgr = mgr.getParentMgr();
|
||||
}
|
||||
@ -381,7 +361,7 @@ var et2_readonlysArrayMgr = /** @class */ (function (_super) {
|
||||
// Otherwise return the default value
|
||||
entry = this.getEntry("__ALL__");
|
||||
return entry !== null && (typeof entry != "undefined");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @returns {*}
|
||||
*/
|
||||
et2_readonlysArrayMgr.prototype.expandName = function (ident) {
|
||||
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
|
||||
*
|
||||
@ -408,15 +386,15 @@ exports.et2_readonlysArrayMgr = et2_readonlysArrayMgr;
|
||||
* existing array managers.
|
||||
* @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
|
||||
var result = {};
|
||||
let result = {};
|
||||
// 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];
|
||||
if (typeof _data[key] != "undefined") {
|
||||
// Open a perspective for the given data row
|
||||
var rowData = {};
|
||||
let rowData = {};
|
||||
rowData[_row] = _data[key];
|
||||
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 result;
|
||||
}
|
||||
exports.et2_arrayMgrs_expand = et2_arrayMgrs_expand;
|
||||
//# sourceMappingURL=et2_core_arrayMgr.js.map
|
@ -4,9 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
@ -14,7 +14,9 @@
|
||||
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().
|
||||
|
@ -1,38 +1,16 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Widget base class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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_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");
|
||||
import { et2_DOMWidget } from './et2_core_DOMWidget';
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_no_init } from "./et2_core_common";
|
||||
/**
|
||||
* Class which manages the DOM node itself. The simpleWidget class is derrived
|
||||
* 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
|
||||
*/
|
||||
var et2_baseWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_baseWidget, _super);
|
||||
export class et2_baseWidget extends et2_DOMWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_baseWidget(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_baseWidget._attributes, _child || {})) || this;
|
||||
_this.align = 'left';
|
||||
_this.node = null;
|
||||
_this.statustext = '';
|
||||
_this._messageDiv = null;
|
||||
_this._tooltipElem = null;
|
||||
return _this;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_baseWidget._attributes, _child || {}));
|
||||
this.align = 'left';
|
||||
this.node = null;
|
||||
this.statustext = '';
|
||||
this._messageDiv = null;
|
||||
this._tooltipElem = null;
|
||||
}
|
||||
et2_baseWidget.prototype.destroy = function () {
|
||||
_super.prototype.destroy.call(this);
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.node = null;
|
||||
this._messageDiv = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
@ -74,7 +49,7 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
* @param _prepend if set, the message is displayed behind the widget node
|
||||
* instead of before. Defaults to false.
|
||||
*/
|
||||
et2_baseWidget.prototype.showMessage = function (_text, _type, _floating, _prepend) {
|
||||
showMessage(_text, _type, _floating, _prepend) {
|
||||
// Preset the parameters
|
||||
if (typeof _type == "undefined") {
|
||||
_type = "hint";
|
||||
@ -103,7 +78,7 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
surr.appendDOMNode(this._messageDiv[0]);
|
||||
}
|
||||
surr.update();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* manager.
|
||||
*/
|
||||
et2_baseWidget.prototype.hideMessage = function (_fade, _noUpdate) {
|
||||
hideMessage(_fade, _noUpdate) {
|
||||
if (typeof _fade == "undefined") {
|
||||
_fade = true;
|
||||
}
|
||||
@ -141,8 +116,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
_done();
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_baseWidget.prototype.detachFromDOM = function () {
|
||||
}
|
||||
detachFromDOM() {
|
||||
// Detach this node from the tooltip node
|
||||
if (this._tooltipElem) {
|
||||
this.egw().tooltipUnbind(this._tooltipElem);
|
||||
@ -152,10 +127,10 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
if (this.node) {
|
||||
jQuery(this.node).unbind("click.et2_baseWidget");
|
||||
}
|
||||
return _super.prototype.detachFromDOM.call(this);
|
||||
};
|
||||
et2_baseWidget.prototype.attachToDOM = function () {
|
||||
var ret = _super.prototype.attachToDOM.call(this);
|
||||
return super.detachFromDOM();
|
||||
}
|
||||
attachToDOM() {
|
||||
let ret = super.attachToDOM();
|
||||
// Add the binding for the click handler
|
||||
if (this.node) {
|
||||
jQuery(this.node).bind("click.et2_baseWidget", this, function (e) {
|
||||
@ -167,8 +142,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
// Update the statustext
|
||||
this.set_statustext(this.statustext);
|
||||
return ret;
|
||||
};
|
||||
et2_baseWidget.prototype.setDOMNode = function (_node) {
|
||||
}
|
||||
setDOMNode(_node) {
|
||||
if (_node != this.node) {
|
||||
// Deatch the old node from the DOM
|
||||
this.detachFromDOM();
|
||||
@ -178,20 +153,20 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
return this.attachToDOM();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
et2_baseWidget.prototype.getDOMNode = function (_sender) {
|
||||
}
|
||||
getDOMNode(_sender) {
|
||||
return this.node;
|
||||
};
|
||||
et2_baseWidget.prototype.getTooltipElement = function () {
|
||||
}
|
||||
getTooltipElement() {
|
||||
return this.getDOMNode(this);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Click handler calling custom handler set via onclick attribute to this.onclick
|
||||
*
|
||||
* @param _ev
|
||||
* @returns
|
||||
*/
|
||||
et2_baseWidget.prototype.click = function (_ev) {
|
||||
click(_ev) {
|
||||
if (typeof this.onclick == 'function') {
|
||||
// Make sure function gets a reference to the widget, splice it in as 2. argument if not
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
@ -200,8 +175,8 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
return this.onclick.apply(this, args);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
et2_baseWidget.prototype.set_statustext = function (_value) {
|
||||
}
|
||||
set_statustext(_value) {
|
||||
// Tooltip should not be shown in mobile view
|
||||
if (egwIsMobile())
|
||||
return;
|
||||
@ -223,14 +198,15 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
this._tooltipElem = elem;
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_baseWidget.prototype.set_align = function (_value) {
|
||||
}
|
||||
set_align(_value) {
|
||||
this.align = _value;
|
||||
};
|
||||
et2_baseWidget.prototype.get_align = function () {
|
||||
}
|
||||
get_align() {
|
||||
return this.align;
|
||||
};
|
||||
et2_baseWidget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_baseWidget._attributes = {
|
||||
"statustext": {
|
||||
"name": "Tooltip",
|
||||
"type": "string",
|
||||
@ -255,34 +231,28 @@ var et2_baseWidget = /** @class */ (function (_super) {
|
||||
"default": et2_no_init,
|
||||
"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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
var et2_container = /** @class */ (function (_super) {
|
||||
__extends(et2_container, _super);
|
||||
export class et2_container extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_container(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_container._attributes, _child || {})) || this;
|
||||
_this.setDOMNode(document.createElement("div"));
|
||||
return _this;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_container._attributes, _child || {}));
|
||||
this.setDOMNode(document.createElement("div"));
|
||||
}
|
||||
/**
|
||||
* The destroy function destroys all children of the widget, removes itself
|
||||
* from the parents children list.
|
||||
* 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
|
||||
for (var i = this._children.length - 1; i >= 0; i--) {
|
||||
this._children[i].destroy();
|
||||
@ -293,31 +263,31 @@ var et2_container = /** @class */ (function (_super) {
|
||||
this._mgrs[key].destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Searches for a DOM widget by id in the tree, descending into the child levels.
|
||||
*
|
||||
* @param _id is the id you're searching for
|
||||
*/
|
||||
et2_container.prototype.getDOMWidgetById = function (_id) {
|
||||
var widget = this.getWidgetById(_id);
|
||||
if (widget && widget.instanceOf(et2_core_DOMWidget_1.et2_DOMWidget)) {
|
||||
getDOMWidgetById(_id) {
|
||||
let widget = this.getWidgetById(_id);
|
||||
if (widget && widget.instanceOf(et2_DOMWidget)) {
|
||||
return widget;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Searches for a Value widget by id in the tree, descending into the child levels.
|
||||
*
|
||||
* @param _id is the id you're searching for
|
||||
*/
|
||||
et2_container.prototype.getInputWidgetById = function (_id) {
|
||||
var widget = this.getWidgetById(_id);
|
||||
getInputWidgetById(_id) {
|
||||
let widget = this.getWidgetById(_id);
|
||||
if (widget && widget.instanceOf(et2_valueWidget)) {
|
||||
return widget;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_container.prototype.setValueById = function (id, value) {
|
||||
var widget = this.getWidgetById(id);
|
||||
setValueById(id, value) {
|
||||
let widget = this.getWidgetById(id);
|
||||
if (!widget)
|
||||
throw 'Could not find widget ' + id;
|
||||
// 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
|
||||
return widget.set_value(value);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* @throws Error If the widget cannot be found or it does not have a set_value() function
|
||||
*/
|
||||
et2_container.prototype.getValueById = function (id) {
|
||||
var widget = this.getWidgetById(id);
|
||||
getValueById(id) {
|
||||
let widget = this.getWidgetById(id);
|
||||
if (!widget)
|
||||
throw 'Could not find widget ' + id;
|
||||
// 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
|
||||
return widget.get_value();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the value for a child widget, specified by the given ID
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
et2_container.prototype.setDisabledById = function (id, value) {
|
||||
var widget = this.getWidgetById(id);
|
||||
setDisabledById(id, value) {
|
||||
let widget = this.getWidgetById(id);
|
||||
if (!widget)
|
||||
throw 'Could not find widget ' + id;
|
||||
// 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
|
||||
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
|
||||
et2_core_widget_1.et2_register_widget(et2_container, []);
|
||||
et2_register_widget(et2_container, []);
|
||||
/**
|
||||
* Container object for not-yet supported widgets
|
||||
*
|
||||
* @augments et2_baseWidget
|
||||
*/
|
||||
var et2_placeholder = /** @class */ (function (_super) {
|
||||
__extends(et2_placeholder, _super);
|
||||
export class et2_placeholder extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_placeholder(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_placeholder._attributes, _child || {})) || this;
|
||||
_this.visible = false;
|
||||
_this.attrNodes = {};
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_placeholder._attributes, _child || {}));
|
||||
this.visible = false;
|
||||
this.attrNodes = {};
|
||||
// Create the placeholder div
|
||||
_this.placeDiv = jQuery(document.createElement("span"))
|
||||
this.placeDiv = jQuery(document.createElement("span"))
|
||||
.addClass("et2_placeholder");
|
||||
var headerNode = jQuery(document.createElement("span"))
|
||||
.text(_this.getType() || "")
|
||||
.text(this.getType() || "")
|
||||
.addClass("et2_caption")
|
||||
.appendTo(_this.placeDiv);
|
||||
.appendTo(this.placeDiv);
|
||||
var attrsCntr = jQuery(document.createElement("span"))
|
||||
.appendTo(_this.placeDiv)
|
||||
.appendTo(this.placeDiv)
|
||||
.hide();
|
||||
headerNode.click(_this, function (e) {
|
||||
headerNode.click(this, function (e) {
|
||||
e.data.visible = !e.data.visible;
|
||||
if (e.data.visible) {
|
||||
attrsCntr.show();
|
||||
@ -418,30 +384,28 @@ var et2_placeholder = /** @class */ (function (_super) {
|
||||
attrsCntr.hide();
|
||||
}
|
||||
});
|
||||
for (var key in _this.options) {
|
||||
if (typeof _this.options[key] != "undefined") {
|
||||
if (typeof _this.attrNodes[key] == "undefined") {
|
||||
_this.attrNodes[key] = jQuery(document.createElement("span"))
|
||||
for (var key in this.options) {
|
||||
if (typeof this.options[key] != "undefined") {
|
||||
if (typeof this.attrNodes[key] == "undefined") {
|
||||
this.attrNodes[key] = jQuery(document.createElement("span"))
|
||||
.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]);
|
||||
return _this;
|
||||
this.setDOMNode(this.placeDiv[0]);
|
||||
}
|
||||
et2_placeholder.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value");
|
||||
};
|
||||
et2_placeholder.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.placeDiv[0]];
|
||||
};
|
||||
et2_placeholder.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
this.placeDiv = jQuery(_nodes[0]);
|
||||
};
|
||||
return et2_placeholder;
|
||||
}(et2_baseWidget));
|
||||
}
|
||||
}
|
||||
// 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
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
@ -14,11 +14,14 @@
|
||||
et2_core_DOMWidget;
|
||||
*/
|
||||
|
||||
import './et2_core_interfaces';
|
||||
import './et2_core_common';
|
||||
import {et2_IAligned, et2_IDetachedDOM} from "./et2_core_interfaces";
|
||||
import {et2_DOMWidget} from './et2_core_DOMWidget';
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
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
|
||||
@ -467,7 +470,7 @@ et2_register_widget(et2_container, []);
|
||||
*
|
||||
* @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
|
||||
@ -546,4 +549,4 @@ class et2_placeholder extends et2_baseWidget implements et2_IDetachedDOM
|
||||
}
|
||||
}
|
||||
// Register widget, but no tags
|
||||
et2_register_widget(et2_placeholder, []);
|
||||
et2_register_widget(et2_placeholder, ['placeholder', 'placeholder_ro']);
|
||||
|
@ -4,10 +4,11 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
import { app, egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
* objects inside the et2_typeDefaults object, as this instance will be shared
|
||||
* between all users of it.
|
||||
*/
|
||||
var et2_typeDefaults = {
|
||||
export var et2_typeDefaults = {
|
||||
"boolean": false,
|
||||
"string": "",
|
||||
"rawstring": "",
|
||||
@ -40,7 +41,7 @@ var et2_typeDefaults = {
|
||||
"any": null,
|
||||
"dimension": "auto"
|
||||
};
|
||||
function et2_evalBool(_val) {
|
||||
export function et2_evalBool(_val) {
|
||||
if (typeof _val == "string") {
|
||||
if (_val == "false" || _val == "0") {
|
||||
return false;
|
||||
@ -53,7 +54,7 @@ function et2_evalBool(_val) {
|
||||
* @param variable number of arguments to contact
|
||||
* @returns string
|
||||
*/
|
||||
function et2_form_name(_cname, _name) {
|
||||
export function et2_form_name(_cname, _name) {
|
||||
var parts = [];
|
||||
for (var i = 0; i < arguments.length; ++i) {
|
||||
var name = arguments[i];
|
||||
@ -75,7 +76,7 @@ function et2_form_name(_cname, _name) {
|
||||
* @param string _attr attribute name
|
||||
* @param object _widget
|
||||
*/
|
||||
function et2_checkType(_val, _type, _attr, _widget) {
|
||||
export function et2_checkType(_val, _type, _attr, _widget) {
|
||||
if (typeof _attr == "undefined") {
|
||||
_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
|
||||
* 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
|
||||
* 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
|
||||
* type default.
|
||||
*/
|
||||
function et2_validateAttrib(_id, _attrib) {
|
||||
export function et2_validateAttrib(_id, _attrib) {
|
||||
// Default ignore to false.
|
||||
if (typeof _attrib["ignore"] == "undefined") {
|
||||
_attrib["ignore"] = false;
|
||||
@ -250,7 +251,7 @@ function et2_validateAttrib(_id, _attrib) {
|
||||
/**
|
||||
* Equivalent to the PHP array_values function
|
||||
*/
|
||||
function et2_arrayValues(_arr) {
|
||||
export function et2_arrayValues(_arr) {
|
||||
var result = [];
|
||||
for (var key in _arr) {
|
||||
// @ts-ignore we check key is an integer
|
||||
@ -263,14 +264,14 @@ function et2_arrayValues(_arr) {
|
||||
/**
|
||||
* Equivalent to the PHP array_keys function
|
||||
*/
|
||||
function et2_arrayKeys(_arr) {
|
||||
export function et2_arrayKeys(_arr) {
|
||||
var result = [];
|
||||
for (var key in _arr) {
|
||||
result.push(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function et2_arrayIntKeys(_arr) {
|
||||
export function et2_arrayIntKeys(_arr) {
|
||||
var result = [];
|
||||
for (var key in _arr) {
|
||||
result.push(parseInt(key));
|
||||
@ -281,7 +282,7 @@ function et2_arrayIntKeys(_arr) {
|
||||
* Equivalent to the PHP substr function, partly take from phpjs, licensed under
|
||||
* the GPL.
|
||||
*/
|
||||
function et2_substr(str, start, len) {
|
||||
export function et2_substr(str, start, len) {
|
||||
var end = str.length;
|
||||
if (start < 0) {
|
||||
start += end;
|
||||
@ -306,7 +307,7 @@ function et2_substr(str, start, len) {
|
||||
* @param string _enclosure='"'
|
||||
* @return array
|
||||
*/
|
||||
function et2_csvSplit(_str, _num, _delimiter, _enclosure) {
|
||||
export function et2_csvSplit(_str, _num, _delimiter, _enclosure) {
|
||||
// Default the parameters
|
||||
if (typeof _str == "undefined" || _str == null) {
|
||||
_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
|
||||
*/
|
||||
function et2_activateLinks(_content) {
|
||||
export function et2_activateLinks(_content) {
|
||||
var _match = false;
|
||||
var arr = [];
|
||||
function _splitPush(_matches, _proc) {
|
||||
@ -427,7 +428,7 @@ function et2_activateLinks(_content) {
|
||||
/**
|
||||
* 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) {
|
||||
egw.debug("warn", "et2_insertLinkText called without node", _text, _node, _target);
|
||||
return;
|
||||
@ -476,7 +477,7 @@ function et2_insertLinkText(_text, _node, _target) {
|
||||
/**
|
||||
* Creates a copy of the given object (non recursive)
|
||||
*/
|
||||
function et2_cloneObject(_obj) {
|
||||
export function et2_cloneObject(_obj) {
|
||||
var result = {};
|
||||
for (var key in _obj) {
|
||||
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
|
||||
* child node.
|
||||
*/
|
||||
function et2_hasChild(_nodes, _child) {
|
||||
export function et2_hasChild(_nodes, _child) {
|
||||
for (var i = 0; i < _nodes.length; i++) {
|
||||
if (_nodes[i] == _child) {
|
||||
return true;
|
||||
@ -510,7 +511,7 @@ function et2_hasChild(_nodes, _child) {
|
||||
/**
|
||||
* Returns an "range" object with the given top position and height
|
||||
*/
|
||||
function et2_range(_top, _height) {
|
||||
export function et2_range(_top, _height) {
|
||||
return {
|
||||
"top": _top,
|
||||
"bottom": _top + _height
|
||||
@ -519,7 +520,7 @@ function et2_range(_top, _height) {
|
||||
/**
|
||||
* Returns an "area" object with the given top- and bottom position
|
||||
*/
|
||||
function et2_bounds(_top, _bottom) {
|
||||
export function et2_bounds(_top, _bottom) {
|
||||
return {
|
||||
"top": _top,
|
||||
"bottom": _bottom
|
||||
@ -528,14 +529,14 @@ function et2_bounds(_top, _bottom) {
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
function et2_rangeIntersectDir(_ar1, _ar2) {
|
||||
export function et2_rangeIntersectDir(_ar1, _ar2) {
|
||||
if (_ar1.bottom < _ar2.top) {
|
||||
return -1;
|
||||
}
|
||||
@ -547,13 +548,13 @@ function et2_rangeIntersectDir(_ar1, _ar2) {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
var res = [_ar1];
|
||||
// Check whether there is an intersection between the given ranges
|
||||
@ -575,7 +576,7 @@ function et2_rangeSubstract(_ar1, _ar2) {
|
||||
* @param {string} _str
|
||||
* @returns {string}
|
||||
*/
|
||||
function html_entity_decode(_str) {
|
||||
export function html_entity_decode(_str) {
|
||||
return _str && _str.indexOf('&') != -1 ? jQuery('<span>' + _str + '</span>').text() : _str;
|
||||
}
|
||||
//# sourceMappingURL=et2_core_common.js.map
|
@ -4,11 +4,13 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
import {app, egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
* objects inside the et2_typeDefaults object, as this instance will be shared
|
||||
* between all users of it.
|
||||
*/
|
||||
var et2_typeDefaults : object = {
|
||||
export var et2_typeDefaults : object = {
|
||||
"boolean": false,
|
||||
"string": "",
|
||||
"rawstring": "", // no html-entity decoding
|
||||
@ -46,7 +48,7 @@ var et2_typeDefaults : object = {
|
||||
"dimension": "auto"
|
||||
};
|
||||
|
||||
function et2_evalBool(_val)
|
||||
export function et2_evalBool(_val)
|
||||
{
|
||||
if (typeof _val == "string")
|
||||
{
|
||||
@ -64,7 +66,7 @@ function et2_evalBool(_val)
|
||||
* @param variable number of arguments to contact
|
||||
* @returns string
|
||||
*/
|
||||
function et2_form_name(_cname,_name)
|
||||
export function et2_form_name(_cname,_name)
|
||||
{
|
||||
var parts = [];
|
||||
for(var i=0; i < arguments.length; ++i)
|
||||
@ -89,7 +91,7 @@ function et2_form_name(_cname,_name)
|
||||
* @param string _attr attribute name
|
||||
* @param object _widget
|
||||
*/
|
||||
function et2_checkType(_val, _type, _attr, _widget)
|
||||
export function et2_checkType(_val, _type, _attr, _widget)
|
||||
{
|
||||
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
|
||||
* 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
|
||||
@ -282,7 +284,7 @@ const et2_no_init = new Object();
|
||||
* empty string, the type defaults to any and the default to the corresponding
|
||||
* type default.
|
||||
*/
|
||||
function et2_validateAttrib(_id, _attrib)
|
||||
export function et2_validateAttrib(_id, _attrib)
|
||||
{
|
||||
// Default ignore to false.
|
||||
if (typeof _attrib["ignore"] == "undefined")
|
||||
@ -333,7 +335,7 @@ function et2_validateAttrib(_id, _attrib)
|
||||
/**
|
||||
* Equivalent to the PHP array_values function
|
||||
*/
|
||||
function et2_arrayValues(_arr)
|
||||
export function et2_arrayValues(_arr)
|
||||
{
|
||||
var result = [];
|
||||
for (var key in _arr)
|
||||
@ -351,7 +353,7 @@ function et2_arrayValues(_arr)
|
||||
/**
|
||||
* Equivalent to the PHP array_keys function
|
||||
*/
|
||||
function et2_arrayKeys(_arr)
|
||||
export function et2_arrayKeys(_arr)
|
||||
{
|
||||
var result = [];
|
||||
for (var key in _arr)
|
||||
@ -362,7 +364,7 @@ function et2_arrayKeys(_arr)
|
||||
return result;
|
||||
}
|
||||
|
||||
function et2_arrayIntKeys(_arr)
|
||||
export function et2_arrayIntKeys(_arr)
|
||||
{
|
||||
var result = [];
|
||||
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
|
||||
* the GPL.
|
||||
*/
|
||||
function et2_substr (str, start, len) {
|
||||
export function et2_substr (str, start, len) {
|
||||
var end = str.length;
|
||||
|
||||
if (start < 0)
|
||||
@ -407,7 +409,7 @@ function et2_substr (str, start, len) {
|
||||
* @param string _enclosure='"'
|
||||
* @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
|
||||
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
|
||||
*/
|
||||
function et2_activateLinks(_content)
|
||||
export function et2_activateLinks(_content)
|
||||
{
|
||||
var _match = false;
|
||||
var arr = [];
|
||||
@ -572,7 +574,7 @@ function et2_activateLinks(_content)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
@ -640,7 +642,7 @@ function et2_insertLinkText(_text, _node, _target)
|
||||
/**
|
||||
* Creates a copy of the given object (non recursive)
|
||||
*/
|
||||
function et2_cloneObject(_obj)
|
||||
export function et2_cloneObject(_obj)
|
||||
{
|
||||
var result = {};
|
||||
|
||||
@ -656,7 +658,7 @@ function et2_cloneObject(_obj)
|
||||
* Returns true if the given array of nodes or their children contains the given
|
||||
* child node.
|
||||
*/
|
||||
function et2_hasChild(_nodes, _child)
|
||||
export function et2_hasChild(_nodes, _child)
|
||||
{
|
||||
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
|
||||
*/
|
||||
function et2_range(_top, _height)
|
||||
export function et2_range(_top, _height)
|
||||
{
|
||||
return {
|
||||
"top": _top,
|
||||
@ -700,7 +702,7 @@ function et2_range(_top, _height)
|
||||
/**
|
||||
* Returns an "area" object with the given top- and bottom position
|
||||
*/
|
||||
function et2_bounds(_top, _bottom)
|
||||
export function et2_bounds(_top, _bottom)
|
||||
{
|
||||
return {
|
||||
"top": _top,
|
||||
@ -711,7 +713,7 @@ function et2_bounds(_top, _bottom)
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
@ -720,7 +722,7 @@ function et2_rangeIntersect(_ar1, _ar2)
|
||||
* 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).
|
||||
*/
|
||||
function et2_rangeIntersectDir(_ar1, _ar2)
|
||||
export function et2_rangeIntersectDir(_ar1, _ar2)
|
||||
{
|
||||
if (_ar1.bottom < _ar2.top)
|
||||
{
|
||||
@ -736,7 +738,7 @@ function et2_rangeIntersectDir(_ar1, _ar2)
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@ -744,7 +746,7 @@ function et2_rangeEqual(_ar1, _ar2)
|
||||
/**
|
||||
* 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
|
||||
var res = [_ar1];
|
||||
@ -774,7 +776,7 @@ function et2_rangeSubstract(_ar1, _ar2)
|
||||
* @param {string} _str
|
||||
* @returns {string}
|
||||
*/
|
||||
function html_entity_decode(_str)
|
||||
export function html_entity_decode(_str)
|
||||
{
|
||||
return _str && _str.indexOf('&') != -1 ? jQuery('<span>'+_str+'</span>').text() : _str;
|
||||
}
|
||||
|
@ -1,33 +1,19 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Widget base class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
et2_core_inputWidget;
|
||||
*/
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
var et2_editableWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_editableWidget, _super);
|
||||
export class et2_editableWidget extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_editableWidget(_parent, _attrs, _child) {
|
||||
var _this = this;
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// 'Editable' really should be boolean for everything else to work
|
||||
if (_attrs.readonly && typeof _attrs.readonly === 'string') {
|
||||
_attrs.readonly = true;
|
||||
var toggle_readonly = _attrs.toggle_readonly;
|
||||
}
|
||||
// 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')
|
||||
_this._toggle_readonly = toggle_readonly;
|
||||
return _this;
|
||||
this._toggle_readonly = toggle_readonly;
|
||||
}
|
||||
et2_editableWidget.prototype.destroy = function () {
|
||||
var node = this.getInputNode();
|
||||
destroy() {
|
||||
let node = this.getInputNode();
|
||||
if (node) {
|
||||
jQuery(node).off('.et2_editableWidget');
|
||||
}
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
super.destroy();
|
||||
}
|
||||
/**
|
||||
* Load the validation errors from the server
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
et2_editableWidget.prototype.transformAttributes = function (_attrs) {
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
};
|
||||
et2_editableWidget.prototype.attachToDOM = function () {
|
||||
var res = _super.prototype.attachToDOM.call(this);
|
||||
var node = this.getDOMNode();
|
||||
transformAttributes(_attrs) {
|
||||
super.transformAttributes(_attrs);
|
||||
}
|
||||
attachToDOM() {
|
||||
let res = super.attachToDOM();
|
||||
let node = this.getDOMNode();
|
||||
if (node && this._toggle_readonly) {
|
||||
jQuery(node)
|
||||
.off('.et2_editableWidget')
|
||||
@ -83,10 +66,10 @@ var et2_editableWidget = /** @class */ (function (_super) {
|
||||
jQuery(node).addClass('et2_editable_readonly');
|
||||
}
|
||||
return res;
|
||||
};
|
||||
et2_editableWidget.prototype.detatchFromDOM = function () {
|
||||
_super.prototype.detatchFromDOM.call(this);
|
||||
};
|
||||
}
|
||||
detatchFromDOM() {
|
||||
super.detatchFromDOM();
|
||||
}
|
||||
/**
|
||||
* Handle double click
|
||||
*
|
||||
@ -94,7 +77,7 @@ var et2_editableWidget = /** @class */ (function (_super) {
|
||||
*
|
||||
* @param {DOMNode} _node
|
||||
*/
|
||||
et2_editableWidget.prototype.dblclick = function (_node) {
|
||||
dblclick(_node) {
|
||||
// Turn off readonly
|
||||
this.set_readonly(false);
|
||||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* User clicked somewhere else, save and turn back to readonly
|
||||
*
|
||||
* @param {DOMNode} _node Body node
|
||||
* @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 oldValue = this._oldValue;
|
||||
// Change back to readonly
|
||||
@ -132,7 +115,7 @@ var et2_editableWidget = /** @class */ (function (_super) {
|
||||
this.set_value(value);
|
||||
return this.getInstanceManager().submit();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Called whenever the template gets submitted.
|
||||
* 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.
|
||||
* Listeners may change these values before they get submitted.
|
||||
*/
|
||||
et2_editableWidget.prototype.submit = function (_values) {
|
||||
submit(_values) {
|
||||
if (this.options.readonly) {
|
||||
// Not currently editing, just continue on
|
||||
return true;
|
||||
@ -157,8 +140,9 @@ var et2_editableWidget = /** @class */ (function (_super) {
|
||||
}, this, true, this).sendRequest();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
et2_editableWidget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_editableWidget._attributes = {
|
||||
readonly: {
|
||||
name: "readonly",
|
||||
type: "string",
|
||||
@ -189,8 +173,5 @@ var et2_editableWidget = /** @class */ (function (_super) {
|
||||
description: "Set height for widget while in edit mode",
|
||||
type: "string"
|
||||
}
|
||||
};
|
||||
return et2_editableWidget;
|
||||
}(et2_core_inputWidget_1.et2_inputWidget));
|
||||
exports.et2_editableWidget = et2_editableWidget;
|
||||
};
|
||||
//# sourceMappingURL=et2_core_editableWidget.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
*/
|
||||
|
||||
@ -15,6 +15,9 @@
|
||||
import {et2_inputWidget} from "./et2_core_inputWidget";
|
||||
import {WidgetConfig} from "./et2_core_widget";
|
||||
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
|
||||
|
@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS code for implementing inheritance with attributes
|
||||
*
|
||||
@ -8,16 +7,13 @@
|
||||
* @link: https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ClassWithAttributes = void 0;
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
*/
|
||||
require("../jsapi/egw_global");
|
||||
require("et2_core_common");
|
||||
var ClassWithAttributes = /** @class */ (function () {
|
||||
function ClassWithAttributes() {
|
||||
}
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
import { et2_checkType, et2_no_init, et2_validateAttrib } from "./et2_core_common";
|
||||
import { et2_implements_registry } from "./et2_core_interfaces";
|
||||
export class ClassWithAttributes {
|
||||
/**
|
||||
* Returns the value of the given attribute. If the property does not
|
||||
* exist, an error message is issued.
|
||||
@ -25,7 +21,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
* @param {string} _name
|
||||
* @return {*}
|
||||
*/
|
||||
ClassWithAttributes.prototype.getAttribute = function (_name) {
|
||||
getAttribute(_name) {
|
||||
if (typeof this.attributes[_name] != "undefined" &&
|
||||
!this.attributes[_name].ignore) {
|
||||
if (typeof this["get_" + _name] == "function") {
|
||||
@ -38,7 +34,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
else {
|
||||
egw.debug("error", this, "Attribute '" + _name + "' does not exist!");
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The setAttribute function sets the attribute with the given name to
|
||||
* the given value. _override defines, whether this[_name] will be set,
|
||||
@ -49,7 +45,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
* @param {*} _value
|
||||
* @param {boolean} _override
|
||||
*/
|
||||
ClassWithAttributes.prototype.setAttribute = function (_name, _value, _override) {
|
||||
setAttribute(_name, _value, _override) {
|
||||
if (typeof this.attributes[_name] != "undefined") {
|
||||
if (!this.attributes[_name].ignore) {
|
||||
if (typeof _override == "undefined") {
|
||||
@ -67,7 +63,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
else {
|
||||
egw.debug("warn", this, "Attribute '" + _name + "' does not exist!");
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* generateAttributeSet sanitizes the given associative array of attributes
|
||||
* (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.
|
||||
*/
|
||||
ClassWithAttributes.generateAttributeSet = function (widget, _attrs) {
|
||||
static generateAttributeSet(widget, _attrs) {
|
||||
// Sanity check and validation
|
||||
for (var key in _attrs) {
|
||||
if (typeof widget[key] != "undefined") {
|
||||
@ -101,7 +97,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
return _attrs;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The initAttributes function sets the attributes to their default
|
||||
* 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.
|
||||
*/
|
||||
ClassWithAttributes.prototype.initAttributes = function (_attrs) {
|
||||
initAttributes(_attrs) {
|
||||
for (var key in _attrs) {
|
||||
if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) {
|
||||
this.setAttribute(key, _attrs[key], false);
|
||||
}
|
||||
}
|
||||
};
|
||||
ClassWithAttributes.buildAttributes = function (class_prototype) {
|
||||
var class_tree = [];
|
||||
var attributes = {};
|
||||
var n = 0;
|
||||
}
|
||||
static buildAttributes(class_prototype) {
|
||||
let class_tree = [];
|
||||
let attributes = {};
|
||||
let n = 0;
|
||||
do {
|
||||
n++;
|
||||
class_tree.push(class_prototype);
|
||||
class_prototype = Object.getPrototypeOf(class_prototype);
|
||||
} 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);
|
||||
}
|
||||
return attributes;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Extend current _attributes with the one from the parent class
|
||||
*
|
||||
@ -139,7 +135,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
* @param _attributes
|
||||
* @param _parent
|
||||
*/
|
||||
ClassWithAttributes.extendAttributes = function (_parent, _attributes) {
|
||||
static extendAttributes(_parent, _attributes) {
|
||||
function _copyMerge(_new, _old) {
|
||||
var result = {};
|
||||
// Copy the new object
|
||||
@ -172,7 +168,7 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
et2_validateAttrib(key, attributes[key]);
|
||||
}
|
||||
return attributes;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The implements function can be used to check whether the object
|
||||
* implements the given interface.
|
||||
@ -183,25 +179,23 @@ var ClassWithAttributes = /** @class */ (function () {
|
||||
*
|
||||
* @param _iface name of interface to check
|
||||
*/
|
||||
ClassWithAttributes.prototype.implements = function (_iface_name) {
|
||||
if (typeof window['implements_' + _iface_name] === 'function' &&
|
||||
window['implements_' + _iface_name](this)) {
|
||||
implements(_iface_name) {
|
||||
if (typeof et2_implements_registry[_iface_name] === 'function' &&
|
||||
et2_implements_registry[_iface_name](this)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
ClassWithAttributes.prototype.instanceOf = function (_class_or_interfacename) {
|
||||
instanceOf(_class_or_interfacename) {
|
||||
if (typeof _class_or_interfacename === 'string') {
|
||||
return this.implements(_class_or_interfacename);
|
||||
}
|
||||
return this instanceof _class_or_interfacename;
|
||||
};
|
||||
return ClassWithAttributes;
|
||||
}());
|
||||
exports.ClassWithAttributes = ClassWithAttributes;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_core_inheritance.js.map
|
@ -12,8 +12,9 @@
|
||||
et2_core_common;
|
||||
*/
|
||||
|
||||
import '../jsapi/egw_global';
|
||||
import 'et2_core_common';
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
import {et2_checkType, et2_no_init, et2_validateAttrib} from "./et2_core_common";
|
||||
import {et2_implements_registry} from "./et2_core_interfaces";
|
||||
|
||||
export class ClassWithAttributes
|
||||
{
|
||||
@ -245,8 +246,8 @@ export class ClassWithAttributes
|
||||
*/
|
||||
implements (_iface_name : string)
|
||||
{
|
||||
if (typeof window['implements_'+_iface_name] === 'function' &&
|
||||
window['implements_'+_iface_name](this))
|
||||
if (typeof et2_implements_registry[_iface_name] === 'function' &&
|
||||
et2_implements_registry[_iface_name](this))
|
||||
{
|
||||
return true
|
||||
}
|
||||
|
@ -1,79 +1,61 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Widget base class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_interfaces;
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
require("./et2_core_common");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
import { et2_no_init } from "./et2_core_common";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_valueWidget } from './et2_core_valueWidget';
|
||||
import { et2_compileLegacyJS } from "./et2_core_legacyJSFunctions";
|
||||
/**
|
||||
* et2_inputWidget derrives from et2_simpleWidget and implements the IInput
|
||||
* interface. When derriving from this class, call setDOMNode with an input
|
||||
* DOMNode.
|
||||
*/
|
||||
var et2_inputWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_inputWidget, _super);
|
||||
export class et2_inputWidget extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_inputWidget(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// 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
|
||||
_this._oldValue = et2_no_init;
|
||||
_this._labelContainer = null;
|
||||
return _this;
|
||||
this._oldValue = et2_no_init;
|
||||
this._labelContainer = null;
|
||||
}
|
||||
et2_inputWidget.prototype.destroy = function () {
|
||||
destroy() {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
jQuery(node).unbind("change.et2_inputWidget");
|
||||
jQuery(node).unbind("focus");
|
||||
}
|
||||
_super.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
this._labelContainer = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Make sure dirty flag is properly set
|
||||
*/
|
||||
et2_inputWidget.prototype.doLoadingFinished = function () {
|
||||
var result = _super.prototype.doLoadingFinished.call(this);
|
||||
doLoadingFinished() {
|
||||
let result = super.doLoadingFinished();
|
||||
this.resetDirty();
|
||||
return result;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Load the validation errors from the server
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
et2_inputWidget.prototype.transformAttributes = function (_attrs) {
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
transformAttributes(_attrs) {
|
||||
super.transformAttributes(_attrs);
|
||||
// Check whether an validation error entry exists
|
||||
if (this.id && this.getArrayMgr("validation_errors")) {
|
||||
var val = this.getArrayMgr("validation_errors").getEntry(this.id);
|
||||
@ -81,8 +63,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
_attrs["validation_error"] = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_inputWidget.prototype.attachToDOM = function () {
|
||||
}
|
||||
attachToDOM() {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
jQuery(node)
|
||||
@ -94,17 +76,17 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
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()).validator();
|
||||
};
|
||||
et2_inputWidget.prototype.detatchFromDOM = function () {
|
||||
}
|
||||
detatchFromDOM() {
|
||||
// if(this.getInputNode()) {
|
||||
// jQuery(this.getInputNode()).data("validator").destroy();
|
||||
// }
|
||||
_super.prototype.detachFromDOM.call(this);
|
||||
};
|
||||
et2_inputWidget.prototype.change = function (_node, _widget, _value) {
|
||||
super.detachFromDOM();
|
||||
}
|
||||
change(_node, _widget, _value) {
|
||||
var messages = [];
|
||||
var valid = this.isValid(messages);
|
||||
// Passing false will clear any set messages
|
||||
@ -122,8 +104,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
};
|
||||
et2_inputWidget.prototype.focus = function (_node) {
|
||||
}
|
||||
focus(_node) {
|
||||
if (typeof this.options.onfocus == 'function') {
|
||||
// Make sure function gets a reference to the widget
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
@ -131,7 +113,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
args.push(this);
|
||||
return this.options.onfocus.apply(this, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_inputWidget.prototype.set_value = function (_value) {
|
||||
set_value(_value) {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
jQuery(node).val(_value);
|
||||
@ -148,8 +130,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
this._oldValue = _value;
|
||||
};
|
||||
et2_inputWidget.prototype.set_id = function (_value) {
|
||||
}
|
||||
set_id(_value) {
|
||||
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
|
||||
@ -166,8 +148,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
node.removeAttribute("name");
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_inputWidget.prototype.set_needed = function (_value) {
|
||||
}
|
||||
set_needed(_value) {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
if (_value && !this.options.readonly) {
|
||||
@ -177,8 +159,8 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
node.removeAttribute("required");
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_inputWidget.prototype.set_validation_error = function (_value) {
|
||||
}
|
||||
set_validation_error(_value) {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
if (_value === false) {
|
||||
@ -189,7 +171,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
this.showMessage(_value, "validation_error");
|
||||
jQuery(node).addClass("invalid");
|
||||
// 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') {
|
||||
widget = widget.getParent();
|
||||
}
|
||||
@ -197,31 +179,31 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
widget.activateTab(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set tab index
|
||||
*
|
||||
* @param {number} index
|
||||
*/
|
||||
et2_inputWidget.prototype.set_tabindex = function (index) {
|
||||
set_tabindex(index) {
|
||||
jQuery(this.getInputNode()).attr("tabindex", index);
|
||||
};
|
||||
et2_inputWidget.prototype.getInputNode = function () {
|
||||
}
|
||||
getInputNode() {
|
||||
return this.node;
|
||||
};
|
||||
et2_inputWidget.prototype.get_value = function () {
|
||||
}
|
||||
get_value() {
|
||||
return this.getValue();
|
||||
};
|
||||
et2_inputWidget.prototype.getValue = function () {
|
||||
}
|
||||
getValue() {
|
||||
var node = this.getInputNode();
|
||||
if (node) {
|
||||
var val = jQuery(node).val();
|
||||
return val;
|
||||
}
|
||||
return this._oldValue;
|
||||
};
|
||||
et2_inputWidget.prototype.isDirty = function () {
|
||||
var value = this.getValue();
|
||||
}
|
||||
isDirty() {
|
||||
let value = this.getValue();
|
||||
if (typeof value !== typeof this._oldValue) {
|
||||
return true;
|
||||
}
|
||||
@ -234,7 +216,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
this._oldValue.length !== value.length) {
|
||||
return true;
|
||||
}
|
||||
for (var key in this._oldValue) {
|
||||
for (let key in this._oldValue) {
|
||||
if (this._oldValue[key] !== value[key])
|
||||
return true;
|
||||
}
|
||||
@ -242,11 +224,11 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
default:
|
||||
return this._oldValue != value;
|
||||
}
|
||||
};
|
||||
et2_inputWidget.prototype.resetDirty = function () {
|
||||
}
|
||||
resetDirty() {
|
||||
this._oldValue = this.getValue();
|
||||
};
|
||||
et2_inputWidget.prototype.isValid = function (messages) {
|
||||
}
|
||||
isValid(messages) {
|
||||
var ok = true;
|
||||
// Check for required
|
||||
if (this.options && this.options.needed && !this.options.readonly && !this.disabled &&
|
||||
@ -255,7 +237,7 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Called whenever the template gets submitted. We return false if the widget
|
||||
* 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.
|
||||
* Listeners may change these values before they get submitted.
|
||||
*/
|
||||
et2_inputWidget.prototype.submit = function (_values) {
|
||||
submit(_values) {
|
||||
var messages = [];
|
||||
var valid = this.isValid(messages);
|
||||
// Passing false will clear any set messages
|
||||
this.set_validation_error(valid ? false : messages);
|
||||
return valid;
|
||||
};
|
||||
et2_inputWidget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_inputWidget._attributes = {
|
||||
"needed": {
|
||||
"name": "Required",
|
||||
"default": false,
|
||||
@ -307,8 +290,5 @@ var et2_inputWidget = /** @class */ (function (_super) {
|
||||
"default": false,
|
||||
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
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
@ -14,18 +14,24 @@
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
|
||||
import './et2_core_common';
|
||||
import {et2_no_init} from "./et2_core_common";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_widget, et2_createWidget, et2_register_widget, WidgetConfig } from "./et2_core_widget";
|
||||
import { et2_DOMWidget } from './et2_core_DOMWidget'
|
||||
import { et2_widget, WidgetConfig } from "./et2_core_widget";
|
||||
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
|
||||
* interface. When derriving from this class, call setDOMNode with an input
|
||||
* 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 = {
|
||||
"needed": {
|
||||
|
@ -4,53 +4,58 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
export var et2_implements_registry = {};
|
||||
/**
|
||||
* Checks if an object / et2_widget implements given methods
|
||||
*
|
||||
* @param obj
|
||||
* @param methods
|
||||
*/
|
||||
function implements_methods(obj, methods) {
|
||||
for (var i = 0; i < methods.length; ++i) {
|
||||
export function implements_methods(obj, methods) {
|
||||
for (let i = 0; i < methods.length; ++i) {
|
||||
if (typeof obj[methods[i]] !== 'function') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var et2_IDOMNode = "et2_IDOMNode";
|
||||
function implements_et2_IDOMNode(obj) {
|
||||
export const et2_IDOMNode = "et2_IDOMNode";
|
||||
et2_implements_registry.et2_IDOMNode = function (obj) {
|
||||
return implements_methods(obj, ["getDOMNode"]);
|
||||
}
|
||||
var et2_IInput = "et2_IInput";
|
||||
function implements_et2_IInput(obj) {
|
||||
};
|
||||
export const et2_IInputNode = "et2_IInputNode";
|
||||
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"]);
|
||||
}
|
||||
var et2_IResizeable = "et2_IResizeable";
|
||||
function implements_et2_IResizeable(obj) {
|
||||
};
|
||||
export const et2_IResizeable = "et2_IResizeable";
|
||||
et2_implements_registry.et2_IResizeable = function (obj) {
|
||||
return implements_methods(obj, ["resize"]);
|
||||
}
|
||||
var et2_IAligned = "et2_IAligned";
|
||||
function implements_et2_IAligned(obj) {
|
||||
};
|
||||
export const et2_IAligned = "et2_IAligned";
|
||||
et2_implements_registry.et2_IAligned = function (obj) {
|
||||
return implements_methods(obj, ["get_align"]);
|
||||
}
|
||||
var et2_ISubmitListener = "et2_ISubmitListener";
|
||||
function implements_et2_ISubmitListener(obj) {
|
||||
};
|
||||
export const et2_ISubmitListener = "et2_ISubmitListener";
|
||||
et2_implements_registry.et2_ISubmitListener = function (obj) {
|
||||
return implements_methods(obj, ["submit"]);
|
||||
}
|
||||
var et2_IDetachedDOM = "et2_IDetachedDOM";
|
||||
function implements_et2_IDetachedDOM(obj) {
|
||||
};
|
||||
export const et2_IDetachedDOM = "et2_IDetachedDOM";
|
||||
et2_implements_registry.et2_IDetachedDOM = function (obj) {
|
||||
return implements_methods(obj, ["getDetachedAttributes", "getDetachedNodes", "setDetachedAttributes"]);
|
||||
}
|
||||
var et2_IPrint = "et2_IPrint";
|
||||
function implements_et2_IPrint(obj) {
|
||||
};
|
||||
export const et2_IPrint = "et2_IPrint";
|
||||
et2_implements_registry.et2_IPrint = function (obj) {
|
||||
return implements_methods(obj, ["beforePrint", "afterPrint"]);
|
||||
}
|
||||
var et2_IExposable = "et2_IExposable";
|
||||
function implements_et2_IExposable(obj) {
|
||||
};
|
||||
export const et2_IExposable = "et2_IExposable";
|
||||
et2_implements_registry.et2_IExposable = function (obj) {
|
||||
return implements_methods(obj, ["getMedia"]);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=et2_core_interfaces.js.map
|
@ -4,17 +4,22 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
*
|
||||
* @param obj
|
||||
* @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)
|
||||
{
|
||||
@ -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 et2_IDOMNode
|
||||
export interface et2_IDOMNode
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
var et2_IDOMNode = "et2_IDOMNode";
|
||||
function implements_et2_IDOMNode(obj : et2_widget)
|
||||
export const et2_IDOMNode = "et2_IDOMNode";
|
||||
et2_implements_registry.et2_IDOMNode = function(obj : et2_widget)
|
||||
{
|
||||
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 et2_IInput
|
||||
export interface et2_IInput
|
||||
{
|
||||
/**
|
||||
* getValue has to return the value of the input widget
|
||||
@ -92,8 +110,8 @@ interface et2_IInput
|
||||
*/
|
||||
isValid(messages) : boolean
|
||||
}
|
||||
var et2_IInput = "et2_IInput";
|
||||
function implements_et2_IInput(obj : et2_widget)
|
||||
export const et2_IInput = "et2_IInput";
|
||||
et2_implements_registry.et2_IInput = function(obj : et2_widget)
|
||||
{
|
||||
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 et2_IResizeable
|
||||
export interface et2_IResizeable
|
||||
{
|
||||
/**
|
||||
* Called whenever the window is resized
|
||||
*/
|
||||
resize(number) : void
|
||||
}
|
||||
var et2_IResizeable = "et2_IResizeable";
|
||||
function implements_et2_IResizeable(obj : et2_widget)
|
||||
export const et2_IResizeable = "et2_IResizeable";
|
||||
et2_implements_registry.et2_IResizeable = function(obj : et2_widget)
|
||||
{
|
||||
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 et2_IAligned
|
||||
export interface et2_IAligned
|
||||
{
|
||||
get_align() : string
|
||||
}
|
||||
var et2_IAligned = "et2_IAligned";
|
||||
function implements_et2_IAligned(obj : et2_widget)
|
||||
export const et2_IAligned = "et2_IAligned";
|
||||
et2_implements_registry.et2_IAligned = function(obj : et2_widget)
|
||||
{
|
||||
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
|
||||
* the form is submitted.
|
||||
*/
|
||||
interface et2_ISubmitListener
|
||||
export interface et2_ISubmitListener
|
||||
{
|
||||
/**
|
||||
* Called whenever the template gets submitted. Return false if you want to
|
||||
@ -142,8 +160,8 @@ interface et2_ISubmitListener
|
||||
*/
|
||||
submit(_values) : void
|
||||
}
|
||||
var et2_ISubmitListener = "et2_ISubmitListener";
|
||||
function implements_et2_ISubmitListener(obj : et2_widget)
|
||||
export const et2_ISubmitListener = "et2_ISubmitListener";
|
||||
et2_implements_registry.et2_ISubmitListener = function(obj : et2_widget)
|
||||
{
|
||||
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
|
||||
* 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
|
||||
@ -182,8 +200,8 @@ interface et2_IDetachedDOM
|
||||
*/
|
||||
setDetachedAttributes(_nodes : HTMLElement[], _values : object, _data?) : void
|
||||
}
|
||||
var et2_IDetachedDOM = "et2_IDetachedDOM";
|
||||
function implements_et2_IDetachedDOM(obj : et2_widget)
|
||||
export const et2_IDetachedDOM = "et2_IDetachedDOM";
|
||||
et2_implements_registry.et2_IDetachedDOM = function(obj : et2_widget)
|
||||
{
|
||||
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 et2_IPrint
|
||||
export interface et2_IPrint
|
||||
{
|
||||
/**
|
||||
* Set up for printing
|
||||
@ -206,8 +224,8 @@ interface et2_IPrint
|
||||
*/
|
||||
afterPrint() : void
|
||||
}
|
||||
var et2_IPrint = "et2_IPrint";
|
||||
function implements_et2_IPrint(obj : et2_widget)
|
||||
export const et2_IPrint = "et2_IPrint";
|
||||
et2_implements_registry.et2_IPrint = function(obj : et2_widget)
|
||||
{
|
||||
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 et2_IExposable
|
||||
export interface et2_IExposable
|
||||
{
|
||||
/**
|
||||
* get media an array of media objects to pass to blueimp Gallery
|
||||
@ -223,8 +241,8 @@ interface et2_IExposable
|
||||
*/
|
||||
getMedia(_attrs) : void;
|
||||
}
|
||||
var et2_IExposable = "et2_IExposable";
|
||||
function implements_et2_IExposable(obj : et2_widget)
|
||||
export const et2_IExposable = "et2_IExposable";
|
||||
et2_implements_registry.et2_IExposable = function(obj : et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["getMedia"]);
|
||||
}
|
@ -4,129 +4,44 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-13
|
||||
* @version $Id: et2_core_phpExpressionCompiler.js 38256 2012-03-05 13:07:38Z igel457 $
|
||||
* @copyright EGroupware GmbH 2011-21
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
et2_interfaces;
|
||||
et2_core_common;
|
||||
*/
|
||||
|
||||
(function()
|
||||
{
|
||||
"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) {
|
||||
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);
|
||||
|
||||
_code = js_pseudo_funcs(_code, _widget);
|
||||
// Check whether _code is simply "1" -- if yes replace it accordingly
|
||||
if (_code === '1')
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (_code.indexOf("$") >= 0 || _code.indexOf("@") >= 0) {
|
||||
// Get the content array manager for the widget
|
||||
var mgr = _widget.getArrayMgr("content");
|
||||
if (mgr)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (_code.indexOf("(") === -1) {
|
||||
var parts = _code.split(".");
|
||||
var existing_func = parts.pop();
|
||||
var parent = _widget.egw().window;
|
||||
@ -143,49 +58,92 @@
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;});
|
||||
}
|
||||
|
||||
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) {
|
||||
return function (ev) {
|
||||
// Dump the executed code for debugging
|
||||
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);
|
||||
}
|
||||
// Return the result of the called function
|
||||
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
|
188
api/js/etemplate/et2_core_legacyJSFunctions.ts
Normal file
188
api/js/etemplate/et2_core_legacyJSFunctions.ts
Normal 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;
|
||||
}
|
@ -4,400 +4,15 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
*/
|
||||
|
||||
(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) + ";";
|
||||
}
|
||||
|
||||
/**
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* Function which compiles the given PHP string to a JS function which can be
|
||||
* easily executed.
|
||||
*
|
||||
@ -406,49 +21,315 @@
|
||||
* The parameters have to be passed to the resulting JS function in the same
|
||||
* order.
|
||||
*/
|
||||
this.et2_compilePHPExpression = function(_expr, _vars)
|
||||
{
|
||||
if (typeof _vars == "undefined")
|
||||
{
|
||||
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) {
|
||||
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; };
|
||||
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++)
|
||||
{
|
||||
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 = 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
|
||||
/*(function () {
|
||||
var row = 10;
|
||||
@ -469,4 +350,4 @@
|
||||
test("\\\\", "\\");
|
||||
test("", "");
|
||||
})();*/
|
||||
|
||||
//# sourceMappingURL=et2_core_phpExpressionCompiler.js.map
|
467
api/js/etemplate/et2_core_phpExpressionCompiler.ts
Normal file
467
api/js/etemplate/et2_core_phpExpressionCompiler.ts
Normal 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("", "");
|
||||
})();*/
|
||||
|
@ -1,66 +1,46 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS widget class with value attribute and auto loading
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
require("./et2_core_common");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_baseWidget } from './et2_core_baseWidget';
|
||||
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
|
||||
* the "value" attribute and automatically loads it from the "content" array
|
||||
* after loading from XML.
|
||||
*/
|
||||
var et2_valueWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_valueWidget, _super);
|
||||
export class et2_valueWidget extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_valueWidget(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_valueWidget._attributes, _child || {})) || this;
|
||||
_this.label = '';
|
||||
_this._labelContainer = null;
|
||||
return _this;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_valueWidget._attributes, _child || {}));
|
||||
this.label = '';
|
||||
this._labelContainer = null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param _attrs
|
||||
*/
|
||||
et2_valueWidget.prototype.transformAttributes = function (_attrs) {
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
transformAttributes(_attrs) {
|
||||
super.transformAttributes(_attrs);
|
||||
if (this.id) {
|
||||
// Set the value for this element
|
||||
var contentMgr = this.getArrayMgr("content");
|
||||
if (contentMgr != null) {
|
||||
var val = contentMgr.getEntry(this.id, false, true);
|
||||
let val = contentMgr.getEntry(this.id, false, true);
|
||||
if (val !== null) {
|
||||
_attrs["value"] = val;
|
||||
}
|
||||
@ -70,8 +50,8 @@ var et2_valueWidget = /** @class */ (function (_super) {
|
||||
_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
|
||||
if (_value == this.label) {
|
||||
return;
|
||||
@ -113,19 +93,20 @@ var et2_valueWidget = /** @class */ (function (_super) {
|
||||
this.getSurroundings().update();
|
||||
// Copy the given value
|
||||
this.label = _value;
|
||||
};
|
||||
et2_valueWidget.prototype.get_value = function () {
|
||||
}
|
||||
get_value() {
|
||||
return this.value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set value of widget
|
||||
*
|
||||
* @param {string} _value value to set
|
||||
*/
|
||||
et2_valueWidget.prototype.set_value = function (_value) {
|
||||
set_value(_value) {
|
||||
this.value = _value;
|
||||
};
|
||||
et2_valueWidget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_valueWidget._attributes = {
|
||||
"label": {
|
||||
"name": "Label",
|
||||
"default": "",
|
||||
@ -139,8 +120,5 @@ var et2_valueWidget = /** @class */ (function (_super) {
|
||||
"type": "rawstring",
|
||||
"default": et2_no_init
|
||||
}
|
||||
};
|
||||
return et2_valueWidget;
|
||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||
exports.et2_valueWidget = et2_valueWidget;
|
||||
};
|
||||
//# sourceMappingURL=et2_core_valueWidget.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -16,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import { et2_baseWidget } from './et2_core_baseWidget'
|
||||
import './et2_core_common';
|
||||
import {WidgetConfig} from "./et2_core_widget";
|
||||
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
|
||||
|
@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Widget base class
|
||||
*
|
||||
@ -8,21 +7,6 @@
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
jsapi.egw;
|
||||
et2_core_xml;
|
||||
@ -30,14 +14,18 @@ exports.et2_widget = exports.et2_createWidget = exports.et2_register_widget = vo
|
||||
et2_core_inheritance;
|
||||
et2_core_arrayMgr;
|
||||
*/
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_arrayMgr_1 = require("./et2_core_arrayMgr");
|
||||
import { ClassWithAttributes } from './et2_core_inheritance';
|
||||
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
|
||||
* constructor.
|
||||
*/
|
||||
var et2_registry = {};
|
||||
var et2_attribute_registry = {};
|
||||
export var et2_registry = {};
|
||||
export var et2_attribute_registry = {};
|
||||
/**
|
||||
* Registers the widget class defined by the given constructor, registers all its class attributes, and associates it
|
||||
* with the types in the _types array.
|
||||
@ -45,9 +33,9 @@ var et2_attribute_registry = {};
|
||||
* @param {function} _constructor constructor
|
||||
* @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";
|
||||
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
|
||||
for (var i = 0; i < _types.length; i++) {
|
||||
var type = _types[i].toLowerCase();
|
||||
@ -60,7 +48,6 @@ function et2_register_widget(_constructor, _types) {
|
||||
et2_registry[type] = _constructor;
|
||||
}
|
||||
}
|
||||
exports.et2_register_widget = et2_register_widget;
|
||||
/**
|
||||
* 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
|
||||
@ -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
|
||||
* to a parent using the addChild or insertChild method.
|
||||
*/
|
||||
function et2_createWidget(_name, _attrs, _parent) {
|
||||
export function et2_createWidget(_name, _attrs, _parent) {
|
||||
"use strict";
|
||||
if (typeof _attrs == "undefined") {
|
||||
_attrs = {};
|
||||
@ -92,24 +79,21 @@ function et2_createWidget(_name, _attrs, _parent) {
|
||||
typeof _attrs["readonly"] == "undefined" ? false : _attrs["readonly"];
|
||||
// Get the constructor - if the widget is readonly, use the special "_ro"
|
||||
// constructor if it is available
|
||||
var constructor = typeof et2_registry[nodeName] == "undefined" ?
|
||||
et2_placeholder : et2_registry[nodeName];
|
||||
let constructor = et2_registry[typeof et2_registry[nodeName] == "undefined" ? 'placeholder' : nodeName];
|
||||
if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined") {
|
||||
constructor = et2_registry[nodeName + "_ro"];
|
||||
}
|
||||
// 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
|
||||
return new constructor(_parent, _attrs);
|
||||
}
|
||||
exports.et2_createWidget = et2_createWidget;
|
||||
/**
|
||||
* The et2 widget base class.
|
||||
*
|
||||
* @augments ClassWithAttributes
|
||||
*/
|
||||
var et2_widget = /** @class */ (function (_super) {
|
||||
__extends(et2_widget, _super);
|
||||
export class et2_widget extends ClassWithAttributes {
|
||||
/**
|
||||
* Widget constructor
|
||||
*
|
||||
@ -123,17 +107,17 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
* @param _attrs is an associative array of attributes.
|
||||
* @param _child attributes object from the child
|
||||
*/
|
||||
function et2_widget(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._children = [];
|
||||
_this._mgrs = {};
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(); // because we in the top of the widget hierarchy
|
||||
this._children = [];
|
||||
this._mgrs = {};
|
||||
/**
|
||||
* This is used and therefore it we can not (yet) make it private
|
||||
*
|
||||
* @deprecated use this.getInstanceMgr()
|
||||
*/
|
||||
_this._inst = null;
|
||||
_this.attributes = et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_widget._attributes, _child || {});
|
||||
this._inst = null;
|
||||
this.attributes = ClassWithAttributes.extendAttributes(et2_widget._attributes, _child || {});
|
||||
// Check whether all attributes are available
|
||||
if (typeof _parent == "undefined") {
|
||||
_parent = null;
|
||||
@ -145,33 +129,32 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
jQuery.extend(_attrs, _attrs.attributes);
|
||||
}
|
||||
// Initialize all important parameters
|
||||
_this._mgrs = {};
|
||||
_this._inst = null;
|
||||
_this._children = [];
|
||||
_this._type = _attrs["type"];
|
||||
_this.id = _attrs["id"];
|
||||
this._mgrs = {};
|
||||
this._inst = null;
|
||||
this._children = [];
|
||||
this._type = _attrs["type"];
|
||||
this.id = _attrs["id"];
|
||||
// Add this widget to the given parent widget
|
||||
if (_parent != null) {
|
||||
_parent.addChild(_this);
|
||||
_parent.addChild(this);
|
||||
}
|
||||
// The supported widget classes array defines a whitelist for all widget
|
||||
// classes or interfaces child widgets have to support.
|
||||
_this.supportedWidgetClasses = [et2_widget];
|
||||
this.supportedWidgetClasses = [et2_widget];
|
||||
if (_attrs["id"]) {
|
||||
// Create a namespace for this object
|
||||
if (_this._createNamespace()) {
|
||||
_this.checkCreateNamespace(_attrs);
|
||||
if (this._createNamespace()) {
|
||||
this.checkCreateNamespace(_attrs);
|
||||
}
|
||||
}
|
||||
if (_this.id) {
|
||||
if (this.id) {
|
||||
//this.id = this.id.replace(/\[/g,'[').replace(/]/g,']');
|
||||
}
|
||||
// Add all attributes hidden in the content arrays to the attributes
|
||||
// parameter
|
||||
_this.transformAttributes(_attrs);
|
||||
this.transformAttributes(_attrs);
|
||||
// Create a local copy of the options object
|
||||
_this.options = et2_cloneObject(_attrs);
|
||||
return _this;
|
||||
this.options = et2_cloneObject(_attrs);
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* created.
|
||||
*/
|
||||
et2_widget.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Call the destructor of all children
|
||||
for (var i = this._children.length - 1; i >= 0; i--) {
|
||||
this._children[i].destroy();
|
||||
@ -196,13 +179,13 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
this._mgrs[key].destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_widget.prototype.getType = function () {
|
||||
}
|
||||
getType() {
|
||||
return this._type;
|
||||
};
|
||||
et2_widget.prototype.setType = function (_type) {
|
||||
}
|
||||
setType(_type) {
|
||||
this._type = _type;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates a copy of this widget. The parameters given are passed to the
|
||||
* 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
|
||||
*/
|
||||
et2_widget.prototype.clone = function (_parent) {
|
||||
clone(_parent) {
|
||||
// Default _parent to null
|
||||
if (typeof _parent == "undefined") {
|
||||
_parent = null;
|
||||
@ -220,8 +203,8 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
// Assign this element to the copy
|
||||
copy.assign(this);
|
||||
return copy;
|
||||
};
|
||||
et2_widget.prototype.assign = function (_obj) {
|
||||
}
|
||||
assign(_obj) {
|
||||
if (typeof _obj._children == "undefined") {
|
||||
this.egw().debug("log", "Foo!");
|
||||
}
|
||||
@ -231,39 +214,39 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
}
|
||||
// Copy a reference to the content array manager
|
||||
this.setArrayMgrs(_obj.mgrs);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the parent widget of this widget
|
||||
*/
|
||||
et2_widget.prototype.getParent = function () {
|
||||
getParent() {
|
||||
return this._parent;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the list of children of this widget.
|
||||
*/
|
||||
et2_widget.prototype.getChildren = function () {
|
||||
getChildren() {
|
||||
return this._children;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the base widget
|
||||
*/
|
||||
et2_widget.prototype.getRoot = function () {
|
||||
getRoot() {
|
||||
if (this._parent != null) {
|
||||
return this._parent.getRoot();
|
||||
}
|
||||
else {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Inserts an child at the end of the list.
|
||||
*
|
||||
* @param _node is the node which should be added. It has to be an instance
|
||||
* of et2_widget
|
||||
*/
|
||||
et2_widget.prototype.addChild = function (_node) {
|
||||
addChild(_node) {
|
||||
this.insertChild(_node, this._children.length);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Inserts a child at the given index.
|
||||
*
|
||||
@ -271,7 +254,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
* of et2_widget
|
||||
* @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.
|
||||
if (this.isOfSupportedWidgetClass(_node)) {
|
||||
// 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);
|
||||
// throw("Widget is not supported by this widget class!");
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Removes the child but does not destroy it.
|
||||
*
|
||||
* @param {et2_widget} _node child to remove
|
||||
*/
|
||||
et2_widget.prototype.removeChild = function (_node) {
|
||||
removeChild(_node) {
|
||||
// Retrieve the child from the child list
|
||||
var idx = this._children.indexOf(_node);
|
||||
if (idx >= 0) {
|
||||
@ -299,13 +282,13 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
_node._parent = null;
|
||||
this._children.splice(idx, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Searches an element by id in the tree, descending into the child levels.
|
||||
*
|
||||
* @param _id is the id you're searching for
|
||||
*/
|
||||
et2_widget.prototype.getWidgetById = function (_id) {
|
||||
getWidgetById(_id) {
|
||||
if (this.id == _id) {
|
||||
return this;
|
||||
}
|
||||
@ -318,7 +301,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
for (var i = 0; i < ids.length && widget !== null; i++) {
|
||||
widget = widget.getWidgetById(ids[i]);
|
||||
@ -326,7 +309,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
return widget;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* the elements have to be instanceOf.
|
||||
*/
|
||||
et2_widget.prototype.iterateOver = function (_callback, _context, _type) {
|
||||
iterateOver(_callback, _context, _type) {
|
||||
if (typeof _type == "undefined") {
|
||||
_type = et2_widget;
|
||||
}
|
||||
@ -345,7 +328,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
for (var i = 0; i < this._children.length; i++) {
|
||||
this._children[i].iterateOver(_callback, _context, _type);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
@ -357,7 +340,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
* return this._super(inTree);
|
||||
* 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") {
|
||||
_vis = true;
|
||||
}
|
||||
@ -365,15 +348,15 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
return _vis && this._parent.isInTree(this);
|
||||
}
|
||||
return _vis;
|
||||
};
|
||||
et2_widget.prototype.isOfSupportedWidgetClass = function (_obj) {
|
||||
}
|
||||
isOfSupportedWidgetClass(_obj) {
|
||||
for (var i = 0; i < this.supportedWidgetClasses.length; i++) {
|
||||
if (_obj instanceof this.supportedWidgetClasses[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The parseXMLAttrs function takes an XML DOM attributes object
|
||||
* 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 {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
|
||||
if (typeof _attrsObj == "undefined") {
|
||||
return;
|
||||
@ -395,8 +378,8 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
var attrValue = _attrsObj[i].value;
|
||||
// Special handling for the legacy options
|
||||
if (attrName == "options" && _proto.constructor.legacyOptions && _proto.constructor.legacyOptions.length > 0) {
|
||||
var legacy = _proto.constructor.legacyOptions || [];
|
||||
var attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
|
||||
let legacy = _proto.constructor.legacyOptions || [];
|
||||
let attrs = et2_attribute_registry[Object.getPrototypeOf(_proto).constructor.name] || {};
|
||||
// Check for modifications on legacy options here. Normal modifications
|
||||
// are handled in widget constructor, but it's too late for legacy options then
|
||||
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
|
||||
}
|
||||
else {
|
||||
var attrs = et2_attribute_registry[_proto.constructor.name] || {};
|
||||
let attrs = et2_attribute_registry[_proto.constructor.name] || {};
|
||||
if (mgr != null && typeof attrs[attrName] != "undefined") {
|
||||
var attr = attrs[attrName];
|
||||
// If the attribute is marked as boolean, parse the
|
||||
@ -457,14 +440,14 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
_target[attrName] = attrValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Apply the "modifications" to the element and translate attributes marked
|
||||
* with "translate: true"
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
et2_widget.prototype.transformAttributes = function (_attrs) {
|
||||
transformAttributes(_attrs) {
|
||||
// Apply the content of the modifications array
|
||||
if (this.id) {
|
||||
if (typeof this.id != "string") {
|
||||
@ -483,30 +466,26 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loop_1 = function () {
|
||||
if (_attrs[key] && typeof this_1.attributes[key] != "undefined") {
|
||||
if (this_1.attributes[key].translate === true ||
|
||||
(this_1.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) {
|
||||
var value = _attrs[key];
|
||||
// Translate the attributes
|
||||
for (var key in _attrs) {
|
||||
if (_attrs[key] && typeof this.attributes[key] != "undefined") {
|
||||
if (this.attributes[key].translate === true ||
|
||||
(this.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) {
|
||||
let value = _attrs[key];
|
||||
// allow statustext to contain multiple translated sub-strings eg: {Firstname}.{Lastname}
|
||||
if (value.indexOf('{') !== -1) {
|
||||
var egw_1 = this_1.egw();
|
||||
const egw = this.egw();
|
||||
_attrs[key] = value.replace(/{([^}]+)}/g, function (str, p1) {
|
||||
return egw_1.lang(p1);
|
||||
return egw.lang(p1);
|
||||
});
|
||||
}
|
||||
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.
|
||||
*
|
||||
@ -521,7 +500,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
*
|
||||
* @return et2_widget
|
||||
*/
|
||||
et2_widget.prototype.createElementFromNode = function (_node, _name) {
|
||||
createElementFromNode(_node, _name) {
|
||||
var attributes = {};
|
||||
// Parse the "readonly" and "type" flag for this element here, as they
|
||||
// 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"
|
||||
// constructor if it is available
|
||||
var constructor = typeof et2_registry[_nodeName] == "undefined" ?
|
||||
et2_placeholder : et2_registry[_nodeName];
|
||||
var constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
|
||||
if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") {
|
||||
constructor = et2_registry[_nodeName + "_ro"];
|
||||
}
|
||||
// Parse the attributes from the given XML attributes object
|
||||
this.parseXMLAttrs(_node.attributes, attributes, constructor.prototype);
|
||||
// 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
|
||||
// passes the widgetType. Then it goes on loading the XML for it.
|
||||
var widget = new constructor(this, attributes);
|
||||
// Load the widget itself from XML
|
||||
widget.loadFromXML(_node);
|
||||
return widget;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Loads the widget tree from an XML node
|
||||
*
|
||||
* @param _node xml node
|
||||
*/
|
||||
et2_widget.prototype.loadFromXML = function (_node) {
|
||||
loadFromXML(_node) {
|
||||
// Load the child nodes.
|
||||
for (var i = 0; i < _node.childNodes.length; i++) {
|
||||
var node = _node.childNodes[i];
|
||||
@ -595,14 +573,14 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
// Create the new element
|
||||
this.createElementFromNode(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Called whenever textNodes are loaded from the XML tree
|
||||
*
|
||||
* @param _content
|
||||
*/
|
||||
et2_widget.prototype.loadContent = function (_content) {
|
||||
};
|
||||
loadContent(_content) {
|
||||
}
|
||||
/**
|
||||
* Called when loading the widget (sub-tree) is finished. First when this
|
||||
* 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.
|
||||
*/
|
||||
et2_widget.prototype.loadingFinished = function (promises) {
|
||||
loadingFinished(promises) {
|
||||
// Call all availble setters
|
||||
this.initAttributes(this.options);
|
||||
// Make sure promises is defined to avoid errors.
|
||||
@ -660,7 +638,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
// Fihish loading when it's finished
|
||||
result.done(jQuery.proxy(loadChildren, this));
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The initAttributes function sets the attributes to their default
|
||||
* values. The attributes are not overwritten, which means, that the
|
||||
@ -671,19 +649,19 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
et2_widget.prototype.initAttributes = function (_attrs) {
|
||||
initAttributes(_attrs) {
|
||||
for (var key in _attrs) {
|
||||
if (typeof this.attributes[key] != "undefined" && !this.attributes[key].ignore && !(_attrs[key] == undefined)) {
|
||||
var val = _attrs[key];
|
||||
// compile string values of attribute type "js" to functions
|
||||
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.setAttribute(key, val, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Does specific post-processing after the widget is loaded. Most widgets should not
|
||||
* 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}
|
||||
*/
|
||||
et2_widget.prototype.doLoadingFinished = function () {
|
||||
doLoadingFinished() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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"
|
||||
* widget using the setApiInstance function.
|
||||
*/
|
||||
et2_widget.prototype.egw = function () {
|
||||
egw() {
|
||||
// The _egw property is not set
|
||||
if (typeof this._egw === 'undefined') {
|
||||
if (this._parent != null) {
|
||||
@ -719,31 +697,31 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
return egw('phpgwapi', wnd);
|
||||
}
|
||||
return this._egw;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the client side api instance. It can be retrieved by the widget tree
|
||||
* by using the "egw()" function.
|
||||
*
|
||||
* @param {IegwAppLocal} _egw egw object to set
|
||||
*/
|
||||
et2_widget.prototype.setApiInstance = function (_egw) {
|
||||
setApiInstance(_egw) {
|
||||
this._egw = _egw;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets all array manager objects - this function can be used to set the
|
||||
* root array managers of the container object.
|
||||
*
|
||||
* @param {object} _mgrs
|
||||
*/
|
||||
et2_widget.prototype.setArrayMgrs = function (_mgrs) {
|
||||
setArrayMgrs(_mgrs) {
|
||||
this._mgrs = et2_cloneObject(_mgrs);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns an associative array containing the top-most array managers.
|
||||
*
|
||||
* @param _mgrs is used internally and should not be supplied.
|
||||
*/
|
||||
et2_widget.prototype.getArrayMgrs = function (_mgrs) {
|
||||
getArrayMgrs(_mgrs) {
|
||||
if (typeof _mgrs == "undefined") {
|
||||
_mgrs = {};
|
||||
}
|
||||
@ -759,22 +737,22 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
this._parent.getArrayMgrs(_mgrs);
|
||||
}
|
||||
return _mgrs;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the array manager for the given part
|
||||
*
|
||||
* @param {string} _part which array mgr to set
|
||||
* @param {object} _mgr
|
||||
*/
|
||||
et2_widget.prototype.setArrayMgr = function (_part, _mgr) {
|
||||
setArrayMgr(_part, _mgr) {
|
||||
this._mgrs[_part] = _mgr;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the array manager object for the given part
|
||||
*
|
||||
* @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") {
|
||||
return this._mgrs[managed_array_type];
|
||||
}
|
||||
@ -782,7 +760,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
return this._parent.getArrayMgr(managed_array_type);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
@ -790,7 +768,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
*
|
||||
* Constructor attributes are passed in case a child needs to make decisions
|
||||
*/
|
||||
et2_widget.prototype.checkCreateNamespace = function (_attrs) {
|
||||
checkCreateNamespace(_attrs) {
|
||||
// Get the content manager
|
||||
var mgrs = this.getArrayMgrs();
|
||||
for (var key in mgrs) {
|
||||
@ -813,7 +791,7 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
delete (this._mgrs[key]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Widgets that do support a namespace should override and return true.
|
||||
*
|
||||
@ -822,23 +800,23 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
et2_widget.prototype._createNamespace = function () {
|
||||
_createNamespace() {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the instance manager object (of type etemplate2, see etemplate2.js)
|
||||
*
|
||||
* @param {etemplate2} _inst
|
||||
*/
|
||||
et2_widget.prototype.setInstanceManager = function (_inst) {
|
||||
setInstanceManager(_inst) {
|
||||
this._inst = _inst;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the instance manager
|
||||
*
|
||||
* @return {etemplate2}
|
||||
*/
|
||||
et2_widget.prototype.getInstanceManager = function () {
|
||||
getInstanceManager() {
|
||||
if (this._inst != null) {
|
||||
return this._inst;
|
||||
}
|
||||
@ -846,19 +824,20 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
return this._parent.getInstanceManager();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the path into the data array. By default, array manager takes care of
|
||||
* this, but some extensions need to override this
|
||||
*/
|
||||
et2_widget.prototype.getPath = function () {
|
||||
getPath() {
|
||||
var path = this.getArrayMgr("content").getPath();
|
||||
// Prevent namespaced widgets with value from going an extra layer deep
|
||||
if (this.id && this._createNamespace() && path[path.length - 1] == this.id)
|
||||
path.pop();
|
||||
return path;
|
||||
};
|
||||
et2_widget._attributes = {
|
||||
}
|
||||
}
|
||||
et2_widget._attributes = {
|
||||
"id": {
|
||||
"name": "ID",
|
||||
"type": "string",
|
||||
@ -903,11 +882,8 @@ var et2_widget = /** @class */ (function (_super) {
|
||||
"ignore": true,
|
||||
"description": "Object of widget attributes"
|
||||
}
|
||||
};
|
||||
// Set the legacyOptions array to the names of the properties the "options"
|
||||
// attribute defines.
|
||||
et2_widget.legacyOptions = [];
|
||||
return et2_widget;
|
||||
}(et2_core_inheritance_1.ClassWithAttributes));
|
||||
exports.et2_widget = et2_widget;
|
||||
};
|
||||
// Set the legacyOptions array to the names of the properties the "options"
|
||||
// attribute defines.
|
||||
et2_widget.legacyOptions = [];
|
||||
//# sourceMappingURL=et2_core_widget.js.map
|
@ -17,15 +17,21 @@
|
||||
*/
|
||||
|
||||
import {ClassWithAttributes} from './et2_core_inheritance';
|
||||
import {et2_arrayMgr, et2_readonlysArrayMgr} from "./et2_core_arrayMgr";
|
||||
import {et2_baseWidget, et2_container} from "./et2_core_baseWidget";
|
||||
import {et2_arrayMgr} from "./et2_core_arrayMgr";
|
||||
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
|
||||
* constructor.
|
||||
*/
|
||||
var et2_registry = {};
|
||||
var et2_attribute_registry = {};
|
||||
export var et2_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"
|
||||
// constructor if it is available
|
||||
var constructor = typeof et2_registry[nodeName] == "undefined" ?
|
||||
et2_placeholder : et2_registry[nodeName];
|
||||
let constructor = et2_registry[typeof et2_registry[nodeName] == "undefined" ? 'placeholder' : nodeName];
|
||||
if (readonly && typeof et2_registry[nodeName + "_ro"] != "undefined")
|
||||
{
|
||||
constructor = et2_registry[nodeName + "_ro"];
|
||||
@ -327,7 +332,7 @@ export class et2_widget extends ClassWithAttributes
|
||||
this.setArrayMgrs(_obj.mgrs);
|
||||
}
|
||||
|
||||
private _parent: et2_widget;
|
||||
_parent: et2_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"
|
||||
// constructor if it is available
|
||||
var constructor = typeof et2_registry[_nodeName] == "undefined" ?
|
||||
et2_placeholder : et2_registry[_nodeName];
|
||||
var constructor = et2_registry[typeof et2_registry[_nodeName] == "undefined" ? 'placeholder' : _nodeName];
|
||||
if (readonly === true && typeof et2_registry[_nodeName + "_ro"] != "undefined") {
|
||||
constructor = et2_registry[_nodeName + "_ro"];
|
||||
}
|
||||
@ -838,7 +842,7 @@ export class et2_widget extends ClassWithAttributes
|
||||
// compile string values of attribute type "js" to functions
|
||||
if (this.attributes[key].type == 'js' && typeof _attrs[key] == 'string') {
|
||||
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.setAttribute(key, val, false);
|
||||
|
@ -4,9 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* Loads the given URL asynchronously from the server
|
||||
*
|
||||
@ -18,12 +19,12 @@
|
||||
* @param {object} _context for _callback
|
||||
* @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") {
|
||||
_context = null;
|
||||
}
|
||||
// use window object from main window with same algorithm as for the template cache
|
||||
var win;
|
||||
let win;
|
||||
try {
|
||||
if (opener && opener.etemplate2) {
|
||||
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
|
||||
_tagName = _tagName.toLowerCase();
|
||||
var result = [];
|
||||
for (var i = 0; i < _node.childNodes.length; i++) {
|
||||
let result = [];
|
||||
for (let i = 0; i < _node.childNodes.length; i++) {
|
||||
if (_tagName == _node.childNodes[i].nodeName.toLowerCase()) {
|
||||
result.push(_node.childNodes[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function et2_filteredNodeIterator(_node, _callback, _context) {
|
||||
for (var i = 0; i < _node.childNodes.length; i++) {
|
||||
var node = _node.childNodes[i];
|
||||
var nodeName = node.nodeName.toLowerCase();
|
||||
export function et2_filteredNodeIterator(_node, _callback, _context) {
|
||||
for (let i = 0; i < _node.childNodes.length; i++) {
|
||||
let node = _node.childNodes[i];
|
||||
let nodeName = node.nodeName.toLowerCase();
|
||||
if (nodeName.charAt(0) != "#") {
|
||||
_callback.call(_context, node, nodeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
function et2_readAttrWithDefault(_node, _name, _default) {
|
||||
var val = _node.getAttribute(_name);
|
||||
export function et2_readAttrWithDefault(_node, _name, _default) {
|
||||
let val = _node.getAttribute(_name);
|
||||
return (val === null) ? _default : val;
|
||||
}
|
||||
//# sourceMappingURL=et2_core_xml.js.map
|
@ -4,10 +4,12 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* Loads the given URL asynchronously from the server
|
||||
*
|
||||
@ -19,7 +21,7 @@
|
||||
* @param {object} _context for _callback
|
||||
* @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")
|
||||
{
|
||||
@ -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
|
||||
_tagName = _tagName.toLowerCase();
|
||||
@ -79,7 +81,7 @@ function et2_directChildrenByTagName(_node : HTMLElement, _tagName : String) : H
|
||||
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++)
|
||||
{
|
||||
@ -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);
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - dataview code
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
* @version $Id$
|
||||
*
|
||||
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
/*egw:uses
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_common;
|
||||
@ -20,12 +17,10 @@
|
||||
et2_dataview_view_rowProvider;
|
||||
et2_dataview_view_resizeable;
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview = void 0;
|
||||
var et2_dataview_model_columns_1 = require("./et2_dataview_model_columns");
|
||||
var et2_dataview_view_resizeable_1 = require("./et2_dataview_view_resizeable");
|
||||
var et2_dataview_view_grid_1 = require("./et2_dataview_view_grid");
|
||||
var et2_dataview_view_rowProvider_1 = require("./et2_dataview_view_rowProvider");
|
||||
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_grid } from "./et2_dataview_view_grid";
|
||||
import { et2_dataview_rowProvider } from "./et2_dataview_view_rowProvider";
|
||||
/**
|
||||
* 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,
|
||||
@ -35,7 +30,7 @@ var et2_dataview_view_rowProvider_1 = require("./et2_dataview_view_rowProvider")
|
||||
*
|
||||
* @augments Class
|
||||
*/
|
||||
var et2_dataview = /** @class */ (function () {
|
||||
export class et2_dataview {
|
||||
/**
|
||||
* Constructor for the grid container
|
||||
*
|
||||
@ -43,7 +38,7 @@ var et2_dataview = /** @class */ (function () {
|
||||
* @param {egw} _egw
|
||||
* @memberOf et2_dataview
|
||||
*/
|
||||
function et2_dataview(_parentNode, _egw) {
|
||||
constructor(_parentNode, _egw) {
|
||||
// Copy the arguments
|
||||
this.parentNode = jQuery(_parentNode);
|
||||
this.egw = _egw;
|
||||
@ -63,7 +58,7 @@ var et2_dataview = /** @class */ (function () {
|
||||
/**
|
||||
* Destroys the object, removes all dom nodes and clears all references.
|
||||
*/
|
||||
et2_dataview.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Clear the columns
|
||||
this._clearHeader();
|
||||
// Free the grid
|
||||
@ -76,46 +71,46 @@ var et2_dataview = /** @class */ (function () {
|
||||
}
|
||||
// Detatch the outer element
|
||||
this.table.remove();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Clears all data rows and reloads them
|
||||
*/
|
||||
et2_dataview.prototype.clear = function () {
|
||||
clear() {
|
||||
if (this.grid) {
|
||||
this.grid.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the column container node for the given column index
|
||||
*
|
||||
* @param _columnIdx the integer column index
|
||||
*/
|
||||
et2_dataview.prototype.getHeaderContainerNode = function (_columnIdx) {
|
||||
getHeaderContainerNode(_columnIdx) {
|
||||
if (typeof this.columnNodes[_columnIdx] != "undefined") {
|
||||
return this.columnNodes[_columnIdx].container[0];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the column descriptors and creates the column header according to it.
|
||||
* 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
|
||||
this._clearHeader();
|
||||
// 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
|
||||
this.updateColumns();
|
||||
// Build the header row
|
||||
this._buildHeader();
|
||||
// Build the grid
|
||||
this._buildGrid();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resizes the grid
|
||||
*/
|
||||
et2_dataview.prototype.resize = function (_w, _h) {
|
||||
resize(_w, _h) {
|
||||
// Not fully initialized yet...
|
||||
if (!this.columnMgr)
|
||||
return;
|
||||
@ -137,22 +132,21 @@ var et2_dataview = /** @class */ (function () {
|
||||
this.headTr.outerHeight(true));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the column manager object. You can use it to set the visibility
|
||||
* of columns etc. Call "updateHeader" if you did any changes.
|
||||
*/
|
||||
et2_dataview.prototype.getColumnMgr = function () {
|
||||
getColumnMgr() {
|
||||
return this.columnMgr;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Recalculates the stylesheets which determine the column visibility and
|
||||
* width.
|
||||
*
|
||||
* @param setDefault boolean Allow admins to save current settings as default for all users
|
||||
*/
|
||||
et2_dataview.prototype.updateColumns = function (setDefault) {
|
||||
if (setDefault === void 0) { setDefault = false; }
|
||||
updateColumns(setDefault = false) {
|
||||
if (this.columnMgr) {
|
||||
this._updateColumns();
|
||||
}
|
||||
@ -160,13 +154,13 @@ var et2_dataview = /** @class */ (function () {
|
||||
if (this.onUpdateColumns) {
|
||||
this.onUpdateColumns(setDefault);
|
||||
}
|
||||
};
|
||||
}
|
||||
/* --- PRIVATE FUNCTIONS --- */
|
||||
/* --- Code for building the grid container DOM-Tree elements ---- */
|
||||
/**
|
||||
* Builds the base DOM-Tree elements
|
||||
*/
|
||||
et2_dataview.prototype._createElements = function () {
|
||||
_createElements() {
|
||||
/*
|
||||
Structure:
|
||||
<table class="egwGridView_outer">
|
||||
@ -188,12 +182,12 @@ var et2_dataview = /** @class */ (function () {
|
||||
.addClass("egwGridView_outer")
|
||||
.append(this.thead, this.tbody)
|
||||
.appendTo(this.parentNode);
|
||||
};
|
||||
}
|
||||
/* --- Code for building the header row --- */
|
||||
/**
|
||||
* Clears the header row
|
||||
*/
|
||||
et2_dataview.prototype._clearHeader = function () {
|
||||
_clearHeader() {
|
||||
if (this.columnMgr) {
|
||||
this.columnMgr.destroy();
|
||||
this.columnMgr = null;
|
||||
@ -216,12 +210,12 @@ var et2_dataview = /** @class */ (function () {
|
||||
this.columnNodes = [];
|
||||
this.columns = [];
|
||||
this.headTr.empty();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the column data which is retrieved by calling egwGridColumns.getColumnData.
|
||||
* The columns will be updated.
|
||||
*/
|
||||
et2_dataview.prototype._updateColumns = function () {
|
||||
_updateColumns() {
|
||||
// Copy the columns data
|
||||
this.columns = this.columnMgr.getColumnData();
|
||||
// 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_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;");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Builds the containers for the header row
|
||||
*/
|
||||
et2_dataview.prototype._buildHeader = function () {
|
||||
_buildHeader() {
|
||||
var self = this;
|
||||
var handler = function (event) {
|
||||
};
|
||||
@ -320,7 +314,7 @@ var et2_dataview = /** @class */ (function () {
|
||||
// make column resizable
|
||||
var enc_column = self.columnMgr.getColumnById(col.id);
|
||||
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
|
||||
// width columns, so set it explicitly first and adjust other relative
|
||||
// columns to match.
|
||||
@ -356,11 +350,11 @@ var et2_dataview = /** @class */ (function () {
|
||||
});
|
||||
}
|
||||
this._buildSelectCol();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Builds the select cols column
|
||||
*/
|
||||
et2_dataview.prototype._buildSelectCol = function () {
|
||||
_buildSelectCol() {
|
||||
// Build the "select columns" icon
|
||||
this.selectColIcon = jQuery(document.createElement("span"))
|
||||
.addClass("selectcols")
|
||||
@ -375,11 +369,11 @@ var et2_dataview = /** @class */ (function () {
|
||||
.appendTo(this.headTr);
|
||||
this.selectCol.css("width", this.scrollbarWidth - this.selectCol.outerWidth()
|
||||
+ this.selectCol.width() + 1);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Builds the inner grid class
|
||||
*/
|
||||
et2_dataview.prototype._buildGrid = function () {
|
||||
_buildGrid() {
|
||||
// Create the collection of column ids
|
||||
var colIds = [];
|
||||
for (var i = 0; i < this.columns.length; i++) {
|
||||
@ -391,19 +385,19 @@ var et2_dataview = /** @class */ (function () {
|
||||
if (this.rowProvider) {
|
||||
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
|
||||
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
|
||||
var tr = jQuery(this.grid.getFirstNode());
|
||||
this.containerTr.replaceWith(tr);
|
||||
this.containerTr = tr;
|
||||
};
|
||||
}
|
||||
/* --- Code for calculating the browser/css depending widths --- */
|
||||
/**
|
||||
* Reads the browser dependant variables
|
||||
*/
|
||||
et2_dataview.prototype._getDepVars = function () {
|
||||
_getDepVars() {
|
||||
if (typeof this.scrollbarWidth === 'undefined') {
|
||||
// Clone the table and attach it to the outer body tag
|
||||
var clone = this.table.clone();
|
||||
@ -421,11 +415,11 @@ var et2_dataview = /** @class */ (function () {
|
||||
// Remove the cloned DOM-Node again from the outer body
|
||||
clone.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Reads the scrollbar width
|
||||
*/
|
||||
et2_dataview.prototype._getScrollbarWidth = function (_table) {
|
||||
_getScrollbarWidth(_table) {
|
||||
// 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.
|
||||
// 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
|
||||
div_outer.remove();
|
||||
return width;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
var cont = jQuery(document.createElement("div"))
|
||||
.addClass("innerContainer");
|
||||
@ -461,11 +455,11 @@ var et2_dataview = /** @class */ (function () {
|
||||
// Remove the appended element again
|
||||
th.remove();
|
||||
return width;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
var cont = jQuery(document.createElement("div"))
|
||||
.addClass("innerContainer");
|
||||
@ -479,8 +473,6 @@ var et2_dataview = /** @class */ (function () {
|
||||
// Remove the appended element again
|
||||
td.remove();
|
||||
return width;
|
||||
};
|
||||
return et2_dataview;
|
||||
}());
|
||||
exports.et2_dataview = et2_dataview;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_dataview.js.map
|
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
* @version $Id$
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
@ -20,7 +19,7 @@
|
||||
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_grid} from "./et2_dataview_view_grid";
|
||||
import {et2_dataview_rowProvider} from "./et2_dataview_view_rowProvider"
|
||||
@ -67,9 +66,9 @@ export class et2_dataview
|
||||
private columnNodes: any[];
|
||||
private columns: any[];
|
||||
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
|
||||
private selectColIcon: JQuery;
|
||||
@ -667,6 +666,4 @@ export class et2_dataview
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,41 +1,29 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
et2_core_inheritance;
|
||||
|
||||
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");
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
import { et2_dataview_selectionManager } from "./et2_dataview_controller_selection";
|
||||
import { et2_dataview_row } from "./et2_dataview_view_row";
|
||||
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
|
||||
* consolidate requests for rows.
|
||||
*/
|
||||
var ET2_DATAVIEW_FETCH_TIMEOUT = 50;
|
||||
var ET2_DATAVIEW_STEPSIZE = 50;
|
||||
export const ET2_DATAVIEW_FETCH_TIMEOUT = 50;
|
||||
export const ET2_DATAVIEW_STEPSIZE = 50;
|
||||
/**
|
||||
* The et2_dataview_controller class is the intermediate layer between a grid
|
||||
* instance and the corresponding data source. It manages updating the grid,
|
||||
* 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
|
||||
* callback.
|
||||
@ -50,7 +38,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
* @param _actionObjectManager is the object that manages the action
|
||||
* objects.
|
||||
*/
|
||||
function et2_dataview_controller(_parentController, _grid) {
|
||||
constructor(_parentController, _grid) {
|
||||
this._indexMap = {};
|
||||
// Copy the given arguments
|
||||
this._parentController = _parentController;
|
||||
@ -74,7 +62,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._parentController._children.push(this);
|
||||
}
|
||||
}
|
||||
et2_dataview_controller.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Destroy the selection manager
|
||||
this._selectionMgr.destroy();
|
||||
// Clear the selection timeout
|
||||
@ -89,34 +77,34 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
this._grid = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param value is an object implementing the et2_IDataProvider
|
||||
* interface
|
||||
*/
|
||||
et2_dataview_controller.prototype.setDataProvider = function (value) {
|
||||
setDataProvider(value) {
|
||||
this._dataProvider = value;
|
||||
};
|
||||
et2_dataview_controller.prototype.setRowCallback = function (value) {
|
||||
}
|
||||
setRowCallback(value) {
|
||||
this._rowCallback = value;
|
||||
};
|
||||
et2_dataview_controller.prototype.setLinkCallback = function (value) {
|
||||
}
|
||||
setLinkCallback(value) {
|
||||
this._linkCallback = value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param value is the context in which the _rowCallback and the
|
||||
* _linkCallback are called.
|
||||
*/
|
||||
et2_dataview_controller.prototype.setContext = function (value) {
|
||||
setContext(value) {
|
||||
this._context = value;
|
||||
};
|
||||
et2_dataview_controller.prototype.setActionObjectManager = function (_actionObjectManager) {
|
||||
}
|
||||
setActionObjectManager(_actionObjectManager) {
|
||||
if (this._selectionMgr) {
|
||||
this._selectionMgr.destroy();
|
||||
}
|
||||
// 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
|
||||
* 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.
|
||||
* Completely clears the grid and selection.
|
||||
*/
|
||||
et2_dataview_controller.prototype.update = function (clear) {
|
||||
update(clear) {
|
||||
// Avoid update after destroy
|
||||
// Happens sometimes if AJAX response comes after etemplate unload
|
||||
if (!this._grid)
|
||||
@ -163,11 +151,11 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._request_queue = [];
|
||||
// Require that range from the server
|
||||
this._queueFetch(et2_bounds(range.top, clear ? 0 : range.bottom + 1), 0, true);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rebuilds the complete grid.
|
||||
*/
|
||||
et2_dataview_controller.prototype.reset = function () {
|
||||
reset() {
|
||||
// Throw away all internal mappings and reset the timestamp
|
||||
this._indexMap = {};
|
||||
// Update selection manager, it uses this by reference
|
||||
@ -180,22 +168,22 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._request_queue = [];
|
||||
// Update the data
|
||||
this.update();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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++) {
|
||||
this._getIndexEntry(i).uid = order[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Load initial data
|
||||
*
|
||||
* @param {string} uid_key Name of the unique row identifier field
|
||||
* @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;
|
||||
for (var key in data) {
|
||||
// Skip any extra keys
|
||||
@ -216,32 +204,32 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._selectionMgr.clear();
|
||||
this._emptyRow(this._grid._total == 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the depth of the controller instance.
|
||||
*/
|
||||
et2_dataview_controller.prototype.getDepth = function () {
|
||||
getDepth() {
|
||||
if (this._parentController) {
|
||||
return this._parentController.getDepth() + 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the data cache prefix
|
||||
* 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
|
||||
* 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;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the row information of the passed node, or null if not available
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* @return {string|false} UID, or false if not found
|
||||
*/
|
||||
et2_dataview_controller.prototype.getRowByNode = function (node) {
|
||||
getRowByNode(node) {
|
||||
// Whatever the node, find a TR
|
||||
var row_node = jQuery(node).closest('tr');
|
||||
var row = null;
|
||||
@ -270,15 +258,15 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
row.controller = this;
|
||||
}
|
||||
return row;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the current "total" count.
|
||||
*/
|
||||
et2_dataview_controller.prototype.getTotalCount = function () {
|
||||
getTotalCount() {
|
||||
return this._grid.getTotalCount();
|
||||
};
|
||||
}
|
||||
/* -- PRIVATE FUNCTIONS -- */
|
||||
et2_dataview_controller.prototype._getIndexEntry = function (_idx) {
|
||||
_getIndexEntry(_idx) {
|
||||
// Create an entry in the index map if it does not exist yet
|
||||
if (typeof this._indexMap[_idx] === "undefined") {
|
||||
this._indexMap[_idx] = {
|
||||
@ -291,7 +279,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
// index does not get updated any further
|
||||
this._indexMap[_idx]["idx"] = _idx;
|
||||
return this._indexMap[_idx];
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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,
|
||||
@ -306,8 +294,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
* @return true, if all data for the row has been available, false
|
||||
* otherwise.
|
||||
*/
|
||||
et2_dataview_controller.prototype._insertDataRow = function (_entry, _update) {
|
||||
var _this = this;
|
||||
_insertDataRow(_entry, _update) {
|
||||
// Abort if the entry already has a row but the _insert flag is not set
|
||||
if (_entry.row && !_update) {
|
||||
return true;
|
||||
@ -350,9 +337,9 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
}
|
||||
// Update index map only for push (autorefresh disabled)
|
||||
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; }));
|
||||
for (var idx = max; idx >= _entry.idx; idx--) {
|
||||
var entry = this._indexMap[idx];
|
||||
let max = parseInt(Object.keys(this._indexMap).reduce((a, b) => this._indexMap[a] > this._indexMap[b] ? a : b));
|
||||
for (let idx = max; idx >= _entry.idx; idx--) {
|
||||
let entry = this._indexMap[idx];
|
||||
this._indexMap[idx].idx = idx + 1;
|
||||
this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx];
|
||||
if (this._selectionMgr && this._selectionMgr._registeredRows[entry.uid]) {
|
||||
@ -362,16 +349,16 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry;
|
||||
return this.hasData;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Create a new row.
|
||||
*
|
||||
* @param {type} ctx
|
||||
* @returns {et2_dataview_container}
|
||||
*/
|
||||
et2_dataview_controller.prototype._createRow = function (ctx) {
|
||||
return new et2_dataview_view_row_1.et2_dataview_row(this._grid);
|
||||
};
|
||||
_createRow(ctx) {
|
||||
return new et2_dataview_row(this._grid);
|
||||
}
|
||||
/**
|
||||
* Function which gets called by the grid when data is requested.
|
||||
*
|
||||
@ -379,7 +366,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
* requested.
|
||||
* @param _idxEnd is the index of the last requested row.
|
||||
*/
|
||||
et2_dataview_controller.prototype._gridCallback = function (_idxStart, _idxEnd) {
|
||||
_gridCallback(_idxStart, _idxEnd) {
|
||||
var needsData = false;
|
||||
// Iterate over all elements the dataview requested and create a row
|
||||
// which indicates that we are currently loading data
|
||||
@ -395,12 +382,12 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
if (needsData !== 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.
|
||||
* TODO: Refresh is currently not used
|
||||
*/
|
||||
et2_dataview_controller.prototype._queueFetch = function (_range, _direction, _isUpdate) {
|
||||
_queueFetch(_range, _direction, _isUpdate) {
|
||||
// Force immediate to be false
|
||||
_isUpdate = _isUpdate ? _isUpdate : false;
|
||||
// Push the requests onto the request queue
|
||||
@ -422,11 +409,11 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
if (_isUpdate) {
|
||||
this._flushQueue(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Flushes the queue.
|
||||
*/
|
||||
et2_dataview_controller.prototype._flushQueue = function (_isUpdate) {
|
||||
_flushQueue(_isUpdate) {
|
||||
// Clear any still existing timer
|
||||
this._clearTimer();
|
||||
// Mark all elements in a radius of ET2_DATAVIEW_STEPSIZE
|
||||
@ -496,20 +483,21 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
"self": this,
|
||||
"start": query.start,
|
||||
"count": query.num_rows,
|
||||
"lastModification": this._lastModification
|
||||
"lastModification": this._lastModification,
|
||||
prefix: undefined
|
||||
};
|
||||
if (this.dataStorePrefix) {
|
||||
ctx.prefix = this.dataStorePrefix;
|
||||
}
|
||||
this._queueRequest(query, ctx);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Queue a request for data
|
||||
* @param {Object} query
|
||||
* @param {Object} ctx
|
||||
*/
|
||||
et2_dataview_controller.prototype._queueRequest = function (query, ctx) {
|
||||
_queueRequest(query, ctx) {
|
||||
this._request_queue.push({
|
||||
query: query,
|
||||
context: ctx,
|
||||
@ -517,11 +505,11 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
status: 0
|
||||
});
|
||||
this._fetchQueuedRequest();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Fetch data for a queued request, subject to rate limit
|
||||
*/
|
||||
et2_dataview_controller.prototype._fetchQueuedRequest = function () {
|
||||
_fetchQueuedRequest() {
|
||||
// Check to see if there's room
|
||||
var count = 0;
|
||||
for (var i = 0; i < this._request_queue.length; i++) {
|
||||
@ -558,20 +546,20 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
request.status = 1;
|
||||
// Call the callback
|
||||
this._dataProvider.dataFetch(request.query, this._fetchCallback, request.context);
|
||||
};
|
||||
et2_dataview_controller.prototype._clearTimer = function () {
|
||||
}
|
||||
_clearTimer() {
|
||||
// Reset the queue timer upon destruction
|
||||
if (this._queueTimer) {
|
||||
window.clearTimeout(this._queueTimer);
|
||||
this._queueTimer = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Called by the data source when the data changes
|
||||
*
|
||||
* @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
|
||||
this.self.hasData = true;
|
||||
// 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
|
||||
this.entry.row.invalidate();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
et2_dataview_controller.prototype._destroyCallback = function (_row) {
|
||||
_destroyCallback(_row) {
|
||||
// Unregister the row from the selection manager, if not selected
|
||||
// If it is selected, leave it there - allows selecting rows and scrolling
|
||||
var selection = this.self._selectionMgr._getRegisteredRowsEntry(this.entry.uid);
|
||||
@ -634,18 +622,18 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this.entry.row = null;
|
||||
// Unregister the data callback
|
||||
this.self._dataProvider.dataUnregisterUID(this.entry.uid, this.self._dataCallback, this);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns an array containing "_count" index mapping entries starting from
|
||||
* the index given in "_start".
|
||||
*/
|
||||
et2_dataview_controller.prototype._getIndexMapping = function (_start, _count) {
|
||||
_getIndexMapping(_start, _count) {
|
||||
var result = [];
|
||||
for (var i = _start; i < _start + _count; i++) {
|
||||
result.push(this._getIndexEntry(i));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
@ -665,7 +653,7 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
* newly created index entries are returned. This function does not update
|
||||
* 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
|
||||
// be merged with the result
|
||||
var result = [];
|
||||
@ -712,8 +700,8 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
et2_dataview_controller.prototype._mergeResult = function (_newEntries, _invalidStartIdx, _diff, _total) {
|
||||
}
|
||||
_mergeResult(_newEntries, _invalidStartIdx, _diff, _total) {
|
||||
if (_newEntries.length > 0 || _diff > 0) {
|
||||
// Create a new index map
|
||||
var newMap = {};
|
||||
@ -744,8 +732,8 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._indexMap = newMap;
|
||||
this._selectionMgr.setIndexMap(newMap);
|
||||
}
|
||||
};
|
||||
et2_dataview_controller.prototype._fetchCallback = function (_response) {
|
||||
}
|
||||
_fetchCallback(_response) {
|
||||
// Remove answered request from queue
|
||||
var request = null;
|
||||
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();
|
||||
// Check if requests are waiting
|
||||
this.self._fetchQueuedRequest();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
jQuery(".egwGridView_empty", this._grid.innerTbody).remove();
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Callback function used by the selection manager to translate the selected
|
||||
* 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,
|
||||
"no_data": true }, function (_response) {
|
||||
_callback.call(_context, _response.order);
|
||||
}, _context);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Tells the grid to make the given index visible.
|
||||
*/
|
||||
et2_dataview_controller.prototype._makeIndexVisible = function (_idx) {
|
||||
_makeIndexVisible(_idx) {
|
||||
this._grid.makeIndexVisible(_idx);
|
||||
};
|
||||
// Maximum concurrent data requests. Additional ones are held in the queue.
|
||||
et2_dataview_controller.CONCURRENT_REQUESTS = 5;
|
||||
return et2_dataview_controller;
|
||||
}());
|
||||
exports.et2_dataview_controller = et2_dataview_controller;
|
||||
}
|
||||
}
|
||||
// Maximum concurrent data requests. Additional ones are held in the queue.
|
||||
et2_dataview_controller.CONCURRENT_REQUESTS = 5;
|
||||
//# sourceMappingURL=et2_dataview_controller.js.map
|
@ -4,9 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
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_row} from "./et2_dataview_view_row";
|
||||
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
|
||||
* 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
|
||||
@ -43,24 +46,25 @@ export class et2_dataview_controller
|
||||
// Maximum concurrent data requests. Additional ones are held in the queue.
|
||||
public static readonly CONCURRENT_REQUESTS = 5;
|
||||
|
||||
private _parentController: any;
|
||||
private _grid: et2_dataview_grid;
|
||||
private dataStorePrefix: any;
|
||||
protected _parentController: any;
|
||||
protected _grid: et2_dataview_grid;
|
||||
protected dataStorePrefix: any;
|
||||
private _dataProvider: any;
|
||||
private _rowCallback: any;
|
||||
private _linkCallback: any;
|
||||
protected _rowCallback: any;
|
||||
protected _linkCallback: any;
|
||||
private _context: any;
|
||||
|
||||
private _children: any[];
|
||||
private _indexMap: any = {};
|
||||
protected _children: any[];
|
||||
protected _indexMap: any = {};
|
||||
|
||||
private _queueTimer: number;
|
||||
private _lastModification: number;
|
||||
private _queue: {};
|
||||
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
|
||||
@ -679,7 +683,8 @@ export class et2_dataview_controller
|
||||
"self": this,
|
||||
"start": query.start,
|
||||
"count": query.num_rows,
|
||||
"lastModification": this._lastModification
|
||||
"lastModification": this._lastModification,
|
||||
prefix: undefined
|
||||
};
|
||||
if(this.dataStorePrefix)
|
||||
{
|
||||
|
@ -1,22 +1,22 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
*
|
||||
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
/*egw:uses
|
||||
et2_dataview_view_aoi;
|
||||
|
||||
egw_action.egw_keymanager;
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview_selectionManager = void 0;
|
||||
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
|
||||
* to manage the row selection.
|
||||
@ -28,7 +28,7 @@ exports.et2_dataview_selectionManager = void 0;
|
||||
*
|
||||
* @augments Class
|
||||
*/
|
||||
var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
export class et2_dataview_selectionManager {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -40,7 +40,7 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
* @param _context
|
||||
* @memberOf et2_dataview_selectionManager
|
||||
*/
|
||||
function et2_dataview_selectionManager(_parent, _indexMap, _actionObjectManager, _queryRangeCallback, _makeVisibleCallback, _context) {
|
||||
constructor(_parent, _indexMap, _actionObjectManager, _queryRangeCallback, _makeVisibleCallback, _context) {
|
||||
// Copy the arguments
|
||||
this._parent = _parent;
|
||||
this._indexMap = _indexMap;
|
||||
@ -68,7 +68,7 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
// Callback for when the selection changes
|
||||
this.select_callback = null;
|
||||
}
|
||||
et2_dataview_selectionManager.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// If we have a parent, unregister from that
|
||||
if (this._parent) {
|
||||
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.select_callback = null;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.clear = function () {
|
||||
}
|
||||
clear() {
|
||||
for (var key in this._registeredRows) {
|
||||
this.unregisterRow(key, this._registeredRows[key].tr);
|
||||
delete this._registeredRows[key];
|
||||
@ -100,14 +100,14 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
this._invertSelection = false;
|
||||
this._selectAll = false;
|
||||
this._inUpdate = false;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.setIndexMap = function (_indexMap) {
|
||||
}
|
||||
setIndexMap(_indexMap) {
|
||||
this._indexMap = _indexMap;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.setTotalCount = function (_total) {
|
||||
}
|
||||
setTotalCount(_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
|
||||
var entry = this._getRegisteredRowsEntry(_uid);
|
||||
// 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;
|
||||
// Update the visible state of the _tr
|
||||
this._updateEntryState(entry, entry.state);
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.unregisterRow = function (_uid, _tr, _noDelete) {
|
||||
}
|
||||
unregisterRow(_uid, _tr, _noDelete) {
|
||||
// _noDelete defaults to false
|
||||
_noDelete = _noDelete ? true : false;
|
||||
if (typeof this._registeredRows[_uid] !== "undefined"
|
||||
@ -152,8 +152,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
}
|
||||
this._inUpdate = false;
|
||||
}
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.resetSelection = function () {
|
||||
}
|
||||
resetSelection() {
|
||||
this._invertSelection = false;
|
||||
this._selectAll = false;
|
||||
this._actionObjectManager.setAllSelected(false);
|
||||
@ -163,17 +163,17 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
for (var i = 0; i < this._children.length; i++) {
|
||||
this._children[i].resetSelection();
|
||||
}
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.setSelected = function (_uid, _selected) {
|
||||
}
|
||||
setSelected(_uid, _selected) {
|
||||
this._selectAll = false;
|
||||
var entry = this._getRegisteredRowsEntry(_uid);
|
||||
this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_SELECTED, _selected));
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.getAllSelected = function () {
|
||||
}
|
||||
getAllSelected() {
|
||||
var selected = this.getSelected();
|
||||
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
|
||||
if (this._focusedEntry) {
|
||||
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);
|
||||
this._updateEntryState(entry, egwSetBit(entry.state, EGW_AO_STATE_FOCUSED, true));
|
||||
}
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.selectAll = function () {
|
||||
}
|
||||
selectAll() {
|
||||
// Reset the selection
|
||||
this.resetSelection();
|
||||
this._selectAll = true;
|
||||
@ -203,8 +203,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
this._updateEntryState(entry, entry.state);
|
||||
}
|
||||
this._selectAll = true;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype.getSelected = function () {
|
||||
}
|
||||
getSelected() {
|
||||
// Collect all currently selected ids
|
||||
var ids = [];
|
||||
for (var key in this._registeredRows) {
|
||||
@ -223,9 +223,9 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
"all": this._selectAll,
|
||||
"ids": ids
|
||||
};
|
||||
};
|
||||
}
|
||||
/** -- 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
|
||||
// this AOI is not connected to the AO, as the selection manager
|
||||
// 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);
|
||||
};
|
||||
et2_dataview_selectionManager.prototype._getDummyAOI = function (_entry, _tr, _uid, _idx) {
|
||||
}
|
||||
_getDummyAOI(_entry, _tr, _uid, _idx) {
|
||||
// Create AOI
|
||||
var dummyAOI = new egwActionObjectInterface();
|
||||
var self = this;
|
||||
@ -261,8 +261,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
// handlers can be properly bound
|
||||
dummyAOI.getDOMNode = function () { return _tr; };
|
||||
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
|
||||
// does no selection handling
|
||||
var dummyAOI = this._getDummyAOI(_entry, _tr, _uid, _idx);
|
||||
@ -322,13 +322,13 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
et2_dataview_selectionManager.prototype._updateState = function (_uid, _state) {
|
||||
}
|
||||
_updateState(_uid, _state) {
|
||||
var entry = this._getRegisteredRowsEntry(_uid);
|
||||
this._updateEntryState(entry, _state);
|
||||
return entry;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype._updateEntryState = function (_entry, _state) {
|
||||
}
|
||||
_updateEntryState(_entry, _state) {
|
||||
if (this._selectAll) {
|
||||
_state |= EGW_AO_STATE_SELECTED;
|
||||
}
|
||||
@ -371,8 +371,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
}
|
||||
// Update the state of the entry
|
||||
_entry.state = _state;
|
||||
};
|
||||
et2_dataview_selectionManager.prototype._getRegisteredRowsEntry = function (_uid) {
|
||||
}
|
||||
_getRegisteredRowsEntry(_uid) {
|
||||
if (typeof this._registeredRows[_uid] === "undefined") {
|
||||
this._registeredRows[_uid] = {
|
||||
"uid": _uid,
|
||||
@ -384,8 +384,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
};
|
||||
}
|
||||
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 (!_ctrl) {
|
||||
var top = this;
|
||||
@ -408,8 +408,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
if (this.select_callback && typeof this.select_callback == "function") {
|
||||
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
|
||||
// to be queried
|
||||
var queryRanges = [];
|
||||
@ -455,8 +455,8 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
if (queryRanges.length > 0) {
|
||||
this._query_ranges(queryRanges);
|
||||
}
|
||||
};
|
||||
et2_dataview_selectionManager.prototype._query_ranges = function (queryRanges) {
|
||||
}
|
||||
_query_ranges(queryRanges) {
|
||||
var that = this;
|
||||
var record_count = 0;
|
||||
var range_index = 0;
|
||||
@ -513,11 +513,9 @@ var et2_dataview_selectionManager = /** @class */ (function () {
|
||||
fetchPromise.finally(function () {
|
||||
dialog.destroy();
|
||||
});
|
||||
};
|
||||
// Maximum number of rows we can safely fetch for selection
|
||||
// Actual selection may have more rows if we already have some
|
||||
et2_dataview_selectionManager.MAX_SELECTION = 1000;
|
||||
return et2_dataview_selectionManager;
|
||||
}());
|
||||
exports.et2_dataview_selectionManager = et2_dataview_selectionManager;
|
||||
}
|
||||
}
|
||||
// Maximum number of rows we can safely fetch for selection
|
||||
// Actual selection may have more rows if we already have some
|
||||
et2_dataview_selectionManager.MAX_SELECTION = 1000;
|
||||
//# sourceMappingURL=et2_dataview_controller_selection.js.map
|
@ -4,10 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
et2_dataview_view_aoi;
|
||||
@ -15,6 +15,11 @@
|
||||
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
|
||||
* to manage the row selection.
|
||||
@ -41,8 +46,8 @@ export class et2_dataview_selectionManager
|
||||
private select_callback: null;
|
||||
|
||||
private _context: any;
|
||||
private _registeredRows: {};
|
||||
private _focusedEntry: null;
|
||||
_registeredRows: {};
|
||||
_focusedEntry: null;
|
||||
private _invertSelection: boolean;
|
||||
private _selectAll: boolean;
|
||||
private _inUpdate: boolean;
|
||||
|
@ -1,26 +1,27 @@
|
||||
"use strict";
|
||||
/**
|
||||
* 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 http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable";
|
||||
function implements_et2_dataview_IInvalidatable(obj) {
|
||||
/*egw:uses
|
||||
et2_core_inheritance;
|
||||
*/
|
||||
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"]);
|
||||
}
|
||||
var et2_dataview_IViewRange = "et2_dataview_IViewRange";
|
||||
function implements_et2_dataview_IViewRange(obj) {
|
||||
};
|
||||
export const et2_dataview_IViewRange = "et2_dataview_IViewRange";
|
||||
et2_implements_registry.et2_dataview_IViewRange = function (obj) {
|
||||
return implements_methods(obj, ["setViewRange"]);
|
||||
}
|
||||
var et2_IDataProvider = "et2_IDataProvider";
|
||||
function implements_et2_IDataProvider(obj) {
|
||||
};
|
||||
export const et2_IDataProvider = "et2_IDataProvider";
|
||||
et2_implements_registry.et2_IDataProvider = function (obj) {
|
||||
return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=et2_dataview_interfaces.js.map
|
@ -4,22 +4,24 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
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
|
||||
{
|
||||
invalidate()
|
||||
}
|
||||
var et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable";
|
||||
function implements_et2_dataview_IInvalidatable(obj : et2_widget)
|
||||
export const et2_dataviewIInvalidatable = "et2_dataview_IInvalidatable";
|
||||
et2_implements_registry.et2_dataview_IInvalidatable = function(obj : et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["invalidate"]);
|
||||
}
|
||||
@ -27,8 +29,8 @@ export interface et2_dataview_IViewRange
|
||||
{
|
||||
setViewRange(_range)
|
||||
}
|
||||
var et2_dataview_IViewRange = "et2_dataview_IViewRange";
|
||||
function implements_et2_dataview_IViewRange(obj : et2_widget)
|
||||
export const et2_dataview_IViewRange = "et2_dataview_IViewRange";
|
||||
et2_implements_registry.et2_dataview_IViewRange = function(obj : et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["setViewRange"]);
|
||||
}
|
||||
@ -101,8 +103,8 @@ export interface et2_IDataProvider
|
||||
dataUnregisterUID (_uid : string, _callback : Function, _context : object)
|
||||
|
||||
}
|
||||
var et2_IDataProvider = "et2_IDataProvider";
|
||||
function implements_et2_IDataProvider(obj : et2_widget)
|
||||
export const et2_IDataProvider = "et2_IDataProvider";
|
||||
et2_implements_registry.et2_IDataProvider = function(obj : et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["dataFetch", "dataRegisterUID", "dataUnregisterUID"]);
|
||||
}
|
||||
|
113
api/js/etemplate/et2_dataview_model_columns.js
Executable file → Normal file
113
api/js/etemplate/et2_dataview_model_columns.js
Executable file → Normal file
@ -1,31 +1,28 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Class which contains a the columns model
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview_columns = exports.et2_dataview_column = void 0;
|
||||
/*egw:uses
|
||||
et2_core_inheritance;
|
||||
et2_inheritance;
|
||||
*/
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* Class which stores the data of a single column.
|
||||
*
|
||||
* @augments Class
|
||||
*/
|
||||
var et2_dataview_column = /** @class */ (function () {
|
||||
export class et2_dataview_column {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_dataview_column(_attrs) {
|
||||
constructor(_attrs) {
|
||||
/**
|
||||
* Defines the visibility state of this column.
|
||||
*/
|
||||
@ -78,7 +75,7 @@ var et2_dataview_column = /** @class */ (function () {
|
||||
*
|
||||
* @param {float|string} _value
|
||||
*/
|
||||
et2_dataview_column.prototype.set_width = function (_value) {
|
||||
set_width(_value) {
|
||||
// Parse the width parameter.
|
||||
this.relativeWidth = false;
|
||||
this.fixedWidth = false;
|
||||
@ -99,8 +96,8 @@ var et2_dataview_column = /** @class */ (function () {
|
||||
else if (typeof w == 'string' && !isNaN(parseFloat(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 (this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS || this.visibility == et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT)
|
||||
return;
|
||||
@ -116,15 +113,16 @@ var et2_dataview_column = /** @class */ (function () {
|
||||
else {
|
||||
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_VISIBILITY_ALWAYS = 0;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE = 1;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_INVISIBLE = 2;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_DISABLED = 4;
|
||||
et2_dataview_column._attributes = {
|
||||
}
|
||||
}
|
||||
et2_dataview_column.ET2_COL_TYPE_DEFAULT = 0;
|
||||
et2_dataview_column.ET2_COL_TYPE_NAME_ICON_FIXED = 1;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS = 0;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_VISIBLE = 1;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_INVISIBLE = 2;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_ALWAYS_NOSELECT = 3;
|
||||
et2_dataview_column.ET2_COL_VISIBILITY_DISABLED = 4;
|
||||
et2_dataview_column._attributes = {
|
||||
"id": {
|
||||
"name": "ID",
|
||||
"type": "string",
|
||||
@ -167,17 +165,14 @@ var et2_dataview_column = /** @class */ (function () {
|
||||
"default": 0,
|
||||
"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
|
||||
* of columns a grid view owns. The parameters of the columns (except for visibility)
|
||||
* do normaly not change.
|
||||
*/
|
||||
var et2_dataview_columns = /** @class */ (function () {
|
||||
function et2_dataview_columns(_columnData) {
|
||||
export class et2_dataview_columns {
|
||||
constructor(_columnData) {
|
||||
// Initialize some variables
|
||||
this._totalWidth = 0;
|
||||
this._totalFixed = 0;
|
||||
@ -189,71 +184,63 @@ var et2_dataview_columns = /** @class */ (function () {
|
||||
}
|
||||
this._updated = true;
|
||||
}
|
||||
et2_dataview_columns.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Free all column objects
|
||||
for (var i = 0; i < this.columns.length; i++) {
|
||||
this.columns[i] = null;
|
||||
}
|
||||
};
|
||||
et2_dataview_columns.prototype.updated = function () {
|
||||
}
|
||||
updated() {
|
||||
this._updated = true;
|
||||
};
|
||||
et2_dataview_columns.prototype.columnCount = function () {
|
||||
}
|
||||
columnCount() {
|
||||
return this.columns.length;
|
||||
};
|
||||
Object.defineProperty(et2_dataview_columns.prototype, "totalWidth", {
|
||||
get: function () {
|
||||
}
|
||||
get totalWidth() {
|
||||
return this._totalWidth;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(et2_dataview_columns.prototype, "totalFixed", {
|
||||
get: function () {
|
||||
}
|
||||
get totalFixed() {
|
||||
return this._totalFixed ? this._totalFixed : 0;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set the total width of the header row
|
||||
*
|
||||
* @param {(string|number)} _width
|
||||
*/
|
||||
et2_dataview_columns.prototype.setTotalWidth = function (_width) {
|
||||
setTotalWidth(_width) {
|
||||
if (_width != this._totalWidth && _width > 0) {
|
||||
this._totalWidth = _width;
|
||||
this._updated = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the index of the colum with the given id
|
||||
*
|
||||
* @param {string} _id
|
||||
*/
|
||||
et2_dataview_columns.prototype.getColumnIndexById = function (_id) {
|
||||
getColumnIndexById(_id) {
|
||||
for (var i = 0; i < this.columns.length; i++) {
|
||||
if (this.columns[i].id == _id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the column with the given id
|
||||
*
|
||||
* @param {string} _id
|
||||
*/
|
||||
et2_dataview_columns.prototype.getColumnById = function (_id) {
|
||||
getColumnById(_id) {
|
||||
var idx = this.getColumnIndexById(_id);
|
||||
return (idx == -1) ? null : this.columns[idx];
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the width of the column with the given index
|
||||
*
|
||||
* @param {number} _idx
|
||||
*/
|
||||
et2_dataview_columns.prototype.getColumnWidth = function (_idx) {
|
||||
getColumnWidth(_idx) {
|
||||
if (this._totalWidth > 0 && _idx >= 0 && _idx < this.columns.length) {
|
||||
// Recalculate the column widths if something has changed.
|
||||
if (this._updated) {
|
||||
@ -264,12 +251,12 @@ var et2_dataview_columns = /** @class */ (function () {
|
||||
return this.columnWidths[_idx];
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns an array containing the width of the column and its visibility
|
||||
* state.
|
||||
*/
|
||||
et2_dataview_columns.prototype.getColumnData = function () {
|
||||
getColumnData() {
|
||||
var result = [];
|
||||
for (var i = 0; i < this.columns.length; i++) {
|
||||
result.push({
|
||||
@ -280,12 +267,12 @@ var et2_dataview_columns = /** @class */ (function () {
|
||||
});
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns an associative array which contains data about the visibility
|
||||
* state of the columns.
|
||||
*/
|
||||
et2_dataview_columns.prototype.getColumnVisibilitySet = function () {
|
||||
getColumnVisibilitySet() {
|
||||
var result = {};
|
||||
for (var i = 0; i < this.columns.length; i++) {
|
||||
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;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets a column visiblity set
|
||||
*
|
||||
* @param {object} _set
|
||||
*/
|
||||
et2_dataview_columns.prototype.setColumnVisibilitySet = function (_set) {
|
||||
setColumnVisibilitySet(_set) {
|
||||
for (var k in _set) {
|
||||
var col = this.getColumnById(k);
|
||||
if (col) {
|
||||
@ -314,16 +301,16 @@ var et2_dataview_columns = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
this._updated = true;
|
||||
};
|
||||
}
|
||||
/* ---- PRIVATE FUNCTIONS ---- */
|
||||
/**
|
||||
* Calculates the absolute column width depending on the previously set
|
||||
* "totalWidth" value. The calculated values are stored in the columnWidths
|
||||
* array.
|
||||
*/
|
||||
et2_dataview_columns.prototype._calculateWidths = function () {
|
||||
_calculateWidths() {
|
||||
// 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++) {
|
||||
_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);
|
||||
}
|
||||
}
|
||||
};
|
||||
return et2_dataview_columns;
|
||||
}());
|
||||
exports.et2_dataview_columns = et2_dataview_columns;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_dataview_model_columns.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -16,6 +15,8 @@
|
||||
*/
|
||||
|
||||
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* Class which stores the data of a single column.
|
||||
*
|
||||
|
@ -4,53 +4,40 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @version $Id$
|
||||
* @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.
|
||||
*/
|
||||
|
||||
var EGW_SELECTMODE_DEFAULT = 0;
|
||||
var EGW_SELECTMODE_TOGGLE = 1;
|
||||
|
||||
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
|
||||
*/
|
||||
function et2_dataview_rowAOI(_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() {
|
||||
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
|
||||
*
|
||||
@ -58,31 +45,25 @@ function et2_dataview_rowAOI(_node)
|
||||
* @param {DOMEvent} e
|
||||
* @param {object} _params
|
||||
*/
|
||||
var selectHandler = function(e, _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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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();
|
||||
if (_egw_active_menu)
|
||||
_egw_active_menu.hide();
|
||||
break;
|
||||
case "up":
|
||||
case "down":
|
||||
@ -90,62 +71,47 @@ function et2_dataview_rowAOI(_node)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (aoi.selectMode)
|
||||
{
|
||||
switch (aoi.selectMode) {
|
||||
case EGW_SELECTMODE_DEFAULT:
|
||||
aoi.updateState(EGW_AO_STATE_SELECTED,
|
||||
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
|
||||
state);
|
||||
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));
|
||||
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});
|
||||
swipe: function (event, direction, distance) {
|
||||
if (distance > 100)
|
||||
selectHandler(event, { swip: direction });
|
||||
},
|
||||
tap: function (event, duration)
|
||||
{
|
||||
tap: function (event, duration) {
|
||||
selectHandler(event);
|
||||
},
|
||||
// stop scrolling touch being confused from tap
|
||||
longTap: function (event)
|
||||
{
|
||||
longTap: function (event) {
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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.doSetState = function(_state) {
|
||||
aoi.doSetState = function (_state) {
|
||||
var selected = egwBitIsSet(_state, EGW_AO_STATE_SELECTED);
|
||||
|
||||
if (this.checkBox)
|
||||
{
|
||||
if (this.checkBox) {
|
||||
this.checkBox.checked = selected;
|
||||
}
|
||||
|
||||
jQuery(this.node).toggleClass('focused',
|
||||
egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
||||
jQuery(this.node).toggleClass('selected',
|
||||
selected);
|
||||
jQuery(this.node).toggleClass('focused', egwBitIsSet(_state, EGW_AO_STATE_FOCUSED));
|
||||
jQuery(this.node).toggleClass('selected', selected);
|
||||
};
|
||||
|
||||
return aoi;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=et2_dataview_view_aoi.js.map
|
150
api/js/etemplate/et2_dataview_view_aoi.ts
Normal file
150
api/js/etemplate/et2_dataview_view_aoi.ts
Normal 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;
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - dataview code
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
* @version $Id$
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview_container = void 0;
|
||||
import { et2_bounds } from "./et2_core_common";
|
||||
/**
|
||||
* 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
|
||||
@ -28,7 +26,7 @@ exports.et2_dataview_container = void 0;
|
||||
*
|
||||
* @augments Class
|
||||
*/
|
||||
var et2_dataview_container = /** @class */ (function () {
|
||||
export class et2_dataview_container {
|
||||
/**
|
||||
* Initializes the container object.
|
||||
*
|
||||
@ -36,7 +34,7 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
* interface. _parent may not be null.
|
||||
* @memberOf et2_dataview_container
|
||||
*/
|
||||
function et2_dataview_container(_parent) {
|
||||
constructor(_parent) {
|
||||
// Copy the given invalidation element
|
||||
this._parent = _parent;
|
||||
this._nodes = [];
|
||||
@ -53,14 +51,14 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
* should override this method and take care of unregistering all event
|
||||
* handlers etc.
|
||||
*/
|
||||
et2_dataview_container.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Remove the nodes from the tree
|
||||
this.removeFromTree();
|
||||
// Call the callback function (if one is registered)
|
||||
if (this._destroyCallback) {
|
||||
this._destroyCallback.call(this._destroyContext, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the "destroyCallback" -- the given function gets called whenever
|
||||
* 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 {object} _context
|
||||
*/
|
||||
et2_dataview_container.prototype.setDestroyCallback = function (_callback, _context) {
|
||||
setDestroyCallback(_callback, _context) {
|
||||
this._destroyCallback = _callback;
|
||||
this._destroyContext = _context;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Inserts all container nodes into the DOM tree after or before the given
|
||||
* element.
|
||||
@ -83,13 +81,13 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
* or after the given node. Inserting before is needed for inserting the
|
||||
* 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) {
|
||||
// Store the parent node and indicate that this element is now in
|
||||
// the tree.
|
||||
this._attachData = { node: _node, prepend: _prepend };
|
||||
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 (_prepend) {
|
||||
_node.before(this._nodes[0]);
|
||||
@ -107,28 +105,28 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
// parent
|
||||
this.invalidate();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Removes all container nodes from the tree.
|
||||
*/
|
||||
et2_dataview_container.prototype.removeFromTree = function () {
|
||||
removeFromTree() {
|
||||
if (this._inTree) {
|
||||
// Call the jQuery remove function to remove all nodes from the tree
|
||||
// again.
|
||||
for (var i = 0; i < this._nodes.length; i++) {
|
||||
for (let i = 0; i < this._nodes.length; i++) {
|
||||
this._nodes[i].remove();
|
||||
}
|
||||
// Reset the "attachData"
|
||||
this._inTree = false;
|
||||
this._attachData = { "node": null, "prepend": false };
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Appends a node to the container.
|
||||
*
|
||||
* @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
|
||||
this._nodes.push(_node);
|
||||
// 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();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Removes a certain node from the container
|
||||
*
|
||||
* @param {HTMLElement} _node
|
||||
*/
|
||||
et2_dataview_container.prototype.removeNode = function (_node) {
|
||||
removeNode(_node) {
|
||||
// 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) {
|
||||
// Remove the node if the container is currently attached
|
||||
if (this._inTree) {
|
||||
@ -164,35 +162,35 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
// Remove the node from the nodes array
|
||||
this._nodes.splice(idx, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the last node of the container - new nodes have to be appended
|
||||
* after it.
|
||||
*/
|
||||
et2_dataview_container.prototype.getLastNode = function () {
|
||||
getLastNode() {
|
||||
if (this._nodes.length > 0) {
|
||||
return this._nodes[this._nodes.length - 1];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the first node of the container.
|
||||
*/
|
||||
et2_dataview_container.prototype.getFirstNode = function () {
|
||||
getFirstNode() {
|
||||
return this._nodes.length > 0 ? this._nodes[0] : null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the accumulated height of all container nodes. Only visible nodes
|
||||
* (without "display: none" etc.) are taken into account.
|
||||
*/
|
||||
et2_dataview_container.prototype.getHeight = function () {
|
||||
getHeight() {
|
||||
if (this._height === -1 && this._inTree) {
|
||||
this._height = 0;
|
||||
// Setting this before measuring height helps with issues getting the
|
||||
// wrong height due to margins & collapsed borders
|
||||
this.tr.css('display', 'block');
|
||||
// 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])) {
|
||||
this._height += et2_dataview_container._nodeHeight(this._nodes[i][0]);
|
||||
}
|
||||
@ -200,7 +198,7 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
this.tr.css('display', '');
|
||||
}
|
||||
return (this._height === -1) ? 0 : this._height;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns a datastructure containing information used for calculating the
|
||||
* 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>
|
||||
* }
|
||||
*/
|
||||
et2_dataview_container.prototype.getAvgHeightData = function () {
|
||||
getAvgHeightData() {
|
||||
return {
|
||||
"avgHeight": this.getHeight(),
|
||||
"avgCount": 1
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the previously set "pixel top" of the container.
|
||||
*/
|
||||
et2_dataview_container.prototype.getTop = function () {
|
||||
getTop() {
|
||||
return this._top;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the "pixel bottom" of the container.
|
||||
*/
|
||||
et2_dataview_container.prototype.getBottom = function () {
|
||||
getBottom() {
|
||||
return this._top + this.getHeight();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the range of the element.
|
||||
*/
|
||||
et2_dataview_container.prototype.getRange = function () {
|
||||
getRange() {
|
||||
return et2_bounds(this.getTop(), this.getBottom());
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the index of the element.
|
||||
*/
|
||||
et2_dataview_container.prototype.getIndex = function () {
|
||||
getIndex() {
|
||||
return this._index;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns how many elements this container represents.
|
||||
*/
|
||||
et2_dataview_container.prototype.getCount = function () {
|
||||
getCount() {
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the top of the element.
|
||||
*
|
||||
* @param {number} _value
|
||||
*/
|
||||
et2_dataview_container.prototype.setTop = function (_value) {
|
||||
setTop(_value) {
|
||||
this._top = _value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the index of the element.
|
||||
*
|
||||
* @param {number} _value
|
||||
*/
|
||||
et2_dataview_container.prototype.setIndex = function (_value) {
|
||||
setIndex(_value) {
|
||||
this._index = _value;
|
||||
};
|
||||
}
|
||||
/* -- et2_dataview_IInvalidatable -- */
|
||||
/**
|
||||
* Broadcasts an invalidation through the container tree. Marks the own
|
||||
* height as invalid.
|
||||
*/
|
||||
et2_dataview_container.prototype.invalidate = function () {
|
||||
invalidate() {
|
||||
// Abort if this element is already marked as invalid.
|
||||
if (this._height !== -1) {
|
||||
// Delete the own, probably computed height
|
||||
@ -275,7 +273,7 @@ var et2_dataview_container = /** @class */ (function () {
|
||||
// Broadcast the invalidation to the parent element
|
||||
this._parent.invalidate();
|
||||
}
|
||||
};
|
||||
}
|
||||
/* -- PRIVATE FUNCTIONS -- */
|
||||
/**
|
||||
* 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
|
||||
* the given object is actually inside the DOM.
|
||||
*/
|
||||
et2_dataview_container._isVisible = function (_obj) {
|
||||
static _isVisible(_obj) {
|
||||
// Check whether the element is localy invisible
|
||||
if (_obj.style && (_obj.style.display === "none"
|
||||
|| _obj.style.visibility === "none")) {
|
||||
return false;
|
||||
}
|
||||
// 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
|
||||
: _obj.currentStyle;
|
||||
if (style.display === "none" || style.visibility === "none") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the height of a node in pixels and zero if the element is not
|
||||
* visible. The height is clamped to positive values.
|
||||
*
|
||||
* @param {HTMLElement} _node
|
||||
*/
|
||||
et2_dataview_container._nodeHeight = function (_node) {
|
||||
static _nodeHeight(_node) {
|
||||
return _node.offsetHeight;
|
||||
};
|
||||
return et2_dataview_container;
|
||||
}());
|
||||
exports.et2_dataview_container = et2_dataview_container;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_dataview_view_container.js.map
|
@ -4,9 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
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.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
/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_spacer} from "./et2_dataview_view_spacer";
|
||||
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
|
||||
{
|
||||
@ -65,16 +66,16 @@ export class et2_dataview_grid extends et2_dataview_container implements et2_dat
|
||||
private _invalidateTimeout: number;
|
||||
private _invalidateCallback: Function;
|
||||
private _invalidateContext: null;
|
||||
private doInvalidate : boolean;
|
||||
doInvalidate : boolean;
|
||||
|
||||
private _map: any[];
|
||||
private _viewRange: { top: any; bottom: any };
|
||||
private _total: number;
|
||||
_total: number;
|
||||
private _avgHeight: number | boolean;
|
||||
private _avgCount: number;
|
||||
|
||||
private scrollarea: any;
|
||||
private innerTbody: any;
|
||||
innerTbody: any;
|
||||
private outerCell: JQuery;
|
||||
|
||||
|
||||
@ -545,7 +546,7 @@ export class et2_dataview_grid extends et2_dataview_container implements et2_dat
|
||||
const self = this;
|
||||
const _super = super.invalidate();
|
||||
this._invalidateTimeout = window.setTimeout(function() {
|
||||
egw.debug("log","Dataview grid timed invalidate");
|
||||
this.egw.debug("log","Dataview grid timed invalidate");
|
||||
// Clear the "_avgHeight"
|
||||
self._avgHeight = false;
|
||||
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
|
||||
const isSpacer = container instanceof et2_dataview_spacer;
|
||||
const hasIViewRange = !isSpacer
|
||||
&& implements_et2_dataview_IViewRange(container);
|
||||
const hasIViewRange = !isSpacer && container.implements(et2_dataview_IViewRange);
|
||||
|
||||
// If the container has one of those special types, calculate the
|
||||
// view range and use that to update the view range of the element
|
||||
|
@ -1,30 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Functions which allow resizing of table headers
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview_view_resizable = void 0;
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* This set of functions is currently only supporting resizing in ew-direction
|
||||
*/
|
||||
var et2_dataview_view_resizable = /** @class */ (function () {
|
||||
function et2_dataview_view_resizable() {
|
||||
}
|
||||
export class et2_dataview_view_resizable {
|
||||
// In resize region returns whether the mouse is currently in the
|
||||
// "resizeRegion"
|
||||
et2_dataview_view_resizable.inResizeRegion = function (_x, _elem) {
|
||||
static inResizeRegion(_x, _elem) {
|
||||
var ol = _x - _elem.offset().left;
|
||||
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) {
|
||||
// Prevent text selection
|
||||
// FireFox handles highlight prevention (text selection) different than other browsers
|
||||
@ -67,8 +62,8 @@ var et2_dataview_view_resizable = /** @class */ (function () {
|
||||
}.bind(this))
|
||||
.appendTo("body");
|
||||
}
|
||||
};
|
||||
et2_dataview_view_resizable.stopResize = function (_outerElem) {
|
||||
}
|
||||
static stopResize(_outerElem) {
|
||||
jQuery(_outerElem).removeClass('egwResizing');
|
||||
if (this.helper != null) {
|
||||
this.helper.remove();
|
||||
@ -78,16 +73,17 @@ var et2_dataview_view_resizable = /** @class */ (function () {
|
||||
this.overlay.remove();
|
||||
this.overlay = null;
|
||||
}
|
||||
};
|
||||
// Define some constants
|
||||
et2_dataview_view_resizable.RESIZE_BORDER = 12;
|
||||
et2_dataview_view_resizable.RESIZE_MIN_WIDTH = 25;
|
||||
et2_dataview_view_resizable.RESIZE_ADD = 2; // Used to ensure mouse is under the resize element after resizing has finished
|
||||
et2_dataview_view_resizable.helper = null;
|
||||
et2_dataview_view_resizable.overlay = null;
|
||||
et2_dataview_view_resizable.didResize = false;
|
||||
et2_dataview_view_resizable.resizeWidth = 0;
|
||||
et2_dataview_view_resizable.makeResizeable = function (_elem, _callback, _context) {
|
||||
}
|
||||
}
|
||||
// Define some constants
|
||||
et2_dataview_view_resizable.RESIZE_BORDER = 12;
|
||||
et2_dataview_view_resizable.RESIZE_MIN_WIDTH = 25;
|
||||
et2_dataview_view_resizable.RESIZE_ADD = 2; // Used to ensure mouse is under the resize element after resizing has finished
|
||||
et2_dataview_view_resizable.helper = null;
|
||||
et2_dataview_view_resizable.overlay = null;
|
||||
et2_dataview_view_resizable.didResize = false;
|
||||
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
|
||||
// align the helper properly
|
||||
var outerTable = _elem.closest("table");
|
||||
@ -173,12 +169,9 @@ var et2_dataview_view_resizable = /** @class */ (function () {
|
||||
resize.css('width', '');
|
||||
_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
|
||||
_elem.unbind(".resize");
|
||||
};
|
||||
return et2_dataview_view_resizable;
|
||||
}());
|
||||
exports.et2_dataview_view_resizable = et2_dataview_view_resizable;
|
||||
};
|
||||
//# sourceMappingURL=et2_dataview_view_resizeable.js.map
|
@ -4,12 +4,13 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* This set of functions is currently only supporting resizing in ew-direction
|
||||
*/
|
||||
|
@ -1,69 +1,50 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - dataview
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
* @version $Id$
|
||||
*
|
||||
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
/*egw:uses
|
||||
egw_action.egw_action;
|
||||
|
||||
et2_dataview_view_container;
|
||||
*/
|
||||
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_row = void 0;
|
||||
var et2_dataview_row = /** @class */ (function (_super) {
|
||||
__extends(et2_dataview_row, _super);
|
||||
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 {
|
||||
/**
|
||||
* Creates the row container. Use the "setRow" function to load the actual
|
||||
* row content.
|
||||
*
|
||||
* @param _parent is the row parent container.
|
||||
*/
|
||||
function et2_dataview_row(_parent) {
|
||||
var _this =
|
||||
constructor(_parent) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent) || this;
|
||||
super(_parent);
|
||||
// Create the outer "tr" tag and append it to the container
|
||||
_this.tr = jQuery(document.createElement("tr"));
|
||||
_this.appendNode(_this.tr);
|
||||
this.tr = jQuery(document.createElement("tr"));
|
||||
this.appendNode(this.tr);
|
||||
// Grid row which gets expanded when clicking on the corresponding
|
||||
// button
|
||||
_this.expansionContainer = null;
|
||||
_this.expansionVisible = false;
|
||||
this.expansionContainer = null;
|
||||
this.expansionVisible = false;
|
||||
// Toggle button which is used to show and hide the expansionContainer
|
||||
_this.expansionButton = null;
|
||||
return _this;
|
||||
this.expansionButton = null;
|
||||
}
|
||||
et2_dataview_row.prototype.destroy = function () {
|
||||
destroy() {
|
||||
if (this.expansionContainer != null) {
|
||||
this.expansionContainer.destroy();
|
||||
}
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
et2_dataview_row.prototype.clear = function () {
|
||||
super.destroy();
|
||||
}
|
||||
clear() {
|
||||
this.tr.empty();
|
||||
};
|
||||
et2_dataview_row.prototype.makeExpandable = function (_expandable, _callback, _context) {
|
||||
}
|
||||
makeExpandable(_expandable, _callback, _context) {
|
||||
if (_expandable) {
|
||||
// Create the tr and the button if this has not been done yet
|
||||
if (!this.expansionButton) {
|
||||
@ -89,29 +70,29 @@ var et2_dataview_row = /** @class */ (function (_super) {
|
||||
this.expansionButton = null;
|
||||
this.expansionContainer = null;
|
||||
}
|
||||
};
|
||||
et2_dataview_row.prototype.removeFromTree = function () {
|
||||
}
|
||||
removeFromTree() {
|
||||
if (this.expansionContainer) {
|
||||
this.expansionContainer.removeFromTree();
|
||||
}
|
||||
this.expansionContainer = null;
|
||||
this.expansionButton = null;
|
||||
_super.prototype.removeFromTree.call(this);
|
||||
};
|
||||
et2_dataview_row.prototype.getDOMNode = function () {
|
||||
super.removeFromTree();
|
||||
}
|
||||
getDOMNode() {
|
||||
return this.tr[0];
|
||||
};
|
||||
et2_dataview_row.prototype.getJNode = function () {
|
||||
}
|
||||
getJNode() {
|
||||
return this.tr;
|
||||
};
|
||||
et2_dataview_row.prototype.getHeight = function () {
|
||||
var h = _super.prototype.getHeight.call(this);
|
||||
}
|
||||
getHeight() {
|
||||
var h = super.getHeight();
|
||||
if (this.expansionContainer && this.expansionVisible) {
|
||||
h += this.expansionContainer.getHeight();
|
||||
}
|
||||
return h;
|
||||
};
|
||||
et2_dataview_row.prototype.getAvgHeightData = function () {
|
||||
}
|
||||
getAvgHeightData() {
|
||||
// Only take the height of the own tr into account
|
||||
//var oldVisible = this.expansionVisible;
|
||||
this.expansionVisible = false;
|
||||
@ -121,9 +102,9 @@ var et2_dataview_row = /** @class */ (function (_super) {
|
||||
};
|
||||
this.expansionVisible = true;
|
||||
return res;
|
||||
};
|
||||
}
|
||||
/** -- PRIVATE FUNCTIONS -- **/
|
||||
et2_dataview_row.prototype._handleExpansionButtonClick = function (_callback, _context) {
|
||||
_handleExpansionButtonClick(_callback, _context) {
|
||||
// Create the "expansionContainer" if it does not exist yet
|
||||
if (!this.expansionContainer) {
|
||||
this.expansionContainer = _callback.call(_context);
|
||||
@ -143,19 +124,17 @@ var et2_dataview_row = /** @class */ (function (_super) {
|
||||
this.expansionButton.removeClass("opened");
|
||||
}
|
||||
this.invalidate();
|
||||
};
|
||||
}
|
||||
/** -- Implementation of et2_dataview_IViewRange -- **/
|
||||
et2_dataview_row.prototype.setViewRange = function (_range) {
|
||||
setViewRange(_range) {
|
||||
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
|
||||
var oh = jQuery(this._nodes[0]).height();
|
||||
_range.top -= oh;
|
||||
// Proxy the setViewRange call to the expansion container
|
||||
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
|
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011-2012
|
||||
* @version $Id$
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
egw_action.egw_action;
|
||||
@ -17,6 +16,7 @@
|
||||
*/
|
||||
|
||||
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
|
||||
{
|
||||
@ -189,7 +189,7 @@ export class et2_dataview_row extends et2_dataview_container implements et2_data
|
||||
setViewRange( _range)
|
||||
{
|
||||
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
|
||||
var oh = jQuery(this._nodes[0]).height();
|
||||
|
@ -1,17 +1,13 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Class which contains a factory method for rows
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dataview_rowProvider = void 0;
|
||||
/*egw:uses
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_inheritance;
|
||||
@ -23,13 +19,13 @@ exports.et2_dataview_rowProvider = void 0;
|
||||
* The row provider contains prototypes (full clonable dom-trees)
|
||||
* for all registered row types.
|
||||
*/
|
||||
var et2_dataview_rowProvider = /** @class */ (function () {
|
||||
export class et2_dataview_rowProvider {
|
||||
/**
|
||||
*
|
||||
* @param _outerId
|
||||
* @param _columnIds
|
||||
*/
|
||||
function et2_dataview_rowProvider(_outerId, _columnIds) {
|
||||
constructor(_outerId, _columnIds) {
|
||||
// Copy the given parameters
|
||||
this._outerId = _outerId;
|
||||
this._columnIds = _columnIds;
|
||||
@ -43,16 +39,16 @@ var et2_dataview_rowProvider = /** @class */ (function () {
|
||||
this._createEmptyPrototype();
|
||||
this._createLoadingPrototype();
|
||||
}
|
||||
et2_dataview_rowProvider.prototype.destroy = function () {
|
||||
destroy() {
|
||||
this._template = null;
|
||||
this._mgrs = null;
|
||||
this._rootWidget = null;
|
||||
this._prototypes = {};
|
||||
this._columnIds = [];
|
||||
};
|
||||
et2_dataview_rowProvider.prototype.getColumnCount = function () {
|
||||
}
|
||||
getColumnCount() {
|
||||
return this._columnIds.length;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns a clone of the prototype with the given name. If the generator
|
||||
* 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 {object} _context
|
||||
*/
|
||||
et2_dataview_rowProvider.prototype.getPrototype = function (_name, _generator, _context) {
|
||||
getPrototype(_name, _generator, _context) {
|
||||
if (typeof this._prototypes[_name] == "undefined") {
|
||||
if (typeof _generator != "undefined") {
|
||||
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();
|
||||
};
|
||||
}
|
||||
/* ---- PRIVATE FUNCTIONS ---- */
|
||||
et2_dataview_rowProvider.prototype._createFullRowPrototype = function () {
|
||||
_createFullRowPrototype() {
|
||||
var tr = jQuery(document.createElement("tr"));
|
||||
var td = jQuery(document.createElement("td"))
|
||||
.addClass(this._outerId + "_td_fullRow")
|
||||
@ -84,12 +80,11 @@ var et2_dataview_rowProvider = /** @class */ (function () {
|
||||
.addClass(this._outerId + "_div_fullRow")
|
||||
.appendTo(td);
|
||||
this._prototypes["fullRow"] = tr;
|
||||
};
|
||||
et2_dataview_rowProvider.prototype._createDefaultPrototype = function () {
|
||||
}
|
||||
_createDefaultPrototype() {
|
||||
var tr = jQuery(document.createElement("tr"));
|
||||
// Append a td for each column
|
||||
for (var _i = 0, _a = this._columnIds; _i < _a.length; _i++) {
|
||||
var column = _a[_i];
|
||||
for (var column of this._columnIds) {
|
||||
if (!column)
|
||||
continue;
|
||||
var td = jQuery(document.createElement("td"))
|
||||
@ -101,16 +96,14 @@ var et2_dataview_rowProvider = /** @class */ (function () {
|
||||
.appendTo(td);
|
||||
}
|
||||
this._prototypes["default"] = tr;
|
||||
};
|
||||
et2_dataview_rowProvider.prototype._createEmptyPrototype = function () {
|
||||
}
|
||||
_createEmptyPrototype() {
|
||||
this._prototypes["empty"] = jQuery(document.createElement("tr"));
|
||||
};
|
||||
et2_dataview_rowProvider.prototype._createLoadingPrototype = function () {
|
||||
}
|
||||
_createLoadingPrototype() {
|
||||
var fullRow = this.getPrototype("fullRow");
|
||||
jQuery("div", fullRow).addClass("loading");
|
||||
this._prototypes["loading"] = fullRow;
|
||||
};
|
||||
return et2_dataview_rowProvider;
|
||||
}());
|
||||
exports.et2_dataview_rowProvider = et2_dataview_rowProvider;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_dataview_view_rowProvider.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
|
@ -1,39 +1,22 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Class which contains the spacer container
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_dataview_view_container;
|
||||
*/
|
||||
import { et2_dataview_container } from "./et2_dataview_view_container";
|
||||
/**
|
||||
* @augments et2_dataview_container
|
||||
*/
|
||||
var et2_dataview_spacer = /** @class */ (function (_super) {
|
||||
__extends(et2_dataview_spacer, _super);
|
||||
export class et2_dataview_spacer extends et2_dataview_container {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -41,22 +24,20 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
|
||||
* @param _rowProvider
|
||||
* @memberOf et2_dataview_spacer
|
||||
*/
|
||||
function et2_dataview_spacer(_parent, _rowProvider) {
|
||||
var _this =
|
||||
constructor(_parent, _rowProvider) {
|
||||
// Call the inherited container constructor
|
||||
_super.call(this, _parent) || this;
|
||||
super(_parent);
|
||||
// Initialize the row count and the row height
|
||||
_this._count = 0;
|
||||
_this._rowHeight = 19;
|
||||
_this._avgSum = 0;
|
||||
_this._avgCount = 0;
|
||||
this._count = 0;
|
||||
this._rowHeight = 19;
|
||||
this._avgSum = 0;
|
||||
this._avgCount = 0;
|
||||
// Get the spacer row and append it to the container
|
||||
_this.spacerNode = _rowProvider.getPrototype("spacer", _this._createSpacerPrototype, _this);
|
||||
_this._phDiv = jQuery("td", _this.spacerNode);
|
||||
_this.appendNode(_this.spacerNode);
|
||||
return _this;
|
||||
this.spacerNode = _rowProvider.getPrototype("spacer", this._createSpacerPrototype, this);
|
||||
this._phDiv = jQuery("td", this.spacerNode);
|
||||
this.appendNode(this.spacerNode);
|
||||
}
|
||||
et2_dataview_spacer.prototype.setCount = function (_count, _rowHeight) {
|
||||
setCount(_count, _rowHeight) {
|
||||
// Set the new count and _rowHeight if given
|
||||
this._count = _count;
|
||||
if (typeof _rowHeight !== "undefined") {
|
||||
@ -66,16 +47,16 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
|
||||
this._phDiv.height(this._count * this._rowHeight);
|
||||
// Call the invalidate function
|
||||
this.invalidate();
|
||||
};
|
||||
et2_dataview_spacer.prototype.getCount = function () {
|
||||
}
|
||||
getCount() {
|
||||
return this._count;
|
||||
};
|
||||
et2_dataview_spacer.prototype.getHeight = function () {
|
||||
}
|
||||
getHeight() {
|
||||
// Set the calculated height, so that "invalidate" will work correctly
|
||||
this._height = this._count * this._rowHeight;
|
||||
return this._height;
|
||||
};
|
||||
et2_dataview_spacer.prototype.getAvgHeightData = function () {
|
||||
}
|
||||
getAvgHeightData() {
|
||||
if (this._avgCount > 0) {
|
||||
return {
|
||||
"avgHeight": this._avgSum / this._avgCount,
|
||||
@ -83,13 +64,13 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
et2_dataview_spacer.prototype.addAvgHeight = function (_height) {
|
||||
}
|
||||
addAvgHeight(_height) {
|
||||
this._avgSum += _height;
|
||||
this._avgCount++;
|
||||
};
|
||||
}
|
||||
/* ---- PRIVATE FUNCTIONS ---- */
|
||||
et2_dataview_spacer.prototype._createSpacerPrototype = function (_outerId, _columnIds) {
|
||||
_createSpacerPrototype(_outerId, _columnIds) {
|
||||
var tr = jQuery(document.createElement("tr"));
|
||||
var td = jQuery(document.createElement("td"))
|
||||
.addClass("egwGridView_spacer")
|
||||
@ -97,8 +78,6 @@ var et2_dataview_spacer = /** @class */ (function (_super) {
|
||||
.attr("colspan", _columnIds.length)
|
||||
.appendTo(tr);
|
||||
return tr;
|
||||
};
|
||||
return et2_dataview_spacer;
|
||||
}(et2_dataview_container));
|
||||
exports.et2_dataview_spacer = et2_dataview_spacer;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_dataview_view_spacer.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -15,6 +14,8 @@
|
||||
et2_dataview_view_container;
|
||||
*/
|
||||
|
||||
import {et2_dataview_container} from "./et2_dataview_view_container";
|
||||
|
||||
/**
|
||||
* @augments et2_dataview_container
|
||||
*/
|
||||
|
@ -1,34 +1,19 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - dataview code
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2014
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_dataview_interfaces;
|
||||
*/
|
||||
import { et2_dataview_row } from "./et2_dataview_view_row";
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
var et2_dataview_tile = /** @class */ (function (_super) {
|
||||
__extends(et2_dataview_tile, _super);
|
||||
export class et2_dataview_tile extends et2_dataview_row {
|
||||
/**
|
||||
* Creates the row container. Use the "setRow" function to load the actual
|
||||
* row content.
|
||||
@ -45,25 +29,23 @@ var et2_dataview_tile = /** @class */ (function (_super) {
|
||||
* @param _parent is the row parent container.
|
||||
* @memberOf et2_dataview_row
|
||||
*/
|
||||
function et2_dataview_tile(_parent) {
|
||||
var _this =
|
||||
constructor(_parent) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent) || this;
|
||||
_this.columns = 4;
|
||||
super(_parent);
|
||||
this.columns = 4;
|
||||
// Make sure the needed class is there to get the CSS
|
||||
_this.tr.addClass('tile');
|
||||
return _this;
|
||||
this.tr.addClass('tile');
|
||||
}
|
||||
et2_dataview_tile.prototype.makeExpandable = function (_expandable, _callback, _context) {
|
||||
makeExpandable(_expandable, _callback, _context) {
|
||||
// Nope. It mostly works, it's just weird.
|
||||
};
|
||||
et2_dataview_tile.prototype.getAvgHeightData = function () {
|
||||
}
|
||||
getAvgHeightData() {
|
||||
var res = {
|
||||
"avgHeight": this.getHeight() / this.columns,
|
||||
"avgCount": this.columns
|
||||
};
|
||||
return res;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @returns {Number}
|
||||
*/
|
||||
et2_dataview_tile.prototype.getHeight = function () {
|
||||
getHeight() {
|
||||
if (this._index % this.columns == 0) {
|
||||
return _super.prototype.getHeight.call(this);
|
||||
return super.getHeight();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Broadcasts an invalidation through the container tree. Marks the own
|
||||
* height as invalid.
|
||||
*/
|
||||
et2_dataview_tile.prototype.invalidate = function () {
|
||||
invalidate() {
|
||||
if (this._inTree && this.tr) {
|
||||
var template_width = jQuery('.innerContainer', this.tr).children().outerWidth(true);
|
||||
if (template_width) {
|
||||
@ -91,19 +73,17 @@ var et2_dataview_tile = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
this._recalculate_columns();
|
||||
_super.prototype.invalidate.call(this);
|
||||
};
|
||||
super.invalidate();
|
||||
}
|
||||
/**
|
||||
* Recalculate how many columns we can fit in a row.
|
||||
* While browser takes care of the actual layout, we need this for proper
|
||||
* pagination.
|
||||
*/
|
||||
et2_dataview_tile.prototype._recalculate_columns = function () {
|
||||
_recalculate_columns() {
|
||||
if (this._inTree && this.tr && this.tr.parent()) {
|
||||
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
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage dataview
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2014
|
||||
* @version $Id: et2_dataview_view_container_1.js 46338 2014-03-20 09:40:37Z ralfbecker $
|
||||
@ -15,6 +15,8 @@
|
||||
et2_dataview_interfaces;
|
||||
*/
|
||||
|
||||
import {et2_dataview_row} from "./et2_dataview_view_row";
|
||||
|
||||
/**
|
||||
* Displays tiles or thumbnails (squares) instead of full rows.
|
||||
*
|
||||
@ -22,7 +24,8 @@
|
||||
* 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;
|
||||
|
||||
/**
|
||||
|
@ -1,30 +1,13 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Custom fields object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
lib/tooltip;
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
@ -32,81 +15,81 @@ exports.et2_customfields_list = void 0;
|
||||
et2_core_DOMWidget;
|
||||
et2_core_inputWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
var et2_customfields_list = /** @class */ (function (_super) {
|
||||
__extends(et2_customfields_list, _super);
|
||||
function et2_customfields_list(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_customfields_list._attributes, _child || {})) || this;
|
||||
_this.rows = {};
|
||||
_this.widgets = {};
|
||||
_this.detachedNodes = [];
|
||||
import { et2_createWidget, et2_register_widget, et2_registry } from "./et2_core_widget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
import { et2_cloneObject, et2_no_init } from "./et2_core_common";
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
export class et2_customfields_list extends et2_valueWidget {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_customfields_list._attributes, _child || {}));
|
||||
this.rows = {};
|
||||
this.widgets = {};
|
||||
this.detachedNodes = [];
|
||||
// Some apps (infolog edit) don't give ID, so assign one to get settings
|
||||
if (!_this.id) {
|
||||
_this.id = _attrs.id = et2_customfields_list.DEFAULT_ID;
|
||||
if (!this.id) {
|
||||
this.id = _attrs.id = et2_customfields_list.DEFAULT_ID;
|
||||
// Add all attributes hidden in the content arrays to the attributes
|
||||
// parameter
|
||||
_this.transformAttributes(_attrs);
|
||||
this.transformAttributes(_attrs);
|
||||
// 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
|
||||
_this.tbody = jQuery(document.createElement("tbody"));
|
||||
_this.table = jQuery(document.createElement("table"))
|
||||
this.tbody = jQuery(document.createElement("tbody"));
|
||||
this.table = jQuery(document.createElement("table"))
|
||||
.addClass("et2_grid et2_customfield_list");
|
||||
_this.table.append(_this.tbody);
|
||||
if (!_this.options.fields)
|
||||
_this.options.fields = {};
|
||||
if (typeof _this.options.fields === 'string') {
|
||||
var fields = _this.options.fields.split(',');
|
||||
_this.options.fields = {};
|
||||
this.table.append(this.tbody);
|
||||
if (!this.options.fields)
|
||||
this.options.fields = {};
|
||||
if (typeof this.options.fields === 'string') {
|
||||
const fields = this.options.fields.split(',');
|
||||
this.options.fields = {};
|
||||
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") {
|
||||
_this.options.type_filter = _this.options.type_filter.split(",");
|
||||
if (this.options.type_filter && typeof this.options.type_filter == "string") {
|
||||
this.options.type_filter = this.options.type_filter.split(",");
|
||||
}
|
||||
if (_this.options.type_filter) {
|
||||
var already_filtered = !jQuery.isEmptyObject(_this.options.fields);
|
||||
for (var field_name in _this.options.customfields) {
|
||||
if (this.options.type_filter) {
|
||||
const already_filtered = !jQuery.isEmptyObject(this.options.fields);
|
||||
for (let field_name in this.options.customfields) {
|
||||
// Already excluded?
|
||||
if (already_filtered && !_this.options.fields[field_name])
|
||||
if (already_filtered && !this.options.fields[field_name])
|
||||
continue;
|
||||
if (!_this.options.customfields[field_name].type2 || _this.options.customfields[field_name].type2.length == 0 ||
|
||||
_this.options.customfields[field_name].type2 == '0') {
|
||||
if (!this.options.customfields[field_name].type2 || this.options.customfields[field_name].type2.length == 0 ||
|
||||
this.options.customfields[field_name].type2 == '0') {
|
||||
// No restrictions
|
||||
_this.options.fields[field_name] = true;
|
||||
this.options.fields[field_name] = true;
|
||||
continue;
|
||||
}
|
||||
var 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;
|
||||
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;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
if (jQuery.inArray(types[i], _this.options.type_filter) > -1) {
|
||||
_this.options.fields[field_name] = true;
|
||||
if (jQuery.inArray(types[i], this.options.type_filter) > -1) {
|
||||
this.options.fields[field_name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_this.setDOMNode(_this.table[0]);
|
||||
return _this;
|
||||
this.setDOMNode(this.table[0]);
|
||||
}
|
||||
et2_customfields_list.prototype.destroy = function () {
|
||||
_super.prototype.destroy.call(this);
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.rows = {};
|
||||
this.widgets = {};
|
||||
this.detachedNodes = [];
|
||||
this.tbody = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
et2_customfields_list.prototype.assign = function (_obj) {
|
||||
assign(_obj) {
|
||||
this.loadFields();
|
||||
};
|
||||
et2_customfields_list.prototype.getDOMNode = function (_sender) {
|
||||
}
|
||||
getDOMNode(_sender) {
|
||||
// Check whether the _sender object exists inside the management array
|
||||
if (this.rows && _sender.id && 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", "")]) {
|
||||
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
|
||||
*/
|
||||
et2_customfields_list.prototype.loadFields = function () {
|
||||
loadFields() {
|
||||
if (!this.options || !this.options.customfields)
|
||||
return;
|
||||
// Already set up - avoid duplicates in nextmatch
|
||||
@ -128,18 +111,18 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
if (!jQuery.isEmptyObject(this.widgets))
|
||||
return;
|
||||
// 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)
|
||||
this.options.fields = global_data.fields;
|
||||
// For checking app entries
|
||||
var apps = this.egw().link_app_list();
|
||||
const apps = this.egw().link_app_list();
|
||||
// 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
|
||||
if (this.getType() != 'customfields-list' && !jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name])
|
||||
continue;
|
||||
var field = this.options.customfields[field_name];
|
||||
var id = this.options.prefix + field_name;
|
||||
const field = this.options.customfields[field_name];
|
||||
let id = this.options.prefix + field_name;
|
||||
// Need curlies around ID for nm row expansion
|
||||
if (this.id == '$row') {
|
||||
id = "{" + this.id + "}" + "[" + this.options.prefix + field_name + "]";
|
||||
@ -150,15 +133,15 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
}
|
||||
// Avoid creating field twice
|
||||
if (!this.rows[id]) {
|
||||
var row = jQuery(document.createElement("tr"))
|
||||
const row = jQuery(document.createElement("tr"))
|
||||
.appendTo(this.tbody)
|
||||
.addClass(this.id + '_' + id);
|
||||
var cf = jQuery(document.createElement("td"))
|
||||
let cf = jQuery(document.createElement("td"))
|
||||
.appendTo(row);
|
||||
if (!field.type)
|
||||
field.type = 'text";';
|
||||
var setup_function = '_setup_' + (apps[field.type] ? 'link_entry' : field.type.replace("-", "_"));
|
||||
var attrs = jQuery.extend({}, this.options[field_name] ? this.options[field_name] : {}, {
|
||||
const setup_function = '_setup_' + (apps[field.type] ? 'link_entry' : field.type.replace("-", "_"));
|
||||
const attrs = jQuery.extend({}, this.options[field_name] ? this.options[field_name] : {}, {
|
||||
'id': id,
|
||||
'statustext': field.help,
|
||||
'needed': field.needed,
|
||||
@ -172,7 +155,7 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
attrs.onchange = this.options.onchange;
|
||||
}
|
||||
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)
|
||||
continue;
|
||||
}
|
||||
@ -193,19 +176,19 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
// Label in first column, widget in 2nd
|
||||
jQuery(document.createElement("td"))
|
||||
.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
|
||||
if (['select', 'radio', 'radiogroup', 'checkbox', 'button'].indexOf(field.type) == -1 && !jQuery.isEmptyObject(field.values)) {
|
||||
var w = et2_registry[attrs.type ? attrs.type : field.type];
|
||||
for (var attr_name in field.values) {
|
||||
const w = et2_registry[attrs.type ? attrs.type : field.type];
|
||||
for (let attr_name in field.values) {
|
||||
if (typeof w._attributes[attr_name] != "undefined") {
|
||||
attrs[attr_name] = field.values[attr_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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
|
||||
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();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Read needed info on available custom fields from various places it's stored.
|
||||
*/
|
||||
et2_customfields_list.prototype.transformAttributes = function (_attrs) {
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
transformAttributes(_attrs) {
|
||||
super.transformAttributes(_attrs);
|
||||
// Add in settings that are objects
|
||||
// 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
|
||||
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) {
|
||||
for (var key_1 in data) {
|
||||
for (let key in data) {
|
||||
// Don't overwrite fields with global values
|
||||
if (global_data[key_1] && key_1 !== 'fields') {
|
||||
data[key_1] = jQuery.extend(true, {}, data[key_1], global_data[key_1]);
|
||||
if (global_data[key] && key !== 'fields') {
|
||||
data[key] = jQuery.extend(true, {}, data[key], global_data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var key in data) {
|
||||
_attrs[key] = data[key];
|
||||
}
|
||||
for (var key_2 in global_data) {
|
||||
if (typeof global_data[key_2] != 'undefined' && !_attrs[key_2])
|
||||
_attrs[key_2] = global_data[key_2];
|
||||
for (let key in global_data) {
|
||||
if (typeof global_data[key] != 'undefined' && !_attrs[key])
|
||||
_attrs[key] = global_data[key];
|
||||
}
|
||||
if (this.id) {
|
||||
// Set the value for this element
|
||||
var contentMgr = this.getArrayMgr("content");
|
||||
const contentMgr = this.getArrayMgr("content");
|
||||
if (contentMgr != null) {
|
||||
var val = contentMgr.getEntry(this.id);
|
||||
const val = contentMgr.getEntry(this.id);
|
||||
_attrs["value"] = {};
|
||||
var prefix = _attrs["prefix"] || et2_customfields_list.PREFIX;
|
||||
let prefix = _attrs["prefix"] || et2_customfields_list.PREFIX;
|
||||
if (val !== null) {
|
||||
if (this.id.indexOf(prefix) === 0 && typeof data.fields != 'undefined' && data.fields[this.id.replace(prefix, '')] === true) {
|
||||
_attrs['value'][this.id] = val;
|
||||
}
|
||||
else {
|
||||
// Only set the values that match desired custom fields
|
||||
for (var key_3 in val) {
|
||||
if (key_3.indexOf(prefix) === 0) {
|
||||
_attrs["value"][key_3] = val[key_3];
|
||||
for (let key in val) {
|
||||
if (key.indexOf(prefix) === 0) {
|
||||
_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();
|
||||
// Load the nodes as usual
|
||||
_super.prototype.loadFromXML.call(this, _node);
|
||||
};
|
||||
et2_customfields_list.prototype.set_value = function (_value) {
|
||||
super.loadFromXML(_node);
|
||||
}
|
||||
set_value(_value) {
|
||||
if (!this.options.customfields)
|
||||
return;
|
||||
for (var field_name in this.options.customfields) {
|
||||
for (let field_name in this.options.customfields) {
|
||||
// Skip fields if we're filtering
|
||||
if (!jQuery.isEmptyObject(this.options.fields) && !this.options.fields[field_name])
|
||||
continue;
|
||||
// Make sure widget is created, and has the needed function
|
||||
if (!this.widgets[field_name] || !this.widgets[field_name].set_value)
|
||||
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
|
||||
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);
|
||||
@ -303,43 +286,43 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
}
|
||||
this.widgets[field_name].set_value(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
if (this.id != et2_customfields_list.DEFAULT_ID) {
|
||||
return null;
|
||||
}
|
||||
var value = {};
|
||||
for (var field_name in this.widgets) {
|
||||
const value = {};
|
||||
for (let field_name in this.widgets) {
|
||||
if (this.widgets[field_name].getValue && !this.widgets[field_name].options.readonly) {
|
||||
value[this.options.prefix + field_name] = this.widgets[field_name].getValue();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
};
|
||||
et2_customfields_list.prototype.isDirty = function () {
|
||||
var dirty = false;
|
||||
for (var field_name in this.widgets) {
|
||||
}
|
||||
isDirty() {
|
||||
let dirty = false;
|
||||
for (let field_name in this.widgets) {
|
||||
if (this.widgets[field_name].isDirty) {
|
||||
dirty = dirty || this.widgets[field_name].isDirty();
|
||||
}
|
||||
}
|
||||
return dirty;
|
||||
};
|
||||
et2_customfields_list.prototype.resetDirty = function () {
|
||||
for (var field_name in this.widgets) {
|
||||
}
|
||||
resetDirty() {
|
||||
for (let field_name in this.widgets) {
|
||||
if (this.widgets[field_name].resetDirty) {
|
||||
this.widgets[field_name].resetDirty();
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_customfields_list.prototype.isValid = function () {
|
||||
}
|
||||
isValid() {
|
||||
// Individual customfields will handle themselves
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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 = 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
|
||||
delete (attrs.label);
|
||||
field.type = 'textbox';
|
||||
@ -358,33 +341,32 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
attrs.maxlength = field.len;
|
||||
}
|
||||
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
|
||||
delete (attrs.label);
|
||||
var defaults = {
|
||||
let defaults = {
|
||||
viewable: true,
|
||||
plaintext: false,
|
||||
suggest: 16
|
||||
};
|
||||
for (var _i = 0, _a = Object.keys(defaults); _i < _a.length; _i++) {
|
||||
var key = _a[_i];
|
||||
for (let key of Object.keys(defaults)) {
|
||||
attrs[key] = (field.values && typeof field.values[key] !== "undefined") ? field.values[key] : defaults[key];
|
||||
}
|
||||
return true;
|
||||
};
|
||||
et2_customfields_list.prototype._setup_ajax_select = function (field_name, field, attrs) {
|
||||
var attributes = ['get_rows', 'get_title', 'id_field', 'template'];
|
||||
}
|
||||
_setup_ajax_select(field_name, field, attrs) {
|
||||
const attributes = ['get_rows', 'get_title', 'id_field', 'template'];
|
||||
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') {
|
||||
attrs[attributes[i]] = field.values[attributes[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
delete (attrs.label);
|
||||
field.type = 'float';
|
||||
@ -392,31 +374,31 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
attrs.size = field.len;
|
||||
}
|
||||
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
|
||||
delete (attrs.label);
|
||||
attrs.rows = field.rows;
|
||||
// select_options are now send from server-side incl. ones defined via a file in EGroupware root
|
||||
attrs.tags = field.tags;
|
||||
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');
|
||||
if (field.account_type) {
|
||||
attrs.account_type = field.account_type;
|
||||
}
|
||||
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';
|
||||
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';
|
||||
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.toolbarStartupExpanded = false;
|
||||
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';
|
||||
// We have to push the config modifications into the modifications array, or they'll
|
||||
// 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)
|
||||
jQuery.extend(data.config, attrs.config);
|
||||
return true;
|
||||
};
|
||||
et2_customfields_list.prototype._setup_radio = function (field_name, field, attrs) {
|
||||
}
|
||||
_setup_radio(field_name, field, attrs) {
|
||||
// 'Empty' label will be first
|
||||
delete (attrs.label);
|
||||
if (field.values && field.values['']) {
|
||||
@ -440,8 +422,8 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
field.type = 'radiogroup';
|
||||
attrs.options = field.values;
|
||||
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
|
||||
if (attrs.readonly && this.getType() !== "customfields") {
|
||||
attrs.ro_true = field.label;
|
||||
@ -453,12 +435,12 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
attrs.ro_false = field.ro_false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* People set button attributes as
|
||||
* 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
|
||||
delete (attrs.label);
|
||||
attrs.label = field.label;
|
||||
@ -468,9 +450,9 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
}
|
||||
// Simple case, one widget for a custom field
|
||||
if (!field.values || typeof field.values != 'object' || Object.keys(field.values).length == 1) {
|
||||
for (var key_4 in field.values) {
|
||||
attrs.label = key_4;
|
||||
attrs.onclick = field.values[key_4];
|
||||
for (let key in field.values) {
|
||||
attrs.label = key;
|
||||
attrs.onclick = field.values[key];
|
||||
}
|
||||
if (!attrs.label) {
|
||||
attrs.label = 'No "label=onclick" in values!';
|
||||
@ -481,26 +463,26 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
else {
|
||||
// Complicated case, a single custom field you get multiple widgets
|
||||
// Handle it all here, since this is the exception
|
||||
var row = jQuery('tr', this.tbody).last();
|
||||
var cf = jQuery('td', row);
|
||||
const row = jQuery('tr', this.tbody).last();
|
||||
let cf = jQuery('td', row);
|
||||
// Label in first column, widget in 2nd
|
||||
cf.text(field.label + "");
|
||||
cf = jQuery(document.createElement("td"))
|
||||
.appendTo(row);
|
||||
for (var key in field.values) {
|
||||
var button_attrs = jQuery.extend({}, attrs);
|
||||
const button_attrs = jQuery.extend({}, attrs);
|
||||
button_attrs.label = key;
|
||||
button_attrs.onclick = field.values[key];
|
||||
button_attrs.id = attrs.id + '_' + key;
|
||||
// This controls where the button is placed in the DOM
|
||||
this.rows[button_attrs.id] = cf[0];
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
et2_customfields_list.prototype._setup_link_entry = function (field_name, field, attrs) {
|
||||
}
|
||||
_setup_link_entry(field_name, field, attrs) {
|
||||
if (field.type === 'filemanager') {
|
||||
return this._setup_filemanager(field_name, field, attrs);
|
||||
}
|
||||
@ -509,8 +491,8 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
attrs.type = "link-entry";
|
||||
attrs.only_app = typeof field.only_app == "undefined" ? field.type : field.only_app;
|
||||
return true;
|
||||
};
|
||||
et2_customfields_list.prototype._setup_filemanager = function (field_name, field, attrs) {
|
||||
}
|
||||
_setup_filemanager(field_name, field, attrs) {
|
||||
attrs.type = 'vfs-upload';
|
||||
delete (attrs.label);
|
||||
if (this.getType() == 'customfields-list') {
|
||||
@ -520,19 +502,19 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
else {
|
||||
// Complicated case, a single custom field you get multiple widgets
|
||||
// Handle it all here, since this is the exception
|
||||
var row = jQuery('tr', this.tbody).last();
|
||||
var cf = jQuery('td', row);
|
||||
const row = jQuery('tr', this.tbody).last();
|
||||
let cf = jQuery('td', row);
|
||||
// Label in first column, widget in 2nd
|
||||
cf.text(field.label + "");
|
||||
cf = jQuery(document.createElement("td"))
|
||||
.appendTo(row);
|
||||
// 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.rows[attrs.id] = cf[0];
|
||||
jQuery(widget.getDOMNode(widget)).css('vertical-align', 'top');
|
||||
// Add a link to existing VFS file
|
||||
var select_attrs = jQuery.extend({}, attrs,
|
||||
const select_attrs = jQuery.extend({}, attrs,
|
||||
// Filemanager select
|
||||
{
|
||||
label: '',
|
||||
@ -545,61 +527,62 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
// This controls where the button is placed in the DOM
|
||||
this.rows[select_attrs.id] = cf[0];
|
||||
// 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);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Display links in list as CF name
|
||||
* @param field_name
|
||||
* @param field
|
||||
* @param attrs
|
||||
*/
|
||||
et2_customfields_list.prototype._setup_url = function (field_name, field, attrs) {
|
||||
_setup_url(field_name, field, attrs) {
|
||||
if (this.getType() == 'customfields-list') {
|
||||
attrs.label = field.label;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set which fields are visible, by name
|
||||
*
|
||||
* Note: no # prefix on the name
|
||||
*
|
||||
*/
|
||||
et2_customfields_list.prototype.set_visible = function (_fields) {
|
||||
for (var name_1 in _fields) {
|
||||
if (this.rows[this.options.prefix + name_1]) {
|
||||
if (_fields[name_1]) {
|
||||
jQuery(this.rows[this.options.prefix + name_1]).show();
|
||||
set_visible(_fields) {
|
||||
for (let name in _fields) {
|
||||
if (this.rows[this.options.prefix + name]) {
|
||||
if (_fields[name]) {
|
||||
jQuery(this.rows[this.options.prefix + name]).show();
|
||||
}
|
||||
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
|
||||
*/
|
||||
et2_customfields_list.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value", "class");
|
||||
};
|
||||
et2_customfields_list.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
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
|
||||
// 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
|
||||
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);
|
||||
}
|
||||
};
|
||||
et2_customfields_list._attributes = {
|
||||
}
|
||||
}
|
||||
et2_customfields_list._attributes = {
|
||||
'customfields': {
|
||||
'name': 'Custom fields',
|
||||
'description': 'Auto filled',
|
||||
@ -644,12 +627,9 @@ var et2_customfields_list = /** @class */ (function (_super) {
|
||||
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.PREFIX = '#';
|
||||
et2_customfields_list.DEFAULT_ID = "custom_fields";
|
||||
return et2_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"]);
|
||||
};
|
||||
et2_customfields_list.legacyOptions = ["type_filter", "private", "fields"]; // Field restriction & private done server-side
|
||||
et2_customfields_list.PREFIX = '#';
|
||||
et2_customfields_list.DEFAULT_ID = "custom_fields";
|
||||
et2_register_widget(et2_customfields_list, ["customfields", "customfields-list"]);
|
||||
//# sourceMappingURL=et2_extension_customfields.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -18,10 +17,14 @@
|
||||
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 {et2_valueWidget} from "./et2_core_valueWidget";
|
||||
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
|
||||
{
|
||||
@ -80,7 +83,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
private tbody: JQuery;
|
||||
private table: JQuery;
|
||||
private rows = {};
|
||||
private widgets = {};
|
||||
widgets = {};
|
||||
private detachedNodes = [];
|
||||
|
||||
constructor(_parent?, _attrs? : WidgetConfig, _child? : object)
|
||||
@ -713,7 +716,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
.appendTo(row);
|
||||
|
||||
// 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.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];
|
||||
|
||||
// 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);
|
||||
}
|
||||
return false;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Christian Binder
|
||||
* @author Nathan Gray
|
||||
* @copyright 2012 Christian Binder
|
||||
@ -13,8 +13,8 @@
|
||||
*/
|
||||
function itempickerDocumentAction(context, data) {
|
||||
"use strict";
|
||||
var formid = "itempicker_action_form";
|
||||
var form = "<form id='" + formid + "' action='index.php?menuaction=" + data.app + "." + data.app + "_merge.download_by_request' method='POST'>"
|
||||
let formid = "itempicker_action_form";
|
||||
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_dir' value='" + data.value.dir + "' />"
|
||||
+ "<input type='hidden' name='data_checked' value='" + data.checked.join(',') + "' />"
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Christian Binder
|
||||
* @author Nathan Gray
|
||||
* @copyright 2012 Christian Binder
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
|
||||
@ -41,8 +40,8 @@
|
||||
|
||||
*/
|
||||
|
||||
import './et2_core_common';
|
||||
import './et2_core_interfaces';
|
||||
import {et2_csvSplit, et2_no_init} from "./et2_core_common";
|
||||
import {et2_IInput, et2_IPrint, et2_IResizeable, implements_methods, et2_implements_registry} from "./et2_core_interfaces";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget";
|
||||
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_searchbox} from "./et2_widget_textbox";
|
||||
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";
|
||||
|
||||
@ -82,8 +83,8 @@ export interface et2_INextmatchHeader {
|
||||
*/
|
||||
setNextmatch(nextmatch : et2_nextmatch) : void
|
||||
}
|
||||
var et2_INextmatchHeader = "et2_INextmatchHeader";
|
||||
function implements_et2_INextmatchHeader(obj : et2_widget)
|
||||
export const et2_INextmatchHeader = "et2_INextmatchHeader";
|
||||
et2_implements_registry.et2_INextmatchHeader = function(obj : et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["setNextmatch"]);
|
||||
}
|
||||
@ -93,9 +94,8 @@ export interface et2_INextmatchSortable
|
||||
setSortmode(_sort_mode): void
|
||||
}
|
||||
|
||||
var et2_INextmatchSortable = "et2_INextmatchSortable";
|
||||
|
||||
function implements_et2_INextmatchSortable(obj: et2_widget)
|
||||
export const et2_INextmatchSortable = "et2_INextmatchSortable";
|
||||
et2_implements_registry.et2_INextmatchSortable = function(obj: et2_widget)
|
||||
{
|
||||
return implements_methods(obj, ["setSortmode"]);
|
||||
}
|
||||
@ -3105,7 +3105,7 @@ et2_register_widget(et2_nextmatch, ["nextmatch"]);
|
||||
* actually load templates from the server.
|
||||
* @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 = {
|
||||
"filter_label": {
|
||||
@ -4298,7 +4298,7 @@ et2_register_widget(et2_nextmatch_accountfilterheader, ['nextmatch-accountfilter
|
||||
*
|
||||
* @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 = {
|
||||
autocomplete_url: { default: ''},
|
||||
@ -4386,7 +4386,7 @@ et2_register_widget(et2_nextmatch_taglistheader, ['nextmatch-taglistheader']);
|
||||
/**
|
||||
* 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
|
||||
@ -4461,7 +4461,7 @@ et2_register_widget(et2_nextmatch_entryheader, ['nextmatch-entryheader']);
|
||||
/**
|
||||
* @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 = {
|
||||
"widget_type": {
|
||||
|
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||
* @copyright Stylite AG 2012-14
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2012-2021
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,53 +1,22 @@
|
||||
"use strict";
|
||||
/**
|
||||
* 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
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @version $Id$
|
||||
*
|
||||
|
||||
/*egw:uses
|
||||
et2_core_common;
|
||||
et2_core_inheritance;
|
||||
|
||||
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");
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
import { et2_dataview_row } from "./et2_dataview_view_row";
|
||||
import { et2_dataview_tile } from "./et2_dataview_view_tile";
|
||||
import { et2_dataview_controller } from "./et2_dataview_controller";
|
||||
import { et2_dataview_column } from "./et2_dataview_model_columns";
|
||||
import { framework } from "../jsapi/egw_global";
|
||||
/**
|
||||
* @augments et2_dataview_controller
|
||||
*/
|
||||
var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
__extends(et2_nextmatch_controller, _super);
|
||||
export class et2_nextmatch_controller extends et2_dataview_controller {
|
||||
/**
|
||||
* Initializes the nextmatch controller.
|
||||
*
|
||||
@ -64,62 +33,60 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
* is given.
|
||||
* @memberOf et2_nextmatch_controller
|
||||
*/
|
||||
function et2_nextmatch_controller(_parentController, _egw, _execId, _widget, _parentId, _grid, _rowProvider, _actionLinks, _objectManager, _actions) {
|
||||
var _this =
|
||||
constructor(_parentController, _egw, _execId, _widget, _parentId, _grid, _rowProvider, _actionLinks, _objectManager, _actions) {
|
||||
// Call the parent et2_dataview_controller constructor
|
||||
_super.call(this, _parentController, _grid) || this;
|
||||
_this.setDataProvider(_this);
|
||||
_this.setRowCallback(_this._rowCallback);
|
||||
_this.setLinkCallback(_this._linkCallback);
|
||||
_this.setContext(_this);
|
||||
super(_parentController, _grid);
|
||||
this.setDataProvider(this);
|
||||
this.setRowCallback(this._rowCallback);
|
||||
this.setLinkCallback(this._linkCallback);
|
||||
this.setContext(this);
|
||||
// Copy the egw reference
|
||||
_this.egw = _egw;
|
||||
this.egw = _egw;
|
||||
// Keep a reference to the widget
|
||||
_this._widget = _widget;
|
||||
this._widget = _widget;
|
||||
// Copy the given parameters
|
||||
_this._actionLinks = _actionLinks;
|
||||
_this._execId = _execId;
|
||||
this._actionLinks = _actionLinks;
|
||||
this._execId = _execId;
|
||||
// Get full widget ID, including path
|
||||
var id = _widget.getArrayMgr('content').getPath();
|
||||
if (typeof id == 'string') {
|
||||
_this._widgetId = id;
|
||||
this._widgetId = id;
|
||||
}
|
||||
else if (id.length === 1) {
|
||||
_this._widgetId = id[0];
|
||||
this._widgetId = id[0];
|
||||
}
|
||||
else {
|
||||
_this._widgetId = id.shift() + '[' + id.join('][') + ']';
|
||||
this._widgetId = id.shift() + '[' + id.join('][') + ']';
|
||||
}
|
||||
_this._parentId = _parentId;
|
||||
_this._rowProvider = _rowProvider;
|
||||
this._parentId = _parentId;
|
||||
this._rowProvider = _rowProvider;
|
||||
// Initialize the action and the object manager
|
||||
// _initActions calls _init_link_dnd, which uses this._actionLinks,
|
||||
// so this must happen after the above parameter copying
|
||||
if (!_objectManager) {
|
||||
_this._initActions(_actions);
|
||||
this._initActions(_actions);
|
||||
}
|
||||
else {
|
||||
_this._actionManager = null;
|
||||
_this._objectManager = _objectManager;
|
||||
this._actionManager = null;
|
||||
this._objectManager = _objectManager;
|
||||
}
|
||||
_this.setActionObjectManager(_this._objectManager);
|
||||
this.setActionObjectManager(this._objectManager);
|
||||
// Add our selection callback to selection manager
|
||||
var self = _this;
|
||||
_this._objectManager.setSelectedCallback = function () { self._selectCallback.apply(self, [this, arguments]); };
|
||||
var self = this;
|
||||
this._objectManager.setSelectedCallback = function () { self._selectCallback.apply(self, [this, arguments]); };
|
||||
// We start with no filters
|
||||
_this._filters = {};
|
||||
this._filters = {};
|
||||
// Keep selection across filter changes
|
||||
_this.kept_selection = null;
|
||||
_this.kept_focus = null;
|
||||
_this.kept_expansion = [];
|
||||
this.kept_selection = null;
|
||||
this.kept_focus = null;
|
||||
this.kept_expansion = [];
|
||||
// Directly use the API-Implementation of dataRegisterUID and
|
||||
// dataUnregisterUID
|
||||
_this.dataUnregisterUID = _egw.dataUnregisterUID;
|
||||
this.dataUnregisterUID = _egw.dataUnregisterUID;
|
||||
// Default to rows
|
||||
_this._view = et2_nextmatch_controller.VIEW_ROW;
|
||||
return _this;
|
||||
this._view = et2_nextmatch_controller.VIEW_ROW;
|
||||
}
|
||||
et2_nextmatch_controller.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// If the actionManager variable is set, the object- and actionManager
|
||||
// were created by this instance -- clear them
|
||||
if (this._actionManager) {
|
||||
@ -127,20 +94,20 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
this._actionManager.remove();
|
||||
}
|
||||
this._widget = null;
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
super.destroy();
|
||||
}
|
||||
/**
|
||||
* Updates the filter instance.
|
||||
*/
|
||||
et2_nextmatch_controller.prototype.setFilters = function (_filters) {
|
||||
setFilters(_filters) {
|
||||
// Update the filters
|
||||
this._filters = _filters;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Keep the selection, if possible, across a data fetch and restore it
|
||||
* after
|
||||
*/
|
||||
et2_nextmatch_controller.prototype.keepSelection = function () {
|
||||
keepSelection() {
|
||||
this.kept_selection = this._selectionMgr ? this._selectionMgr.getSelected() : null;
|
||||
this.kept_focus = this._selectionMgr && this._selectionMgr._focusedEntry ?
|
||||
this._selectionMgr._focusedEntry.uid || null : null;
|
||||
@ -153,17 +120,17 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
controller.kept_expansion.push(entry.uid);
|
||||
}
|
||||
});
|
||||
};
|
||||
et2_nextmatch_controller.prototype.getObjectManager = function () {
|
||||
}
|
||||
getObjectManager() {
|
||||
return this._objectManager;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Deletes a row from the grid
|
||||
*
|
||||
* @param {string} uid
|
||||
*/
|
||||
et2_nextmatch_controller.prototype.deleteRow = function (uid) {
|
||||
var entry = Object.values(this._indexMap).find(function (entry) { return entry.uid == uid; });
|
||||
deleteRow(uid) {
|
||||
var entry = Object.values(this._indexMap).find(entry => entry.uid == uid);
|
||||
// Unselect
|
||||
this._selectionMgr.setSelected(uid, false);
|
||||
if (entry && entry.idx !== null) {
|
||||
@ -192,11 +159,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
// Not needed, they share by reference
|
||||
// this._selectionMgr.setIndexMap(this._indexMap);
|
||||
}
|
||||
for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
|
||||
var child = _a[_i];
|
||||
for (let child of this._children) {
|
||||
child.deleteRow(uid);
|
||||
}
|
||||
};
|
||||
}
|
||||
/** -- PRIVATE FUNCTIONS -- **/
|
||||
/**
|
||||
* Create a new row, either normal or tiled
|
||||
@ -204,10 +170,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
* @param {type} ctx
|
||||
* @returns {et2_dataview_container}
|
||||
*/
|
||||
et2_nextmatch_controller.prototype._createRow = function (ctx) {
|
||||
_createRow(ctx) {
|
||||
switch (this._view) {
|
||||
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
|
||||
// applied properly, leading to incomplete rows
|
||||
window.setTimeout(function () {
|
||||
@ -223,13 +189,13 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
return row;
|
||||
case et2_nextmatch_controller.VIEW_ROW:
|
||||
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.
|
||||
*/
|
||||
et2_nextmatch_controller.prototype._initActions = function (_actions) {
|
||||
_initActions(_actions) {
|
||||
// Generate a uid for the action and object manager
|
||||
var uid = this._widget.id || this.egw.uid();
|
||||
if (_actions == null)
|
||||
@ -303,11 +269,11 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Automatically add dnd support for linking
|
||||
*/
|
||||
et2_nextmatch_controller.prototype._init_links_dnd = function () {
|
||||
_init_links_dnd() {
|
||||
var mgr = this._actionManager;
|
||||
var self = this;
|
||||
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);
|
||||
}
|
||||
drag_action.set_dragType('link');
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the data cache prefix
|
||||
* Overridden from the parent to re-check automatically the added link dnd
|
||||
* since the prefix is used in support detection.
|
||||
*/
|
||||
et2_nextmatch_controller.prototype.setPrefix = function (prefix) {
|
||||
_super.prototype.setPrefix.call(this, prefix);
|
||||
setPrefix(prefix) {
|
||||
super.setPrefix(prefix);
|
||||
this._init_links_dnd();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Overwrites the inherited _destroyCallback function in order to be able
|
||||
* to free the "rowWidget".
|
||||
*/
|
||||
et2_nextmatch_controller.prototype._destroyCallback = function (_row) {
|
||||
_destroyCallback(_row) {
|
||||
// Destroy any widget associated to the row
|
||||
if (this.entry.widget) {
|
||||
this.entry.widget.destroy();
|
||||
this.entry.widget = null;
|
||||
}
|
||||
// Call the inherited function
|
||||
_super.prototype._destroyCallback.call(this, _row);
|
||||
};
|
||||
super._destroyCallback(_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
|
||||
* 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
|
||||
// rowWidget inside the _entry
|
||||
_entry.widget = this._rowProvider.getDataRow({ "content": _data }, _tr, _idx, this);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
@ -458,7 +424,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
*
|
||||
* @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() != "") {
|
||||
return this._actionLinks;
|
||||
}
|
||||
@ -486,13 +452,13 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
catch (e) {
|
||||
}
|
||||
return links;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Overridden from the parent to also process any additional data that
|
||||
* the data source adds, such as readonlys and additonal content.
|
||||
* 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;
|
||||
if (!nm) {
|
||||
// Nextmatch either not connected, or it tried to destroy this
|
||||
@ -542,7 +508,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
col_refresh = true;
|
||||
nm.dataview.columnMgr.getColumnById('col_' + column_index)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
@ -558,7 +524,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
this.self.keepSelection();
|
||||
}
|
||||
// Call the inherited function
|
||||
_super.prototype._fetchCallback.apply(this, arguments);
|
||||
super._fetchCallback.apply(this, arguments);
|
||||
// Restore selection, if passed
|
||||
if (this.self && this.self.kept_selection && this.self._selectionMgr) {
|
||||
if (this.self.kept_selection.all) {
|
||||
@ -584,11 +550,11 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
}
|
||||
this.self.kept_focus = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Execute the select callback when the row selection changes
|
||||
*/
|
||||
et2_nextmatch_controller.prototype._selectCallback = function (action, senders) {
|
||||
_selectCallback(action, senders) {
|
||||
if (typeof senders == "undefined") {
|
||||
senders = [];
|
||||
}
|
||||
@ -598,9 +564,9 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
if (egwIsMobile())
|
||||
framework.nm_onselect_ctrl(this._widget, action, senders);
|
||||
this._widget.onselect.call(this._widget, action, senders);
|
||||
};
|
||||
}
|
||||
/** -- 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
|
||||
if (this._parentId !== null) {
|
||||
_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
|
||||
// nextmatch instance into the call.
|
||||
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
|
||||
if (this._widget && this._widget._get_appname() != this.egw.getAppName()) {
|
||||
_context.prefix = _uid.split('::')[0];
|
||||
}
|
||||
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
|
||||
};
|
||||
// Display constants
|
||||
et2_nextmatch_controller.VIEW_ROW = 'row';
|
||||
et2_nextmatch_controller.VIEW_TILE = 'tile';
|
||||
return et2_nextmatch_controller;
|
||||
}(et2_dataview_controller_1.et2_dataview_controller));
|
||||
exports.et2_nextmatch_controller = et2_nextmatch_controller;
|
||||
}
|
||||
}
|
||||
// Display constants
|
||||
et2_nextmatch_controller.VIEW_ROW = 'row';
|
||||
et2_nextmatch_controller.VIEW_TILE = 'tile';
|
||||
//# sourceMappingURL=et2_extension_nextmatch_controller.js.map
|
@ -4,11 +4,10 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @version $Id$
|
||||
*
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
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_dataview_controller} from "./et2_dataview_controller";
|
||||
import {et2_dataview_column} from "./et2_dataview_model_columns";
|
||||
import {framework, Iegw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* @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';
|
||||
|
||||
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.
|
||||
|
@ -1,30 +1,13 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Class which contains a factory method for rows
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_inheritance;
|
||||
@ -33,14 +16,17 @@ exports.et2_nextmatch_rowProvider = void 0;
|
||||
et2_core_widget;
|
||||
et2_dataview_view_rowProvider;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_arrayMgr_1 = require("./et2_core_arrayMgr");
|
||||
import { et2_widget } from "./et2_core_widget";
|
||||
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)
|
||||
* for all registered row types.
|
||||
*
|
||||
*/
|
||||
var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
export class et2_nextmatch_rowProvider {
|
||||
/**
|
||||
* Creates the nextmatch row provider.
|
||||
*
|
||||
@ -49,7 +35,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
* @param {object} _context
|
||||
* @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 "
|
||||
*
|
||||
@ -68,12 +54,12 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
this._context = _context;
|
||||
this._createEmptyPrototype();
|
||||
}
|
||||
et2_nextmatch_rowProvider.prototype.destroy = function () {
|
||||
destroy() {
|
||||
this._rowProvider.destroy();
|
||||
this._subgridCallback = null;
|
||||
this._context = null;
|
||||
this._dataRow = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* the nextmatch)
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype.setDataRowTemplate = function (_widgets, _rowData, _rootWidget) {
|
||||
setDataRowTemplate(_widgets, _rowData, _rootWidget) {
|
||||
// Copy the root widget
|
||||
this._rootWidget = _rootWidget;
|
||||
// Create the base row
|
||||
@ -118,12 +104,12 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
row.children().each(function () { tmpl.appendChild(this); });
|
||||
this._dataRow = tmpl;
|
||||
this._template = rowTemplate;
|
||||
};
|
||||
et2_nextmatch_rowProvider.prototype.getDataRow = function (_data, _row, _idx, _controller) {
|
||||
}
|
||||
getDataRow(_data, _row, _idx, _controller) {
|
||||
// Clone the row template
|
||||
var row = this._dataRow.cloneNode(true);
|
||||
// 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
|
||||
// to set the _data directly
|
||||
var rowWidget = null;
|
||||
@ -200,7 +186,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
// Set the row data
|
||||
this._setRowData(this._template.rowData, tr, mgrs);
|
||||
return rowWidget;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* 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 placeholder = jQuery(document.createElement("td"))
|
||||
.attr("colspan", this._rowProvider.getColumnCount())
|
||||
@ -217,16 +203,16 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
this._rowProvider._prototypes["empty"] = jQuery(document.createElement("tr"))
|
||||
.addClass("egwGridView_empty")
|
||||
.append(placeholder);
|
||||
};
|
||||
}
|
||||
/** -- PRIVATE FUNCTIONS -- **/
|
||||
/**
|
||||
* Returns an array containing objects which have variable attributes
|
||||
*
|
||||
* @param {et2_widget} _widget
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype._getVariableAttributeSet = function (_widget) {
|
||||
var variableAttributes = [];
|
||||
var process = function (_widget) {
|
||||
_getVariableAttributeSet(_widget) {
|
||||
let variableAttributes = [];
|
||||
const process = function (_widget) {
|
||||
// Create the attribtues
|
||||
var hasAttr = false;
|
||||
var widgetData = {
|
||||
@ -234,10 +220,10 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
"data": []
|
||||
};
|
||||
// Get all attribute values
|
||||
for (var key in _widget.attributes) {
|
||||
for (const key in _widget.attributes) {
|
||||
if (!_widget.attributes[key].ignore &&
|
||||
typeof _widget.options[key] != "undefined") {
|
||||
var val = _widget.options[key];
|
||||
const val = _widget.options[key];
|
||||
// TODO: Improve detection
|
||||
if (typeof val == "string" && val.indexOf("$") >= 0) {
|
||||
hasAttr = true;
|
||||
@ -254,7 +240,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
}
|
||||
};
|
||||
// Check each column
|
||||
var columns = _widget._widgets;
|
||||
const columns = _widget._widgets;
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
// 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) {
|
||||
@ -263,8 +249,8 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
columns[i].iterateOver(process, this);
|
||||
}
|
||||
return variableAttributes;
|
||||
};
|
||||
et2_nextmatch_rowProvider.prototype._seperateWidgets = function (_varAttrs) {
|
||||
}
|
||||
_seperateWidgets(_varAttrs) {
|
||||
// The detachable array contains all widgets which implement the
|
||||
// et2_IDetachedDOM interface for all needed attributes
|
||||
var detachable = [];
|
||||
@ -324,13 +310,13 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
"detachable": detachable,
|
||||
"remaining": remaining
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Removes to DOM code for all widgets in the "remaining" slot
|
||||
*
|
||||
* @param {object} _rowTemplate
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype._stripTemplateRow = function (_rowTemplate) {
|
||||
_stripTemplateRow(_rowTemplate) {
|
||||
_rowTemplate.placeholders = [];
|
||||
for (var i = 0; i < _rowTemplate.seperated.remaining.length; 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) {
|
||||
return 0;
|
||||
}
|
||||
@ -365,14 +351,14 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns a function which does a relative access on the given DOM-Node
|
||||
*
|
||||
* @param {DOMElement} _root
|
||||
* @param {DOMElement} _target
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype._compileDOMAccessFunc = function (_root, _target) {
|
||||
_compileDOMAccessFunc(_root, _target) {
|
||||
function recordPath(_root, _target, _path) {
|
||||
if (typeof _path == "undefined") {
|
||||
_path = [];
|
||||
@ -394,13 +380,13 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
return new Function("_node", recordPath.call(this, _root, _target));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Builds relative paths to the DOM-Nodes and compiles fast-access functions
|
||||
*
|
||||
* @param {object} _rowTemplate
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype._buildNodeAccessFuncs = function (_rowTemplate) {
|
||||
_buildNodeAccessFuncs(_rowTemplate) {
|
||||
for (var i = 0; i < _rowTemplate.seperated.detachable.length; i++) {
|
||||
var entry = _rowTemplate.seperated.detachable[i];
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Applies additional row data (like the class) to the tr
|
||||
*
|
||||
@ -419,7 +405,7 @@ var et2_nextmatch_rowProvider = /** @class */ (function () {
|
||||
* @param {DOMElement} _tr
|
||||
* @param {object} _mgrs
|
||||
*/
|
||||
et2_nextmatch_rowProvider.prototype._setRowData = function (_data, _tr, _mgrs) {
|
||||
_setRowData(_data, _tr, _mgrs) {
|
||||
// TODO: Implement other fields than "class"
|
||||
if (_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"]);
|
||||
_tr.setAttribute("valign", align);
|
||||
}
|
||||
};
|
||||
return et2_nextmatch_rowProvider;
|
||||
}());
|
||||
exports.et2_nextmatch_rowProvider = et2_nextmatch_rowProvider;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @augments et2_widget
|
||||
*/
|
||||
var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_nextmatch_rowWidget, _super);
|
||||
export class et2_nextmatch_rowWidget extends et2_widget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -465,16 +448,14 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
|
||||
* @param _row
|
||||
* @memberOf et2_nextmatch_rowWidget
|
||||
*/
|
||||
function et2_nextmatch_rowWidget(_mgrs, _row) {
|
||||
var _this =
|
||||
constructor(_mgrs, _row) {
|
||||
// Call the parent constructor with some dummy attributes
|
||||
_super.call(this, null, { "id": "", "type": "rowWidget" }) || this;
|
||||
super(null, { "id": "", "type": "rowWidget" });
|
||||
// Initialize some variables
|
||||
_this._widgets = [];
|
||||
this._widgets = [];
|
||||
// Copy the given DOM node and the content arrays
|
||||
_this._mgrs = _mgrs;
|
||||
_this._row = _row;
|
||||
return _this;
|
||||
this._mgrs = _mgrs;
|
||||
this._row = _row;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_nextmatch_rowWidget.prototype.createWidgets = function (_widgets) {
|
||||
createWidgets(_widgets) {
|
||||
// Clone the given the widgets with this element as parent
|
||||
this._widgets = [];
|
||||
var row_id = 0;
|
||||
let row_id = 0;
|
||||
for (var i = 0; i < _widgets.length; i++) {
|
||||
// Disabled columns might be missing widget - skip it
|
||||
if (!_widgets[i])
|
||||
@ -498,14 +479,14 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
|
||||
}
|
||||
row_id++;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the column node for the given sender
|
||||
*
|
||||
* @param {et2_widget} _sender
|
||||
* @return {DOMElement}
|
||||
*/
|
||||
et2_nextmatch_rowWidget.prototype.getDOMNode = function (_sender) {
|
||||
getDOMNode(_sender) {
|
||||
var row_id = 0;
|
||||
for (var i = 0; i < this._widgets.length; i++) {
|
||||
// Disabled columns might be missing widget - skip it
|
||||
@ -517,14 +498,12 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) {
|
||||
row_id++;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
return et2_nextmatch_rowWidget;
|
||||
}(et2_core_widget_1.et2_widget));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @augments et2_widget
|
||||
*/
|
||||
var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) {
|
||||
__extends(et2_nextmatch_rowTemplateWidget, _super);
|
||||
export class et2_nextmatch_rowTemplateWidget extends et2_widget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -532,20 +511,18 @@ var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) {
|
||||
* @param _row
|
||||
* @memberOf et2_nextmatch_rowTemplateWidget
|
||||
*/
|
||||
function et2_nextmatch_rowTemplateWidget(_root, _row) {
|
||||
var _this =
|
||||
constructor(_root, _row) {
|
||||
// Call the parent constructor with some dummy attributes
|
||||
_super.call(this, null, { "id": "", "type": "rowTemplateWidget" }) || this;
|
||||
_this._root = _root;
|
||||
_this._mgrs = {};
|
||||
_this._row = _row;
|
||||
super(null, { "id": "", "type": "rowTemplateWidget" });
|
||||
this._root = _root;
|
||||
this._mgrs = {};
|
||||
this._row = _row;
|
||||
// Set parent to root widget, so sub-widget calls still work
|
||||
_this._parent = _root;
|
||||
this._parent = _root;
|
||||
// Clone the widgets inside the placeholders array
|
||||
_this._widgets = [];
|
||||
return _this;
|
||||
this._widgets = [];
|
||||
}
|
||||
et2_nextmatch_rowTemplateWidget.prototype.createWidgets = function (_mgrs, _widgets) {
|
||||
createWidgets(_mgrs, _widgets) {
|
||||
// Set the array managers - don't use setArrayMgrs here as this creates
|
||||
// an unnecessary copy of the object
|
||||
this._mgrs = _mgrs;
|
||||
@ -558,21 +535,20 @@ var et2_nextmatch_rowTemplateWidget = /** @class */ (function (_super) {
|
||||
};
|
||||
this._widgets[i].widget.loadingFinished();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the column node for the given sender
|
||||
*
|
||||
* @param {et2_widget} _sender
|
||||
* @return {DOMElement}
|
||||
*/
|
||||
et2_nextmatch_rowTemplateWidget.prototype.getDOMNode = function (_sender) {
|
||||
getDOMNode(_sender) {
|
||||
for (var i = 0; i < this._widgets.length; i++) {
|
||||
if (this._widgets[i].widget == _sender) {
|
||||
return this._widgets[i].node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
return et2_nextmatch_rowTemplateWidget;
|
||||
}(et2_core_widget_1.et2_widget));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_extension_nextmatch_rowProvider.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2012
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -21,6 +20,9 @@
|
||||
|
||||
import {et2_widget} from "./et2_core_widget";
|
||||
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)
|
||||
@ -590,7 +592,7 @@ export class et2_nextmatch_rowProvider
|
||||
/**
|
||||
* @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 _row: any;
|
||||
@ -669,7 +671,7 @@ class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode
|
||||
/**
|
||||
* @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 _row: any;
|
||||
|
@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
/**
|
||||
|
||||
* 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
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
/vendor/bower-asset/jquery-ui/jquery-ui.js;
|
||||
et2_core_inputWidget;
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
var et2_widget_selectbox_1 = require("./et2_widget_selectbox");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
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,
|
||||
* 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.
|
||||
* @augments et2_inputWidget
|
||||
*/
|
||||
var et2_ajaxSelect = /** @class */ (function (_super) {
|
||||
__extends(et2_ajaxSelect, _super);
|
||||
export class et2_ajaxSelect extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_ajaxSelect
|
||||
*/
|
||||
function et2_ajaxSelect(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_ajaxSelect._attributes, _child || {})) || this;
|
||||
_this.input = null;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_ajaxSelect._attributes, _child || {}));
|
||||
this.input = null;
|
||||
if (typeof _attrs.get_rows == 'string') {
|
||||
_attrs.get_rows = _this.egw().link('/index.php', {
|
||||
menuaction: _this.options.get_rows
|
||||
_attrs.get_rows = this.egw().link('/index.php', {
|
||||
menuaction: this.options.get_rows
|
||||
});
|
||||
}
|
||||
_this.createInputWidget();
|
||||
_this.input = null;
|
||||
_this.createInputWidget();
|
||||
return _this;
|
||||
this.createInputWidget();
|
||||
this.input = null;
|
||||
this.createInputWidget();
|
||||
}
|
||||
et2_ajaxSelect.prototype.createInputWidget = function () {
|
||||
createInputWidget() {
|
||||
this.input = jQuery(document.createElement("input"));
|
||||
this.input.addClass("et2_textbox");
|
||||
this.setDOMNode(this.input[0]);
|
||||
var widget = this;
|
||||
let widget = this;
|
||||
this.input.autocomplete({
|
||||
delay: 100,
|
||||
source: 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) {
|
||||
widget.value = ui.item[widget.options.id_field];
|
||||
if (widget.options.get_title) {
|
||||
@ -93,18 +75,18 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
et2_ajaxSelect.prototype.getValue = function () {
|
||||
}
|
||||
getValue() {
|
||||
if (this.options.blur && this.input.val() == this.options.blur)
|
||||
return "";
|
||||
return this.value;
|
||||
};
|
||||
et2_ajaxSelect.prototype.set_value = function (_value) {
|
||||
}
|
||||
set_value(_value) {
|
||||
this.value = _value;
|
||||
if (this.input.autocomplete('instance')) {
|
||||
var source = this.input.autocomplete('option', 'source');
|
||||
let source = this.input.autocomplete('option', 'source');
|
||||
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) {
|
||||
this.input.val(source[i].label);
|
||||
}
|
||||
@ -118,8 +100,8 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_ajaxSelect.prototype.set_blur = function (_value) {
|
||||
}
|
||||
set_blur(_value) {
|
||||
if (_value) {
|
||||
this.input.attr("placeholder", _value + ""); // HTML5
|
||||
if (!this.input[0]["placeholder"]) {
|
||||
@ -138,8 +120,9 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.input.removeAttr("placeholder");
|
||||
}
|
||||
};
|
||||
et2_ajaxSelect._attributes = {
|
||||
}
|
||||
}
|
||||
et2_ajaxSelect._attributes = {
|
||||
'get_rows': {
|
||||
"name": "Data source",
|
||||
"type": "any",
|
||||
@ -189,60 +172,54 @@ var et2_ajaxSelect = /** @class */ (function (_super) {
|
||||
"default": {},
|
||||
"description": "Specify the available options. Use this, or Data source."
|
||||
}
|
||||
};
|
||||
return et2_ajaxSelect;
|
||||
}(et2_core_inputWidget_1.et2_inputWidget));
|
||||
et2_core_widget_1.et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
|
||||
};
|
||||
et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
|
||||
/**
|
||||
* et2_textbox_ro is the dummy readonly implementation of the textbox.
|
||||
* @augments et2_valueWidget
|
||||
*/
|
||||
var et2_ajaxSelect_ro = /** @class */ (function (_super) {
|
||||
__extends(et2_ajaxSelect_ro, _super);
|
||||
export class et2_ajaxSelect_ro extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_ajaxSelect_ro
|
||||
*/
|
||||
function et2_ajaxSelect_ro(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_ajaxSelect_ro._attributes, _child || {})) || this;
|
||||
_this.value = "";
|
||||
_this.span = jQuery(document.createElement("span"));
|
||||
_this.setDOMNode(_this.span[0]);
|
||||
return _this;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_ajaxSelect_ro._attributes, _child || {}));
|
||||
this.value = "";
|
||||
this.span = jQuery(document.createElement("span"));
|
||||
this.setDOMNode(this.span[0]);
|
||||
}
|
||||
et2_ajaxSelect_ro.prototype.set_value = function (_value) {
|
||||
set_value(_value) {
|
||||
this.value = _value;
|
||||
if (!_value)
|
||||
_value = "";
|
||||
this.span.text(_value);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
*/
|
||||
et2_ajaxSelect_ro.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value");
|
||||
};
|
||||
et2_ajaxSelect_ro.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.span[0]];
|
||||
};
|
||||
et2_ajaxSelect_ro.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
this.span = jQuery(_nodes[0]);
|
||||
if (typeof _values["value"] != 'undefined') {
|
||||
this.set_value(_values["value"]);
|
||||
}
|
||||
};
|
||||
/**
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ignore all more advanced attributes.
|
||||
*/
|
||||
et2_ajaxSelect_ro._attributes = {
|
||||
et2_ajaxSelect_ro._attributes = {
|
||||
"multiline": {
|
||||
"ignore": true
|
||||
}
|
||||
};
|
||||
return et2_ajaxSelect_ro;
|
||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||
et2_core_widget_1.et2_register_widget(et2_ajaxSelect_ro, ["ajax_select_ro"]);
|
||||
};
|
||||
et2_register_widget(et2_ajaxSelect_ro, ["ajax_select_ro"]);
|
||||
//# sourceMappingURL=et2_widget_ajaxSelect.js.map
|
@ -5,7 +5,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2012
|
||||
*/
|
||||
@ -22,6 +22,7 @@ import {et2_inputWidget} from "./et2_core_inputWidget";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_valueWidget} from "./et2_core_valueWidget";
|
||||
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,
|
||||
@ -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.
|
||||
* @augments et2_inputWidget
|
||||
*/
|
||||
class et2_ajaxSelect extends et2_inputWidget
|
||||
export class et2_ajaxSelect extends et2_inputWidget
|
||||
{
|
||||
static readonly _attributes : any = {
|
||||
'get_rows': {
|
||||
@ -204,7 +205,7 @@ et2_register_widget(et2_ajaxSelect, ["ajax_select"]);
|
||||
* et2_textbox_ro is the dummy readonly implementation of the textbox.
|
||||
* @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.
|
||||
|
@ -1,38 +1,21 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Audio tag
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Hadi Nategh <hn[at]egroupware.org>
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_interfaces;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
import { et2_baseWidget } from './et2_core_baseWidget';
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
var et2_audio = /** @class */ (function (_super) {
|
||||
__extends(et2_audio, _super);
|
||||
function et2_audio(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_audio._attributes, _child || {})) || this;
|
||||
_this.audio = null;
|
||||
_this.container = null;
|
||||
export class et2_audio extends et2_baseWidget {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_audio._attributes, _child || {}));
|
||||
this.audio = null;
|
||||
this.container = null;
|
||||
//Create Audio tag
|
||||
_this.audio = new Audio();
|
||||
this.audio = new Audio();
|
||||
// Container
|
||||
_this.container = document.createElement('div');
|
||||
_this.container.append(_this.audio);
|
||||
_this.container.classList.add('et2_audio');
|
||||
if (_this.options.autohide)
|
||||
_this.container.classList.add('et2_audio_autohide');
|
||||
if (_this.options.controls)
|
||||
_this.audio.setAttribute("controls", '1');
|
||||
if (_this.options.autoplay)
|
||||
_this.audio.setAttribute("autoplay", '1');
|
||||
if (_this.options.muted)
|
||||
_this.audio.setAttribute("muted", '1');
|
||||
if (_this.options.loop)
|
||||
_this.audio.setAttribute("loop", '1');
|
||||
if (_this.options.preload)
|
||||
_this.audio.setAttribute('preload', _this.options.preload);
|
||||
_this.setDOMNode(_this.container);
|
||||
return _this;
|
||||
this.container = document.createElement('div');
|
||||
this.container.append(this.audio);
|
||||
this.container.classList.add('et2_audio');
|
||||
if (this.options.autohide)
|
||||
this.container.classList.add('et2_audio_autohide');
|
||||
if (this.options.controls)
|
||||
this.audio.setAttribute("controls", '1');
|
||||
if (this.options.autoplay)
|
||||
this.audio.setAttribute("autoplay", '1');
|
||||
if (this.options.muted)
|
||||
this.audio.setAttribute("muted", '1');
|
||||
if (this.options.loop)
|
||||
this.audio.setAttribute("loop", '1');
|
||||
if (this.options.preload)
|
||||
this.audio.setAttribute('preload', this.options.preload);
|
||||
this.setDOMNode(this.container);
|
||||
}
|
||||
/**
|
||||
* Set audio source
|
||||
*
|
||||
* @param {string} _value url
|
||||
*/
|
||||
et2_audio.prototype.set_src = function (_value) {
|
||||
set_src(_value) {
|
||||
if (_value) {
|
||||
this.audio.setAttribute('src', _value);
|
||||
if (this.options.src_type) {
|
||||
@ -101,23 +82,24 @@ var et2_audio = /** @class */ (function (_super) {
|
||||
if (this.options.preload != "none")
|
||||
this.audio.load();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @return Promise
|
||||
*/
|
||||
et2_audio.prototype.play = function () {
|
||||
play() {
|
||||
return this.audio.play();
|
||||
};
|
||||
et2_audio.prototype.pause = function () {
|
||||
}
|
||||
pause() {
|
||||
this.audio.pause();
|
||||
};
|
||||
et2_audio.prototype.currentTime = function () {
|
||||
}
|
||||
currentTime() {
|
||||
return this.audio.currentTime;
|
||||
};
|
||||
et2_audio.prototype.seek = function (_time) {
|
||||
}
|
||||
seek(_time) {
|
||||
this.audio.currentTime = _time;
|
||||
};
|
||||
et2_audio._attributes = {
|
||||
}
|
||||
}
|
||||
et2_audio._attributes = {
|
||||
"src": {
|
||||
"name": "Audio",
|
||||
"type": "string",
|
||||
@ -164,9 +146,6 @@ var et2_audio = /** @class */ (function (_super) {
|
||||
"default": 'auto',
|
||||
"description": "preloads audio source based on given option. none(do not preload), auto(preload), metadata(preload metadata only)."
|
||||
}
|
||||
};
|
||||
return et2_audio;
|
||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||
exports.et2_audio = et2_audio;
|
||||
et2_core_widget_1.et2_register_widget(et2_audio, ["audio"]);
|
||||
};
|
||||
et2_register_widget(et2_audio, ["audio"]);
|
||||
//# sourceMappingURL=et2_widget_audio.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Hadi Nategh <hn[at]egroupware.org>
|
||||
* @copyright EGroupware GmbH
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -19,6 +18,7 @@
|
||||
import { et2_baseWidget } from './et2_core_baseWidget'
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
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
|
||||
|
@ -1,30 +1,13 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS barcode widget
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Hadi Nategh <hn[at]stylite.de>
|
||||
* @copyright Stylite AG
|
||||
* @version $Id:$
|
||||
* @copyright EGroupware GmbH
|
||||
*/
|
||||
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
|
||||
/vendor/bower-asset/jquery/dist/jquery.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
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
/**
|
||||
* Class which implements the "barcode" XET-Tag
|
||||
*
|
||||
*/
|
||||
var et2_barcode = /** @class */ (function (_super) {
|
||||
__extends(et2_barcode, _super);
|
||||
export class et2_barcode extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_barcode(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_barcode._attributes, _child || {})) || this;
|
||||
_this.div = jQuery(document.createElement('div')).attr({ class: 'et2_barcode' });
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_barcode._attributes, _child || {}));
|
||||
this.div = jQuery(document.createElement('div')).attr({ class: 'et2_barcode' });
|
||||
// Set domid
|
||||
_this.set_id(_this.id);
|
||||
_this.setDOMNode(_this.div[0]);
|
||||
_this.createWidget();
|
||||
return _this;
|
||||
this.set_id(this.id);
|
||||
this.setDOMNode(this.div[0]);
|
||||
this.createWidget();
|
||||
}
|
||||
et2_barcode.prototype.createWidget = function () {
|
||||
createWidget() {
|
||||
this.settings = {
|
||||
output: this.options.format,
|
||||
bgColor: this.options.bgColor,
|
||||
@ -87,35 +67,36 @@ var et2_barcode = /** @class */ (function (_super) {
|
||||
// @ts-ignore
|
||||
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') {
|
||||
this.value = _val;
|
||||
this.createWidget();
|
||||
}
|
||||
};
|
||||
// Class Constants
|
||||
/*
|
||||
}
|
||||
}
|
||||
// Class Constants
|
||||
/*
|
||||
* type const
|
||||
*/
|
||||
et2_barcode.TYPE_CODEBAR = "codebar";
|
||||
et2_barcode.TYPE_CODE11 = "code11"; //(code 11)
|
||||
et2_barcode.TYPE_CODE39 = "code39"; //(code 39)
|
||||
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_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_INT25 = "int25"; //(interleaved 2 of 5)
|
||||
et2_barcode.TYPE_MSI = "msi";
|
||||
et2_barcode.TYPE_DATAMATRIX = "datamatrix"; //(ASCII + extended) - http://barcode-coder.com/en/datamatrix-specification-104.html
|
||||
/**
|
||||
et2_barcode.TYPE_CODEBAR = "codebar";
|
||||
et2_barcode.TYPE_CODE11 = "code11"; //(code 11)
|
||||
et2_barcode.TYPE_CODE39 = "code39"; //(code 39)
|
||||
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_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_INT25 = "int25"; //(interleaved 2 of 5)
|
||||
et2_barcode.TYPE_MSI = "msi";
|
||||
et2_barcode.TYPE_DATAMATRIX = "datamatrix"; //(ASCII + extended) - http://barcode-coder.com/en/datamatrix-specification-104.html
|
||||
/**
|
||||
* Formats consts
|
||||
*/
|
||||
et2_barcode.FORMAT_CSS = "css";
|
||||
et2_barcode.FORMAT_SVG = "svg";
|
||||
et2_barcode.FORMAT_bmp = "bmp";
|
||||
et2_barcode.FORMAT_CANVAS = "canvas";
|
||||
et2_barcode._attributes = {
|
||||
et2_barcode.FORMAT_CSS = "css";
|
||||
et2_barcode.FORMAT_SVG = "svg";
|
||||
et2_barcode.FORMAT_bmp = "bmp";
|
||||
et2_barcode.FORMAT_CANVAS = "canvas";
|
||||
et2_barcode._attributes = {
|
||||
"code_type": {
|
||||
"name": "code type",
|
||||
"type": "string",
|
||||
@ -152,9 +133,6 @@ var et2_barcode = /** @class */ (function (_super) {
|
||||
"default": '50',
|
||||
"description": "Defines heigh of each bar in the barcode."
|
||||
},
|
||||
};
|
||||
return et2_barcode;
|
||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||
exports.et2_barcode = et2_barcode;
|
||||
et2_core_widget_1.et2_register_widget(et2_barcode, ["barcode"]);
|
||||
};
|
||||
et2_register_widget(et2_barcode, ["barcode"]);
|
||||
//# sourceMappingURL=et2_widget_barcode.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Hadi Nategh <hn[at]stylite.de>
|
||||
* @copyright Stylite AG
|
||||
* @version $Id:$
|
||||
* @copyright EGroupware GmbH
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
|
@ -1,36 +1,20 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Box object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_baseWidget } from "./et2_core_baseWidget";
|
||||
import { et2_readAttrWithDefault } from "./et2_core_xml";
|
||||
/**
|
||||
* Class which implements box and vbox tag
|
||||
*
|
||||
@ -39,33 +23,31 @@ var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
*
|
||||
* @augments et2_baseWidget
|
||||
*/
|
||||
var et2_box = /** @class */ (function (_super) {
|
||||
__extends(et2_box, _super);
|
||||
export class et2_box extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_box
|
||||
*/
|
||||
function et2_box(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, _child) || this;
|
||||
_this.div = jQuery(document.createElement("div"))
|
||||
.addClass("et2_" + _this.getType())
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, _child);
|
||||
this.div = jQuery(document.createElement("div"))
|
||||
.addClass("et2_" + this.getType())
|
||||
.addClass("et2_box_widget");
|
||||
_this.setDOMNode(_this.div[0]);
|
||||
return _this;
|
||||
this.setDOMNode(this.div[0]);
|
||||
}
|
||||
et2_box.prototype._createNamespace = function () {
|
||||
_createNamespace() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Overriden so we can check for autorepeating children. We only check for
|
||||
* $ in the immediate children & grandchildren of this node.
|
||||
*
|
||||
* @param {object} _node
|
||||
*/
|
||||
et2_box.prototype.loadFromXML = function (_node) {
|
||||
loadFromXML(_node) {
|
||||
if (this.getType() != "box") {
|
||||
return _super.prototype.loadFromXML.call(this, _node);
|
||||
return super.loadFromXML(_node);
|
||||
}
|
||||
// Load the child nodes.
|
||||
var childIndex = 0;
|
||||
@ -111,7 +93,7 @@ var et2_box = /** @class */ (function (_super) {
|
||||
this.getArrayMgr(name).setPerspectiveData(currentPerspective);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
* 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
|
||||
*/
|
||||
et2_box.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push('data');
|
||||
};
|
||||
et2_box.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.getDOMNode()];
|
||||
};
|
||||
et2_box.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
if (_values.data) {
|
||||
var pairs = _values.data.split(/,/g);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_box._attributes = {
|
||||
}
|
||||
}
|
||||
et2_box._attributes = {
|
||||
// Not needed
|
||||
"rows": { "ignore": true },
|
||||
"cols": { "ignore": true }
|
||||
};
|
||||
return et2_box;
|
||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||
exports.et2_box = et2_box;
|
||||
et2_core_widget_1.et2_register_widget(et2_box, ["vbox", "box"]);
|
||||
};
|
||||
et2_register_widget(et2_box, ["vbox", "box"]);
|
||||
/**
|
||||
* Details widget implementation
|
||||
* 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/>
|
||||
*
|
||||
*/
|
||||
var et2_details = /** @class */ (function (_super) {
|
||||
__extends(et2_details, _super);
|
||||
function et2_details(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, _child) || this;
|
||||
_this.div = jQuery(document.createElement('div')).addClass('et2_details');
|
||||
_this.title = jQuery(document.createElement('span'))
|
||||
export class et2_details extends et2_box {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, _child);
|
||||
this.div = jQuery(document.createElement('div')).addClass('et2_details');
|
||||
this.title = jQuery(document.createElement('span'))
|
||||
.addClass('et2_label et2_details_title')
|
||||
.appendTo(_this.div);
|
||||
_this.span = jQuery(document.createElement('span'))
|
||||
.appendTo(this.div);
|
||||
this.span = jQuery(document.createElement('span'))
|
||||
.addClass('et2_details_toggle')
|
||||
.appendTo(_this.div);
|
||||
_this.wrapper = jQuery(document.createElement('div'))
|
||||
.appendTo(this.div);
|
||||
this.wrapper = jQuery(document.createElement('div'))
|
||||
.addClass('et2_details_wrapper')
|
||||
.appendTo(_this.div);
|
||||
_this._createWidget();
|
||||
return _this;
|
||||
.appendTo(this.div);
|
||||
this._createWidget();
|
||||
}
|
||||
/**
|
||||
* Function happens on toggle action
|
||||
*/
|
||||
et2_details.prototype._toggle = function () {
|
||||
_toggle() {
|
||||
this.div.toggleClass('et2_details_expanded');
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Create widget, set contents, and binds handlers
|
||||
*/
|
||||
et2_details.prototype._createWidget = function () {
|
||||
var self = this;
|
||||
_createWidget() {
|
||||
const self = this;
|
||||
this.span.on('click', function (e) {
|
||||
self._toggle();
|
||||
});
|
||||
@ -198,16 +176,17 @@ var et2_details = /** @class */ (function (_super) {
|
||||
// Align toggle button left/right
|
||||
if (this.options.toggle_align === "left")
|
||||
this.span.css({ float: 'left' });
|
||||
};
|
||||
et2_details.prototype.getDOMNode = function (_sender) {
|
||||
}
|
||||
getDOMNode(_sender) {
|
||||
if (!_sender || _sender === this) {
|
||||
return this.div[0];
|
||||
}
|
||||
else {
|
||||
return this.wrapper[0];
|
||||
}
|
||||
};
|
||||
et2_details._attributes = {
|
||||
}
|
||||
}
|
||||
et2_details._attributes = {
|
||||
"toggle_align": {
|
||||
name: "Toggle button alignment",
|
||||
description: " Defines where to align the toggle button, default is right alignment",
|
||||
@ -221,9 +200,6 @@ var et2_details = /** @class */ (function (_super) {
|
||||
default: "",
|
||||
translate: true
|
||||
}
|
||||
};
|
||||
return et2_details;
|
||||
}(et2_box));
|
||||
exports.et2_details = et2_details;
|
||||
et2_core_widget_1.et2_register_widget(et2_details, ["details"]);
|
||||
};
|
||||
et2_register_widget(et2_details, ["details"]);
|
||||
//# sourceMappingURL=et2_widget_box.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -18,6 +17,8 @@
|
||||
|
||||
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
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
|
||||
|
@ -1,70 +1,51 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Button object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_interfaces;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
require("./et2_core_common");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
import { et2_no_init } from "./et2_core_common";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_baseWidget } from './et2_core_baseWidget';
|
||||
/**
|
||||
* Class which implements the "button" XET-Tag
|
||||
*/
|
||||
var et2_button = /** @class */ (function (_super) {
|
||||
__extends(et2_button, _super);
|
||||
export class et2_button extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_button(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_button._attributes, _child || {})) || this;
|
||||
_this.label = "";
|
||||
_this.clicked = false;
|
||||
_this.btn = null;
|
||||
_this.image = null;
|
||||
if (!_this.options.background_image && (_this.options.image || _this.options.ro_image)) {
|
||||
_this.image = jQuery(document.createElement("img"))
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_button._attributes, _child || {}));
|
||||
this.label = "";
|
||||
this.clicked = false;
|
||||
this.btn = null;
|
||||
this.image = null;
|
||||
if (!this.options.background_image && (this.options.image || this.options.ro_image)) {
|
||||
this.image = jQuery(document.createElement("img"))
|
||||
.addClass("et2_button et2_button_icon");
|
||||
if (!_this.options.readonly)
|
||||
_this.image.addClass("et2_clickable");
|
||||
_this.setDOMNode(_this.image[0]);
|
||||
return _this;
|
||||
if (!this.options.readonly)
|
||||
this.image.addClass("et2_clickable");
|
||||
this.setDOMNode(this.image[0]);
|
||||
return;
|
||||
}
|
||||
if (!_this.options.readonly || _this.options.ro_image) {
|
||||
_this.btn = jQuery(document.createElement("button"))
|
||||
if (!this.options.readonly || this.options.ro_image) {
|
||||
this.btn = jQuery(document.createElement("button"))
|
||||
.addClass("et2_button")
|
||||
.attr({ type: "button" });
|
||||
_this.setDOMNode(_this.btn[0]);
|
||||
this.setDOMNode(this.btn[0]);
|
||||
}
|
||||
if (_this.options.image)
|
||||
_this.set_image(_this.options.image);
|
||||
return _this;
|
||||
if (this.options.image)
|
||||
this.set_image(this.options.image);
|
||||
}
|
||||
/**
|
||||
* Apply the "modifications" to the element and translate attributes marked
|
||||
@ -74,7 +55,7 @@ var et2_button = /** @class */ (function (_super) {
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
et2_button.prototype.transformAttributes = function (_attrs) {
|
||||
transformAttributes(_attrs) {
|
||||
if (this.id && typeof _attrs.background_image == 'undefined' && !_attrs.image) {
|
||||
for (var image in et2_button.default_background_images) {
|
||||
if (this.id.match(et2_button.default_background_images[image])) {
|
||||
@ -90,35 +71,35 @@ var et2_button = /** @class */ (function (_super) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
};
|
||||
et2_button.prototype.set_accesskey = function (key) {
|
||||
super.transformAttributes(_attrs);
|
||||
}
|
||||
set_accesskey(key) {
|
||||
jQuery(this.node).attr("accesskey", key);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set image and update current image
|
||||
*
|
||||
* @param _image
|
||||
*/
|
||||
et2_button.prototype.set_image = function (_image) {
|
||||
set_image(_image) {
|
||||
this.options.image = _image;
|
||||
this.update_image();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set readonly image and update current image
|
||||
*
|
||||
* @param _image
|
||||
*/
|
||||
et2_button.prototype.set_ro_image = function (_image) {
|
||||
set_ro_image(_image) {
|
||||
this.options.ro_image = _image;
|
||||
this.update_image();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set current image (dont update options.image)
|
||||
*
|
||||
* @param _image
|
||||
*/
|
||||
et2_button.prototype.update_image = function (_image) {
|
||||
update_image(_image) {
|
||||
if (!this.isInTree() || !this.options.background_image && this.image == null)
|
||||
return;
|
||||
if (typeof _image == 'undefined')
|
||||
@ -155,13 +136,13 @@ var et2_button = /** @class */ (function (_super) {
|
||||
this.btn.removeClass('et2_button_with_image');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set options.readonly and update image
|
||||
*
|
||||
* @param {boolean} _ro
|
||||
*/
|
||||
et2_button.prototype.set_readonly = function (_ro) {
|
||||
set_readonly(_ro) {
|
||||
if (_ro != this.options.readonly) {
|
||||
this.options.readonly = _ro;
|
||||
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
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_button.prototype.attachToDOM = function () {
|
||||
var ret = _super.prototype.attachToDOM.call(this);
|
||||
}
|
||||
attachToDOM() {
|
||||
let ret = super.attachToDOM();
|
||||
if (this.options.readonly && (this.btn || this.image)) {
|
||||
(this.btn || this.image)
|
||||
.removeClass('et2_clickable')
|
||||
@ -185,17 +166,17 @@ var et2_button = /** @class */ (function (_super) {
|
||||
.css('cursor', 'default'); // temp. 'til it is removed from et2_button
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
et2_button.prototype.getDOMNode = function () {
|
||||
}
|
||||
getDOMNode() {
|
||||
return this.btn ? this.btn[0] : (this.image ? this.image[0] : null);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Overwritten to maintain an internal clicked attribute
|
||||
*
|
||||
* @param _ev
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
et2_button.prototype.click = function (_ev) {
|
||||
click(_ev) {
|
||||
var _a, _b;
|
||||
// ignore click on readonly button
|
||||
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")) {
|
||||
this.getInstanceManager().skip_close_prompt();
|
||||
}
|
||||
if (!_super.prototype.click.apply(this, arguments)) {
|
||||
if (!super.click.apply(this, arguments)) {
|
||||
this.clicked = false;
|
||||
return false;
|
||||
}
|
||||
@ -216,8 +197,8 @@ var et2_button = /** @class */ (function (_super) {
|
||||
this.clicked = false;
|
||||
(_b = this.getInstanceManager()) === null || _b === void 0 ? void 0 : _b.skip_close_prompt(false);
|
||||
return true;
|
||||
};
|
||||
et2_button.prototype.set_label = function (_value) {
|
||||
}
|
||||
set_label(_value) {
|
||||
if (this.btn) {
|
||||
this.label = _value;
|
||||
this.btn.text(_value);
|
||||
@ -233,52 +214,52 @@ var et2_button = /** @class */ (function (_super) {
|
||||
this.image.attr("title", _value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set tab index
|
||||
*
|
||||
* @param {number} index
|
||||
*/
|
||||
et2_button.prototype.set_tabindex = function (index) {
|
||||
set_tabindex(index) {
|
||||
jQuery(this.btn).attr("tabindex", index);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Implementation of the et2_IInput interface
|
||||
*/
|
||||
/**
|
||||
* Always return false as a button is never dirty
|
||||
*/
|
||||
et2_button.prototype.isDirty = function () {
|
||||
isDirty() {
|
||||
return false;
|
||||
};
|
||||
et2_button.prototype.resetDirty = function () {
|
||||
};
|
||||
et2_button.prototype.getValue = function () {
|
||||
}
|
||||
resetDirty() {
|
||||
}
|
||||
getValue() {
|
||||
if (this.clicked) {
|
||||
return true;
|
||||
}
|
||||
// If "null" is returned, the result is not added to the submitted
|
||||
// array.
|
||||
return null;
|
||||
};
|
||||
et2_button.prototype.isValid = function () {
|
||||
}
|
||||
isValid() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* et2_IDetachedDOM
|
||||
*
|
||||
* @param {array} _attrs
|
||||
*/
|
||||
et2_button.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("label", "value", "class", "image", "ro_image", "onclick", "background_image");
|
||||
};
|
||||
et2_button.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [
|
||||
this.btn != null ? this.btn[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
|
||||
this.btn = _nodes[0].nodeName[0] != '#' ? jQuery(_nodes[0]) : null;
|
||||
this.image = jQuery(_nodes[1]);
|
||||
@ -306,13 +287,14 @@ var et2_button = /** @class */ (function (_super) {
|
||||
var attrs = jQuery.extend(_values, this.options);
|
||||
var parent = this.getParent();
|
||||
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.set_id(_values["id"]);
|
||||
return e.data.click.call(e.data, e);
|
||||
});
|
||||
};
|
||||
et2_button._attributes = {
|
||||
}
|
||||
}
|
||||
et2_button._attributes = {
|
||||
"label": {
|
||||
"name": "caption",
|
||||
"type": "string",
|
||||
@ -361,12 +343,12 @@ var et2_button = /** @class */ (function (_super) {
|
||||
"needed": {
|
||||
"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
|
||||
*/
|
||||
et2_button.default_background_images = {
|
||||
et2_button.default_background_images = {
|
||||
save: /save(&|\]|$)/,
|
||||
apply: /apply(&|\]|$)/,
|
||||
cancel: /cancel(&|\]|$)/,
|
||||
@ -383,17 +365,14 @@ var et2_button = /** @class */ (function (_super) {
|
||||
ok: /ok(&|\]|$)/,
|
||||
close: /close(&|\]|$)/,
|
||||
add: /(add(&|\]|$)|create)/ // customfields use create*
|
||||
};
|
||||
/**
|
||||
};
|
||||
/**
|
||||
* 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_question: /(yes|no)(&|\]|$)/,
|
||||
et2_button_delete: /delete(&|\]|$)/ // red
|
||||
};
|
||||
return et2_button;
|
||||
}(et2_core_baseWidget_1.et2_baseWidget));
|
||||
exports.et2_button = et2_button;
|
||||
et2_core_widget_1.et2_register_widget(et2_button, ["button", "buttononly"]);
|
||||
};
|
||||
et2_register_widget(et2_button, ["button", "buttononly"]);
|
||||
//# sourceMappingURL=et2_widget_button.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
@ -14,10 +14,11 @@
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
|
||||
import './et2_core_common';
|
||||
import {et2_no_init} from "./et2_core_common";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_baseWidget} from './et2_core_baseWidget'
|
||||
import {et2_IDetachedDOM, et2_IInput} from "./et2_core_interfaces";
|
||||
|
||||
/**
|
||||
* Class which implements the "button" XET-Tag
|
||||
|
@ -1,80 +1,60 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Checkbox object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_inputWidget;
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
/**
|
||||
* Class which implements the "checkbox" XET-Tag
|
||||
*
|
||||
* @augments et2_inputWidget
|
||||
*/
|
||||
var et2_checkbox = /** @class */ (function (_super) {
|
||||
__extends(et2_checkbox, _super);
|
||||
export class et2_checkbox extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_checkbox
|
||||
*/
|
||||
function et2_checkbox(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_checkbox._attributes, _child || {})) || this;
|
||||
_this.input = null;
|
||||
_this.toggle = null;
|
||||
_this.input = null;
|
||||
_this.createInputWidget();
|
||||
return _this;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_checkbox._attributes, _child || {}));
|
||||
this.input = null;
|
||||
this.toggle = null;
|
||||
this.input = null;
|
||||
this.createInputWidget();
|
||||
}
|
||||
et2_checkbox.prototype.createInputWidget = function () {
|
||||
createInputWidget() {
|
||||
this.input = jQuery(document.createElement("input")).attr("type", "checkbox");
|
||||
this.input.addClass("et2_checkbox");
|
||||
if (this.options.toggle_on || this.options.toggle_off) {
|
||||
var self_1 = this;
|
||||
let self = this;
|
||||
// checkbox container
|
||||
this.toggle = jQuery(document.createElement('span'))
|
||||
.addClass('et2_checkbox_slideSwitch')
|
||||
.append(this.input);
|
||||
// update switch status on change
|
||||
this.input.change(function () {
|
||||
self_1.getValue();
|
||||
self.getValue();
|
||||
return true;
|
||||
});
|
||||
// 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
|
||||
var on = jQuery(document.createElement('span')).addClass('on').appendTo(area);
|
||||
let on = jQuery(document.createElement('span')).addClass('on').appendTo(area);
|
||||
// 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);
|
||||
off.text(this.options.toggle_off);
|
||||
// handle a tag
|
||||
@ -84,25 +64,25 @@ var et2_checkbox = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.setDOMNode(this.input[0]);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Override default to place checkbox before label, if there is no %s in the label
|
||||
*
|
||||
* @param {string} label
|
||||
*/
|
||||
et2_checkbox.prototype.set_label = function (label) {
|
||||
set_label(label) {
|
||||
if (label.length && label.indexOf('%s') < 0) {
|
||||
label = '%s' + label;
|
||||
}
|
||||
_super.prototype.set_label.call(this, label);
|
||||
super.set_label(label);
|
||||
jQuery(this.getSurroundings().getWidgetSurroundings()).addClass('et2_checkbox_label');
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Override default to match against set/unset 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
|
||||
if (_value === "0" && this.options.selected_value != "0") {
|
||||
_value = false;
|
||||
@ -121,20 +101,20 @@ var et2_checkbox = /** @class */ (function (_super) {
|
||||
this.toggle.removeClass('switchOn');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Disable checkbox on runtime
|
||||
*
|
||||
* @param {boolean} _ro
|
||||
*/
|
||||
et2_checkbox.prototype.set_readonly = function (_ro) {
|
||||
set_readonly(_ro) {
|
||||
jQuery(this.getDOMNode()).attr('disabled', _ro);
|
||||
this.input.prop('disabled', _ro);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Override default to return unchecked value
|
||||
*/
|
||||
et2_checkbox.prototype.getValue = function () {
|
||||
getValue() {
|
||||
if (this.input.prop("checked")) {
|
||||
if (this.options.toggle_on || this.options.toggle_off)
|
||||
this.toggle.addClass('switchOn');
|
||||
@ -145,9 +125,9 @@ var et2_checkbox = /** @class */ (function (_super) {
|
||||
this.toggle.removeClass('switchOn');
|
||||
return this.options.unselected_value;
|
||||
}
|
||||
};
|
||||
et2_checkbox.prototype.set_disabled = function (_value) {
|
||||
var parentNode = jQuery(this.getDOMNode()).parent();
|
||||
}
|
||||
set_disabled(_value) {
|
||||
let parentNode = jQuery(this.getDOMNode()).parent();
|
||||
if (parentNode[0] && parentNode[0].nodeName == "label" && parentNode.hasClass('.et2_checkbox_label')) {
|
||||
if (_value) {
|
||||
parentNode.hide();
|
||||
@ -156,9 +136,10 @@ var et2_checkbox = /** @class */ (function (_super) {
|
||||
parentNode.show();
|
||||
}
|
||||
}
|
||||
_super.prototype.set_disabled.call(this, _value);
|
||||
};
|
||||
et2_checkbox._attributes = {
|
||||
super.set_disabled(_value);
|
||||
}
|
||||
}
|
||||
et2_checkbox._attributes = {
|
||||
"selected_value": {
|
||||
"name": "Set value",
|
||||
"type": "string",
|
||||
@ -201,33 +182,27 @@ var et2_checkbox = /** @class */ (function (_super) {
|
||||
"description": "String caption to show OFF status",
|
||||
"translate": true
|
||||
}
|
||||
};
|
||||
et2_checkbox.legacyOptions = ["selected_value", "unselected_value", "ro_true", "ro_false"];
|
||||
return et2_checkbox;
|
||||
}(et2_core_inputWidget_1.et2_inputWidget));
|
||||
exports.et2_checkbox = et2_checkbox;
|
||||
et2_core_widget_1.et2_register_widget(et2_checkbox, ["checkbox"]);
|
||||
};
|
||||
et2_checkbox.legacyOptions = ["selected_value", "unselected_value", "ro_true", "ro_false"];
|
||||
et2_register_widget(et2_checkbox, ["checkbox"]);
|
||||
/**
|
||||
* et2_checkbox_ro is the dummy readonly implementation of the checkbox
|
||||
* @augments et2_checkbox
|
||||
*/
|
||||
var et2_checkbox_ro = /** @class */ (function (_super) {
|
||||
__extends(et2_checkbox_ro, _super);
|
||||
export class et2_checkbox_ro extends et2_checkbox {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_checkbox_ro
|
||||
*/
|
||||
function et2_checkbox_ro(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_checkbox_ro._attributes, _child || {})) || this;
|
||||
_this.span = null;
|
||||
_this.value = "";
|
||||
_this.span = jQuery(document.createElement("span"))
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_checkbox_ro._attributes, _child || {}));
|
||||
this.span = null;
|
||||
this.value = "";
|
||||
this.span = jQuery(document.createElement("span"))
|
||||
.addClass("et2_checkbox_ro");
|
||||
_this.setDOMNode(_this.span[0]);
|
||||
return _this;
|
||||
this.setDOMNode(this.span[0]);
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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"] &&
|
||||
_value != this.options.unselected_value) {
|
||||
this.span.text(this.options.ro_true);
|
||||
@ -244,19 +219,19 @@ var et2_checkbox_ro = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.span.text(this.options.ro_false);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
*
|
||||
* @param {array} _attrs
|
||||
*/
|
||||
et2_checkbox_ro.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value", "class");
|
||||
};
|
||||
et2_checkbox_ro.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.span[0]];
|
||||
};
|
||||
et2_checkbox_ro.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
// Update the properties
|
||||
if (typeof _values["value"] != "undefined") {
|
||||
this.span = jQuery(_nodes[0]);
|
||||
@ -265,16 +240,15 @@ var et2_checkbox_ro = /** @class */ (function (_super) {
|
||||
if (typeof _values["class"] != "undefined") {
|
||||
_nodes[0].setAttribute("class", _values["class"]);
|
||||
}
|
||||
};
|
||||
/**
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ignore unset value
|
||||
*/
|
||||
et2_checkbox_ro._attributes = {
|
||||
et2_checkbox_ro._attributes = {
|
||||
"unselected_value": {
|
||||
"ignore": true
|
||||
}
|
||||
};
|
||||
return et2_checkbox_ro;
|
||||
}(et2_checkbox));
|
||||
et2_core_widget_1.et2_register_widget(et2_checkbox_ro, ["checkbox_ro"]);
|
||||
};
|
||||
et2_register_widget(et2_checkbox_ro, ["checkbox_ro"]);
|
||||
//# sourceMappingURL=et2_widget_checkbox.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -19,6 +18,7 @@
|
||||
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_inputWidget} from "./et2_core_inputWidget";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_IDetachedDOM} from "./et2_core_interfaces";
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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
|
||||
|
@ -1,142 +1,115 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Color picker object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_inputWidget;
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
/**
|
||||
* Class which implements the "colorpicker" XET-Tag
|
||||
*
|
||||
*/
|
||||
var et2_color = /** @class */ (function (_super) {
|
||||
__extends(et2_color, _super);
|
||||
export class et2_color extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_color(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_color._attributes, _child || {})) || this;
|
||||
_this.cleared = true;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_color._attributes, _child || {}));
|
||||
this.cleared = true;
|
||||
// included via etemplate2.css
|
||||
//this.egw().includeCSS("phpgwapi/js/jquery/jpicker/css/jPicker-1.1.6.min.css");
|
||||
_this.span = jQuery("<span class='et2_color'/>");
|
||||
_this.image = jQuery("<img src='" + _this.egw().image("non_loaded_bg") + "'/>")
|
||||
.appendTo(_this.span)
|
||||
this.span = jQuery("<span class='et2_color'/>");
|
||||
this.image = jQuery("<img src='" + this.egw().image("non_loaded_bg") + "'/>")
|
||||
.appendTo(this.span)
|
||||
.on("click", function () {
|
||||
this.input.trigger('click');
|
||||
}.bind(_this));
|
||||
_this.input = jQuery("<input type='color'/>").appendTo(_this.span)
|
||||
}.bind(this));
|
||||
this.input = jQuery("<input type='color'/>").appendTo(this.span)
|
||||
.on('change', function () {
|
||||
this.cleared = false;
|
||||
this.image.hide();
|
||||
}.bind(_this));
|
||||
if (!_this.options.readonly && !_this.options.needed) {
|
||||
_this.clear = jQuery("<span class='ui-icon clear'/>")
|
||||
.appendTo(_this.span)
|
||||
}.bind(this));
|
||||
if (!this.options.readonly && !this.options.needed) {
|
||||
this.clear = jQuery("<span class='ui-icon clear'/>")
|
||||
.appendTo(this.span)
|
||||
.on("click", function () {
|
||||
this.set_value('');
|
||||
return false;
|
||||
}.bind(_this));
|
||||
}.bind(this));
|
||||
}
|
||||
_this.setDOMNode(_this.span[0]);
|
||||
return _this;
|
||||
this.setDOMNode(this.span[0]);
|
||||
}
|
||||
et2_color.prototype.getValue = function () {
|
||||
getValue() {
|
||||
var value = this.input.val();
|
||||
if (this.cleared || value === '#FFFFFF' || value === '#ffffff') {
|
||||
return '';
|
||||
}
|
||||
return value;
|
||||
};
|
||||
et2_color.prototype.set_value = function (color) {
|
||||
}
|
||||
set_value(color) {
|
||||
if (!color) {
|
||||
color = '';
|
||||
}
|
||||
this.cleared = !color;
|
||||
this.image.toggle(!color);
|
||||
this.input.val(color);
|
||||
};
|
||||
return et2_color;
|
||||
}(et2_core_inputWidget_1.et2_inputWidget));
|
||||
exports.et2_color = et2_color;
|
||||
et2_core_widget_1.et2_register_widget(et2_color, ["colorpicker"]);
|
||||
}
|
||||
}
|
||||
et2_register_widget(et2_color, ["colorpicker"]);
|
||||
/**
|
||||
* et2_textbox_ro is the dummy readonly implementation of the textbox.
|
||||
* @augments et2_valueWidget
|
||||
*/
|
||||
var et2_color_ro = /** @class */ (function (_super) {
|
||||
__extends(et2_color_ro, _super);
|
||||
export class et2_color_ro extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_color_ro
|
||||
*/
|
||||
function et2_color_ro(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, _child || {}) || this;
|
||||
_this.value = "";
|
||||
_this.$node = jQuery(document.createElement("div"))
|
||||
super(_parent, _attrs, _child || {});
|
||||
this.value = "";
|
||||
this.$node = jQuery(document.createElement("div"))
|
||||
.addClass("et2_color");
|
||||
_this.setDOMNode(_this.$node[0]);
|
||||
return _this;
|
||||
this.setDOMNode(this.$node[0]);
|
||||
}
|
||||
et2_color_ro.prototype.set_value = function (_value) {
|
||||
set_value(_value) {
|
||||
this.value = _value;
|
||||
if (!_value)
|
||||
_value = "inherit";
|
||||
this.$node.css("background-color", _value);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
*
|
||||
* @param {array} _attrs array to add further attributes to
|
||||
*/
|
||||
et2_color_ro.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value");
|
||||
};
|
||||
et2_color_ro.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.node];
|
||||
};
|
||||
et2_color_ro.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
this.$node = jQuery(_nodes[0]);
|
||||
if (typeof _values["value"] != 'undefined') {
|
||||
this.set_value(_values["value"]);
|
||||
}
|
||||
};
|
||||
return et2_color_ro;
|
||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||
exports.et2_color_ro = et2_color_ro;
|
||||
et2_core_widget_1.et2_register_widget(et2_color_ro, ["colorpicker_ro"]);
|
||||
}
|
||||
}
|
||||
et2_register_widget(et2_color_ro, ["colorpicker_ro"]);
|
||||
//# sourceMappingURL=et2_widget_color.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2012
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -20,6 +19,7 @@ import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_valueWidget} from "./et2_core_valueWidget";
|
||||
import {et2_inputWidget} from "./et2_core_inputWidget";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_IDetachedDOM} from "./et2_core_interfaces";
|
||||
|
||||
/**
|
||||
* Class which implements the "colorpicker" XET-Tag
|
||||
|
@ -1,36 +1,21 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - Countdown timer widget
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
require("./et2_core_common");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
import { et2_no_init } from "./et2_core_common";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
var et2_countdown = /** @class */ (function (_super) {
|
||||
__extends(et2_countdown, _super);
|
||||
export class et2_countdown extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_countdown(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_countdown._attributes, _child || {})) || this;
|
||||
_this.timer = null;
|
||||
_this.container = null;
|
||||
_this.days = null;
|
||||
_this.hours = null;
|
||||
_this.minutes = null;
|
||||
_this.seconds = null;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_countdown._attributes, _child || {}));
|
||||
this.timer = null;
|
||||
this.container = null;
|
||||
this.days = null;
|
||||
this.hours = null;
|
||||
this.minutes = null;
|
||||
this.seconds = null;
|
||||
// Build countdown dom container
|
||||
_this.container = jQuery(document.createElement("div"))
|
||||
this.container = jQuery(document.createElement("div"))
|
||||
.addClass("et2_countdown");
|
||||
_this.days = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_days").appendTo(_this.container);
|
||||
_this.hours = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_hours").appendTo(_this.container);
|
||||
_this.minutes = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_minutes").appendTo(_this.container);
|
||||
_this.seconds = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_seconds").appendTo(_this.container);
|
||||
_this.setDOMNode(_this.container[0]);
|
||||
return _this;
|
||||
this.days = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_days").appendTo(this.container);
|
||||
this.hours = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_hours").appendTo(this.container);
|
||||
this.minutes = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_minutes").appendTo(this.container);
|
||||
this.seconds = jQuery(document.createElement("span"))
|
||||
.addClass("et2_countdown_seconds").appendTo(this.container);
|
||||
this.setDOMNode(this.container[0]);
|
||||
}
|
||||
et2_countdown.prototype.set_value = function (_time) {
|
||||
set_value(_time) {
|
||||
if (isNaN(_time))
|
||||
return;
|
||||
_super.prototype.set_value.call(this, _time);
|
||||
super.set_value(_time);
|
||||
this.time = new Date();
|
||||
this.time.setSeconds(this.time.getSeconds() + parseInt(_time));
|
||||
var self = this;
|
||||
let self = this;
|
||||
this.timer = setInterval(function () {
|
||||
if (self._updateTimer() <= 0) {
|
||||
clearInterval(self.timer);
|
||||
@ -81,16 +63,16 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
self.onFinish();
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
et2_countdown.prototype._updateTimer = function () {
|
||||
var now = new Date();
|
||||
var distance = this.time.getTime() - now.getTime();
|
||||
}
|
||||
_updateTimer() {
|
||||
let now = new Date();
|
||||
let distance = this.time.getTime() - now.getTime();
|
||||
if (distance < 0)
|
||||
return 0;
|
||||
if (this.options.alarm > 0 && this.options.alarm == distance / 1000 && typeof this.onAlarm == 'function') {
|
||||
this.onAlarm();
|
||||
}
|
||||
var values = {
|
||||
let values = {
|
||||
days: Math.floor(distance / (1000 * 60 * 60 * 24)),
|
||||
hours: Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
|
||||
minutes: Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)),
|
||||
@ -114,10 +96,10 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
if (this.options.precision) {
|
||||
var units = ['days', 'hours', 'minutes', 'seconds'];
|
||||
for (var u = 0; u < 4; ++u) {
|
||||
const units = ['days', 'hours', 'minutes', 'seconds'];
|
||||
for (let u = 0; u < 4; ++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();
|
||||
}
|
||||
break;
|
||||
@ -128,11 +110,12 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return distance;
|
||||
};
|
||||
et2_countdown.prototype._getIndicator = function (_v) {
|
||||
}
|
||||
_getIndicator(_v) {
|
||||
return this.options.format == 's' ? egw.lang(_v).substr(0, 1) : egw.lang(_v);
|
||||
};
|
||||
et2_countdown._attributes = {
|
||||
}
|
||||
}
|
||||
et2_countdown._attributes = {
|
||||
format: {
|
||||
name: "display format",
|
||||
type: "string",
|
||||
@ -169,9 +152,6 @@ var et2_countdown = /** @class */ (function (_super) {
|
||||
default: "",
|
||||
description: "Defines a callback to gets called at alarm - timer. This only will work if there's an alarm set."
|
||||
}
|
||||
};
|
||||
return et2_countdown;
|
||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||
exports.et2_countdown = et2_countdown;
|
||||
et2_core_widget_1.et2_register_widget(et2_countdown, ["countdown"]);
|
||||
};
|
||||
et2_register_widget(et2_countdown, ["countdown"]);
|
||||
//# sourceMappingURL=et2_widget_countdown.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Hadi Nategh
|
||||
*/
|
||||
|
||||
@ -13,12 +13,11 @@
|
||||
et2_core_baseWidget;
|
||||
*/
|
||||
|
||||
import './et2_core_common';
|
||||
import {et2_no_init} from "./et2_core_common";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_date} from "./et2_widget_date";
|
||||
import {et2_baseWidget} from "./et2_core_baseWidget";
|
||||
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_valueWidget} from "./et2_core_valueWidget";
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* Class which implements the "countdown" XET-Tag
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2011
|
||||
*/
|
||||
@ -17,13 +17,16 @@
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
|
||||
import './et2_core_common';
|
||||
import {et2_csvSplit, et2_no_init} from "./et2_core_common";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_createWidget, et2_register_widget, et2_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_valueWidget} from './et2_core_valueWidget'
|
||||
import {et2_inputWidget} from './et2_core_inputWidget'
|
||||
import {et2_selectbox} from './et2_widget_selectbox'
|
||||
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:
|
||||
declare function date (format : string, timestamp? : string | number | Date);
|
||||
|
@ -1,84 +1,61 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Description object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_description = void 0;
|
||||
/*egw:uses
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_baseWidget;
|
||||
expose;
|
||||
*/
|
||||
require("./et2_core_common");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
import { et2_activateLinks, et2_csvSplit, et2_insertLinkText, et2_no_init } from "./et2_core_common";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_baseWidget } from './et2_core_baseWidget';
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
import { expose } from "./expose";
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* Class which implements the "description" XET-Tag
|
||||
*/
|
||||
var et2_description = /** @class */ (function (_super) {
|
||||
__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);
|
||||
export class et2_description extends expose((_a = class et2_description extends et2_baseWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_description(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_description._attributes, _child || {})) || this;
|
||||
_this._labelContainer = null;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_description._attributes, _child || {}));
|
||||
this._labelContainer = null;
|
||||
// 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");
|
||||
et2_insertLinkText(_this._parseText(_this.options.value), _this.span[0], _this.options.href ? _this.options.extra_link_target : '_blank');
|
||||
_this.setDOMNode(_this.span[0]);
|
||||
return _this;
|
||||
et2_insertLinkText(this._parseText(this.options.value), this.span[0], this.options.href ? this.options.extra_link_target : '_blank');
|
||||
this.setDOMNode(this.span[0]);
|
||||
}
|
||||
et2_description.prototype.transformAttributes = function (_attrs) {
|
||||
_super.prototype.transformAttributes.call(this, _attrs);
|
||||
transformAttributes(_attrs) {
|
||||
super.transformAttributes(_attrs);
|
||||
if (this.id) {
|
||||
var val = this.getArrayMgr("content").getEntry(this.id);
|
||||
if (val) {
|
||||
_attrs["value"] = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_description.prototype.doLoadingFinished = function () {
|
||||
_super.prototype.doLoadingFinished.call(this);
|
||||
}
|
||||
doLoadingFinished() {
|
||||
super.doLoadingFinished();
|
||||
// Get the real id of the 'for' widget
|
||||
var for_widget = null;
|
||||
var for_id = "";
|
||||
let for_id = "";
|
||||
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) {
|
||||
if (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;
|
||||
}
|
||||
this.span.attr("for", for_id);
|
||||
@ -89,7 +66,7 @@ var et2_description = /** @class */ (function (_super) {
|
||||
window.setTimeout(function () {
|
||||
var _a;
|
||||
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;
|
||||
}
|
||||
this.span.attr("for", for_id);
|
||||
@ -99,8 +76,8 @@ var et2_description = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
et2_description.prototype.set_label = function (_value) {
|
||||
}
|
||||
set_label(_value) {
|
||||
// Abort if ther was no change in the label
|
||||
if (_value == this.label) {
|
||||
return;
|
||||
@ -142,15 +119,15 @@ var et2_description = /** @class */ (function (_super) {
|
||||
this.getSurroundings().update();
|
||||
// Copy the given value
|
||||
this.label = _value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Function to get media content to feed the expose
|
||||
* @param {type} _value
|
||||
* @returns {Array|Array.getMedia.mediaContent}
|
||||
*/
|
||||
et2_description.prototype.getMedia = function (_value) {
|
||||
var base_url = egw.webserverUrl.match(new RegExp(/^\//, 'ig')) ? egw(window).window.location.origin : '';
|
||||
var mediaContent = [];
|
||||
getMedia(_value) {
|
||||
let base_url = egw.webserverUrl.match(new RegExp(/^\//, 'ig')) ? egw(window).window.location.origin : '';
|
||||
let mediaContent = [];
|
||||
if (_value) {
|
||||
mediaContent = [{
|
||||
title: this.options.label,
|
||||
@ -162,8 +139,8 @@ var et2_description = /** @class */ (function (_super) {
|
||||
mediaContent[0]["download_href"] = base_url + _value + '?download';
|
||||
}
|
||||
return mediaContent;
|
||||
};
|
||||
et2_description.prototype.set_value = function (_value) {
|
||||
}
|
||||
set_value(_value) {
|
||||
if (!_value)
|
||||
_value = "";
|
||||
if (!this.options.no_lang)
|
||||
@ -192,8 +169,8 @@ var et2_description = /** @class */ (function (_super) {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
et2_description.prototype._parseText = function (_value) {
|
||||
}
|
||||
_parseText(_value) {
|
||||
if (this.options.href) {
|
||||
var href = this.options.href;
|
||||
if (href.indexOf('/') == -1 && href.split('.').length >= 3 &&
|
||||
@ -215,24 +192,24 @@ var et2_description = /** @class */ (function (_super) {
|
||||
else {
|
||||
return [_value];
|
||||
}
|
||||
};
|
||||
et2_description.prototype.set_font_style = function (_value) {
|
||||
}
|
||||
set_font_style(_value) {
|
||||
this.font_style = _value;
|
||||
this.span.toggleClass("et2_bold", _value.indexOf("b") >= 0);
|
||||
this.span.toggleClass("et2_italic", _value.indexOf("i") >= 0);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
*
|
||||
* @param {array} _attrs
|
||||
*/
|
||||
et2_description.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value", "class", "href");
|
||||
};
|
||||
et2_description.prototype.getDetachedNodes = function () {
|
||||
}
|
||||
getDetachedNodes() {
|
||||
return [this.span[0]];
|
||||
};
|
||||
et2_description.prototype.setDetachedAttributes = function (_nodes, _values, _data) {
|
||||
}
|
||||
setDetachedAttributes(_nodes, _values, _data) {
|
||||
// Update the properties
|
||||
var updateLink = false;
|
||||
if (typeof _values["href"] != "undefined") {
|
||||
@ -250,12 +227,12 @@ var et2_description = /** @class */ (function (_super) {
|
||||
if (this.options.hover_action) {
|
||||
this._build_hover_action(_data);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Builds button for hover action
|
||||
* @param {object} _data
|
||||
*/
|
||||
et2_description.prototype._build_hover_action = function (_data) {
|
||||
_build_hover_action(_data) {
|
||||
var content = _data && _data.content ? _data.content : undefined;
|
||||
var widget = this;
|
||||
this.span.off().on('mouseenter', jQuery.proxy(function (event) {
|
||||
@ -265,14 +242,14 @@ var et2_description = /** @class */ (function (_super) {
|
||||
items: 'span.et2_label',
|
||||
position: { my: "right top", at: "left top", collision: "flipfit" },
|
||||
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="'
|
||||
+ egw.image("edit") + '"/></a>')
|
||||
.on('click', function () {
|
||||
widget.options.hover_action.call(self, self.widget, content);
|
||||
});
|
||||
},
|
||||
close: function (event, ui) {
|
||||
close(event, ui) {
|
||||
ui.tooltip.hover(function () {
|
||||
jQuery(this).stop(true).fadeTo(400, 1);
|
||||
}, function () {
|
||||
@ -282,9 +259,8 @@ var et2_description = /** @class */ (function (_super) {
|
||||
})
|
||||
.tooltip("open");
|
||||
}, { widget: this, span: this.span }));
|
||||
};
|
||||
return et2_description;
|
||||
}(et2_core_baseWidget_1.et2_baseWidget)),
|
||||
}
|
||||
},
|
||||
_a._attributes = {
|
||||
"label": {
|
||||
"name": "Label",
|
||||
@ -370,8 +346,8 @@ var et2_description = /** @class */ (function (_super) {
|
||||
},
|
||||
_a.legacyOptions = ["font_style", "href", "activate_links", "for",
|
||||
"extra_link_target", "extra_link_popup", "statustext"],
|
||||
_a))));
|
||||
exports.et2_description = et2_description;
|
||||
_a)) {
|
||||
}
|
||||
;
|
||||
et2_core_widget_1.et2_register_widget(et2_description, ["description", "label"]);
|
||||
et2_register_widget(et2_description, ["description", "label"]);
|
||||
//# sourceMappingURL=et2_widget_description.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
*/
|
||||
|
||||
@ -14,11 +14,14 @@
|
||||
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 {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {et2_baseWidget} from './et2_core_baseWidget'
|
||||
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
|
||||
|
@ -1,38 +1,23 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Dialog Widget class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
et2_core_widget;
|
||||
/vendor/bower-asset/jquery-ui/jquery-ui.js;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_widget_2 = require("./et2_core_widget");
|
||||
var et2_widget_button_1 = require("./et2_widget_button");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var etemplate2_1 = require("./etemplate2");
|
||||
import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_widget } from "./et2_core_widget";
|
||||
import { et2_button } from "./et2_widget_button";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
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.
|
||||
*
|
||||
@ -106,14 +91,13 @@ var etemplate2_1 = require("./etemplate2");
|
||||
* @augments et2_widget
|
||||
* @see http://api.jqueryui.com/dialog/
|
||||
*/
|
||||
var et2_dialog = /** @class */ (function (_super) {
|
||||
__extends(et2_dialog, _super);
|
||||
function et2_dialog(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_dialog._attributes, _child || {})) || this;
|
||||
export class et2_dialog extends et2_widget {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_dialog._attributes, _child || {}));
|
||||
/**
|
||||
* Details for dialog type options
|
||||
*/
|
||||
_this._dialog_types = [
|
||||
this._dialog_types = [
|
||||
//PLAIN_MESSAGE: 0
|
||||
"",
|
||||
//INFORMATION_MESSAGE: 1,
|
||||
@ -125,7 +109,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
//ERROR_MESSAGE: 4,
|
||||
"dialog_error"
|
||||
];
|
||||
_this._buttons = [
|
||||
this._buttons = [
|
||||
/*
|
||||
Pre-defined Button combos
|
||||
- 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' }
|
||||
]
|
||||
];
|
||||
_this.div = null;
|
||||
_this.template = null;
|
||||
this.div = null;
|
||||
this.template = null;
|
||||
// Define this as null to avoid breaking any hierarchies (eg: destroy())
|
||||
if (_this.getParent() != null)
|
||||
_this.getParent().removeChild(_this);
|
||||
if (this.getParent() != null)
|
||||
this.getParent().removeChild(this);
|
||||
// Button callbacks need a reference to this
|
||||
var self = _this;
|
||||
for (var i = 0; i < _this._buttons.length; i++) {
|
||||
for (var j = 0; j < _this._buttons[i].length; j++) {
|
||||
_this._buttons[i][j].click = (function (id) {
|
||||
let self = this;
|
||||
for (let i = 0; i < this._buttons.length; i++) {
|
||||
for (let j = 0; j < this._buttons[i].length; j++) {
|
||||
this._buttons[i][j].click = (function (id) {
|
||||
return function (event) {
|
||||
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
|
||||
_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._createDialog();
|
||||
return _this;
|
||||
this.div = jQuery(document.createElement("div"));
|
||||
this._createDialog();
|
||||
}
|
||||
/**
|
||||
* Clean up dialog
|
||||
*/
|
||||
et2_dialog.prototype.destroy = function () {
|
||||
destroy() {
|
||||
if (this.div != null) {
|
||||
// Un-dialog the dialog
|
||||
this.div.dialog("destroy");
|
||||
@ -186,8 +169,8 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
this.div = null;
|
||||
}
|
||||
// Call the inherited constructor
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
super.destroy();
|
||||
}
|
||||
/**
|
||||
* Internal callback registered on all standard buttons.
|
||||
* 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 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.call(this, button_id, this.get_value()) === false)
|
||||
return;
|
||||
}
|
||||
// Triggers destroy too
|
||||
this.div.dialog("close");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the values of any widgets in the dialog. This does not include
|
||||
* the buttons, which are only supplied for the callback.
|
||||
*/
|
||||
et2_dialog.prototype.get_value = function () {
|
||||
get_value() {
|
||||
var value = this.options.value;
|
||||
if (this.template) {
|
||||
value = this.template.getValues(this.template.widgetContainer);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the displayed prompt message
|
||||
*
|
||||
* @param {string} message New message for the dialog
|
||||
*/
|
||||
et2_dialog.prototype.set_message = function (message) {
|
||||
set_message(message) {
|
||||
this.options.message = message;
|
||||
this.div.empty()
|
||||
.append("<img class='dialog_icon' />")
|
||||
.append(jQuery('<div/>').text(message));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the dialog type to a pre-defined type
|
||||
*
|
||||
* @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") {
|
||||
this.options.dialog_type = type;
|
||||
}
|
||||
this.set_icon(this._dialog_types[type] ? egw.image(this._dialog_types[type]) : "");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the icon for the dialog
|
||||
*
|
||||
* @param {string} icon_url
|
||||
*/
|
||||
et2_dialog.prototype.set_icon = function (icon_url) {
|
||||
set_icon(icon_url) {
|
||||
if (icon_url == "") {
|
||||
jQuery("img.dialog_icon", this.div).hide();
|
||||
}
|
||||
else {
|
||||
jQuery("img.dialog_icon", this.div).show().attr("src", icon_url);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the dialog buttons
|
||||
*
|
||||
@ -256,7 +239,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
* @see http://api.jqueryui.com/dialog/#option-buttons
|
||||
* @param {array} buttons
|
||||
*/
|
||||
et2_dialog.prototype.set_buttons = function (buttons) {
|
||||
set_buttons(buttons) {
|
||||
this.options.buttons = buttons;
|
||||
if (buttons instanceof Array) {
|
||||
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
|
||||
if (button.id && typeof button.class == 'undefined') {
|
||||
for (var name in et2_widget_button_1.et2_button.default_classes) {
|
||||
if (button.id.match(et2_widget_button_1.et2_button.default_classes[name])) {
|
||||
for (var name in et2_button.default_classes) {
|
||||
if (button.id.match(et2_button.default_classes[name])) {
|
||||
button.class = (typeof button.class == 'undefined' ? '' : button.class + ' ') + name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (button.id && typeof button.image == 'undefined' && typeof button.style == 'undefined') {
|
||||
for (var name in et2_widget_button_1.et2_button.default_background_images) {
|
||||
if (button.id.match(et2_widget_button_1.et2_button.default_background_images[name])) {
|
||||
for (var name in et2_button.default_background_images) {
|
||||
if (button.id.match(et2_button.default_background_images[name])) {
|
||||
button.image = name;
|
||||
break;
|
||||
}
|
||||
@ -296,35 +279,35 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
// Focus default button so enter works
|
||||
jQuery('.ui-dialog-buttonpane button[default]', this.div.parent()).focus();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the dialog title
|
||||
*
|
||||
* @param {string} title New title for the dialog
|
||||
*/
|
||||
et2_dialog.prototype.set_title = function (title) {
|
||||
set_title(title) {
|
||||
this.options.title = title;
|
||||
this.div.dialog("option", "title", title);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Block interaction with the page behind the dialog
|
||||
*
|
||||
* @param {boolean} modal Block page behind dialog
|
||||
*/
|
||||
et2_dialog.prototype.set_modal = function (modal) {
|
||||
set_modal(modal) {
|
||||
this.options.modal = modal;
|
||||
this.div.dialog("option", "modal", modal);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Load an etemplate into the dialog
|
||||
*
|
||||
* @param template String etemplate file name
|
||||
*/
|
||||
et2_dialog.prototype.set_template = function (template) {
|
||||
set_template(template) {
|
||||
if (this.template && this.options.template != template) {
|
||||
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) {
|
||||
// File name provided, fetch from server
|
||||
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
|
||||
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++) {
|
||||
var et = _a[_i];
|
||||
for (let et of etemplate2.getByApplication(this.template.app)) {
|
||||
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.
|
||||
this.template.unbind_unload();
|
||||
@ -351,11 +333,11 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
}
|
||||
// set template-name as id, to allow to style dialogs
|
||||
this.div.children().attr('id', template.replace(/^(.*\/)?([^/]+)(\.xet)?$/, '$2').replace(/\./g, '-'));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Actually create and display the dialog
|
||||
*/
|
||||
et2_dialog.prototype._createDialog = function () {
|
||||
_createDialog() {
|
||||
if (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_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) {
|
||||
var positions = this.options.position.split(',');
|
||||
let positions = this.options.position.split(',');
|
||||
position_my = positions[0] ? positions[0].trim() : 'center';
|
||||
position_at = positions[1] ? positions[1].trim() : position_my;
|
||||
}
|
||||
var options = {
|
||||
let options = {
|
||||
// Pass the internal object, not the option
|
||||
buttons: this.options.buttons,
|
||||
modal: this.options.modal,
|
||||
@ -409,24 +391,24 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
this.div.dialog(options);
|
||||
// Make sure dialog is wide enough for the title
|
||||
// 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()) {
|
||||
// Auto-sizing chopped the title
|
||||
this.div.dialog('option', 'width', title_width);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_dialog._create_parent = function (_egw_or_appname) {
|
||||
static _create_parent(_egw_or_appname) {
|
||||
if (typeof _egw_or_appname == 'undefined') {
|
||||
// @ts-ignore
|
||||
_egw_or_appname = egw_appName;
|
||||
}
|
||||
// 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 (typeof _egw_or_appname != 'string') {
|
||||
parent.setApiInstance(_egw_or_appname);
|
||||
@ -437,7 +419,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
parent.egw().langRequireApp(parent.egw().window, _egw_or_appname);
|
||||
}
|
||||
return parent;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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|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) {
|
||||
var parent = et2_dialog._create_parent(_egw_or_appname);
|
||||
static show_dialog(_callback, _message, _title, _value, _buttons, _type, _icon, _egw_or_appname) {
|
||||
let parent = et2_dialog._create_parent(_egw_or_appname);
|
||||
// Just pass them along, widget handles defaults & missing
|
||||
return et2_core_widget_1.et2_createWidget("dialog", {
|
||||
return et2_createWidget("dialog", {
|
||||
callback: _callback || function () {
|
||||
},
|
||||
message: _message,
|
||||
@ -464,7 +446,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
value: _value,
|
||||
width: 'auto'
|
||||
}, parent);
|
||||
};
|
||||
}
|
||||
;
|
||||
/**
|
||||
* 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 {integer} _type One of the message constants. This defines the style of the message.
|
||||
*/
|
||||
et2_dialog.alert = function (_message, _title, _type) {
|
||||
var parent = et2_dialog._create_parent(et2_dialog._create_parent().egw());
|
||||
et2_core_widget_1.et2_createWidget("dialog", {
|
||||
static alert(_message, _title, _type) {
|
||||
let parent = et2_dialog._create_parent(et2_dialog._create_parent().egw());
|
||||
et2_createWidget("dialog", {
|
||||
callback: function () {
|
||||
},
|
||||
message: _message,
|
||||
@ -483,7 +465,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
buttons: et2_dialog.BUTTONS_OK,
|
||||
dialog_type: _type || et2_dialog.INFORMATION_MESSAGE
|
||||
}, parent);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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 {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;
|
||||
// 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) {
|
||||
if (typeof callback == "function") {
|
||||
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',
|
||||
class: "et2_prompt"
|
||||
}, et2_dialog._create_parent(_egw_or_appname));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Method to build a confirmation dialog only with
|
||||
* 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
|
||||
*/
|
||||
et2_dialog.confirm = function (_senders, _dialogMsg, _titleMsg, _postSubmit) {
|
||||
static confirm(_senders, _dialogMsg, _titleMsg, _postSubmit) {
|
||||
var senders = _senders;
|
||||
var buttonId = _senders.id;
|
||||
var dialogMsg = (typeof _dialogMsg != "undefined") ? _dialogMsg : '';
|
||||
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) {
|
||||
if (button_id == et2_dialog.YES_BUTTON) {
|
||||
if (_postSubmit) {
|
||||
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.getInstanceManager().submit(senders, false, senders.options.novalidate);
|
||||
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);
|
||||
};
|
||||
}
|
||||
;
|
||||
/**
|
||||
* Show a dialog for a long-running, multi-part task
|
||||
@ -577,11 +559,11 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
*
|
||||
* @return {et2_dialog}
|
||||
*/
|
||||
et2_dialog.long_task = function (_callback, _message, _title, _menuaction, _list, _egw_or_appname) {
|
||||
var parent = et2_dialog._create_parent(_egw_or_appname);
|
||||
var egw = parent.egw();
|
||||
static long_task(_callback, _message, _title, _menuaction, _list, _egw_or_appname) {
|
||||
let parent = et2_dialog._create_parent(_egw_or_appname);
|
||||
let egw = parent.egw();
|
||||
// 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.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',
|
||||
value: {
|
||||
content: {
|
||||
@ -612,19 +594,19 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
}, parent);
|
||||
// OK starts disabled
|
||||
jQuery("button[button_id=" + et2_dialog.OK_BUTTON + "]", dialog.div.parent()).button("disable");
|
||||
var log = null;
|
||||
var progressbar = null;
|
||||
var cancel = false;
|
||||
var totals = {
|
||||
let log = null;
|
||||
let progressbar = null;
|
||||
let cancel = false;
|
||||
let totals = {
|
||||
success: 0,
|
||||
skipped: 0,
|
||||
failed: 0,
|
||||
widget: null
|
||||
};
|
||||
// Updates progressbar & log, calls next step
|
||||
var update = function (response) {
|
||||
let update = function (response) {
|
||||
// context is index
|
||||
var index = this || 0;
|
||||
let index = this || 0;
|
||||
progressbar.set_value(100 * (index / _list.length));
|
||||
progressbar.set_label(index + ' / ' + _list.length);
|
||||
// Display response information
|
||||
@ -635,7 +617,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
.appendTo(log);
|
||||
totals.failed++;
|
||||
// Ask to retry / ignore / abort
|
||||
et2_core_widget_1.et2_createWidget("dialog", {
|
||||
et2_createWidget("dialog", {
|
||||
callback: function (button) {
|
||||
switch (button) {
|
||||
case 'dialog[cancel]':
|
||||
@ -676,7 +658,7 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
// Scroll to bottom
|
||||
var height = log[0].scrollHeight;
|
||||
let height = log[0].scrollHeight;
|
||||
log.scrollTop(height);
|
||||
// Update totals
|
||||
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);
|
||||
});
|
||||
return dialog;
|
||||
};
|
||||
et2_dialog._attributes = {
|
||||
}
|
||||
}
|
||||
et2_dialog._attributes = {
|
||||
callback: {
|
||||
name: "Callback",
|
||||
type: "js",
|
||||
@ -837,28 +820,25 @@ var et2_dialog = /** @class */ (function (_super) {
|
||||
description: "Add css classed into dialog container",
|
||||
default: ''
|
||||
}
|
||||
};
|
||||
/**
|
||||
};
|
||||
/**
|
||||
* Types
|
||||
* @constant
|
||||
*/
|
||||
et2_dialog.PLAIN_MESSAGE = 0;
|
||||
et2_dialog.INFORMATION_MESSAGE = 1;
|
||||
et2_dialog.QUESTION_MESSAGE = 2;
|
||||
et2_dialog.WARNING_MESSAGE = 3;
|
||||
et2_dialog.ERROR_MESSAGE = 4;
|
||||
/* Pre-defined Button combos */
|
||||
et2_dialog.BUTTONS_OK = 0;
|
||||
et2_dialog.BUTTONS_OK_CANCEL = 1;
|
||||
et2_dialog.BUTTONS_YES_NO = 2;
|
||||
et2_dialog.BUTTONS_YES_NO_CANCEL = 3;
|
||||
/* Button constants */
|
||||
et2_dialog.CANCEL_BUTTON = 0;
|
||||
et2_dialog.OK_BUTTON = 1;
|
||||
et2_dialog.YES_BUTTON = 2;
|
||||
et2_dialog.NO_BUTTON = 3;
|
||||
return et2_dialog;
|
||||
}(et2_core_widget_2.et2_widget));
|
||||
exports.et2_dialog = et2_dialog;
|
||||
et2_core_widget_1.et2_register_widget(et2_dialog, ["dialog"]);
|
||||
et2_dialog.PLAIN_MESSAGE = 0;
|
||||
et2_dialog.INFORMATION_MESSAGE = 1;
|
||||
et2_dialog.QUESTION_MESSAGE = 2;
|
||||
et2_dialog.WARNING_MESSAGE = 3;
|
||||
et2_dialog.ERROR_MESSAGE = 4;
|
||||
/* Pre-defined Button combos */
|
||||
et2_dialog.BUTTONS_OK = 0;
|
||||
et2_dialog.BUTTONS_OK_CANCEL = 1;
|
||||
et2_dialog.BUTTONS_YES_NO = 2;
|
||||
et2_dialog.BUTTONS_YES_NO_CANCEL = 3;
|
||||
/* Button constants */
|
||||
et2_dialog.CANCEL_BUTTON = 0;
|
||||
et2_dialog.OK_BUTTON = 1;
|
||||
et2_dialog.YES_BUTTON = 2;
|
||||
et2_dialog.NO_BUTTON = 3;
|
||||
et2_register_widget(et2_dialog, ["dialog"]);
|
||||
//# sourceMappingURL=et2_widget_dialog.js.map
|
@ -3,10 +3,9 @@
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2013
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*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_button} from "./et2_widget_button";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_DOMWidget} from "./et2_core_DOMWidget";
|
||||
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.
|
||||
@ -479,7 +479,7 @@ export class et2_dialog extends et2_widget {
|
||||
this.template.clear();
|
||||
}
|
||||
|
||||
this.template = new etemplate2(this.div[0], false);
|
||||
this.template = new etemplate2(this.div[0]);
|
||||
if (template.indexOf('.xet') > 0) {
|
||||
// File name provided, fetch from server
|
||||
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|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);
|
||||
|
||||
// Just pass them along, widget handles defaults & missing
|
||||
return et2_createWidget("dialog", {
|
||||
return <et2_dialog>et2_createWidget("dialog", {
|
||||
callback: _callback || function () {
|
||||
},
|
||||
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 {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());
|
||||
et2_createWidget("dialog", {
|
||||
callback: function () {
|
||||
|
@ -1,61 +1,41 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Diff object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
/vendor/bower-asset/jquery-ui/jquery-ui.js;
|
||||
/vendor/bower-asset/diff2html/dist/diff2html.min.js;
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
/**
|
||||
* Class that displays the diff between two [text] values
|
||||
*
|
||||
* @augments et2_valueWidget
|
||||
*/
|
||||
var et2_diff = /** @class */ (function (_super) {
|
||||
__extends(et2_diff, _super);
|
||||
export class et2_diff extends et2_valueWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function et2_diff(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_diff._attributes, _child || {})) || this;
|
||||
_this.mini = true;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_diff._attributes, _child || {}));
|
||||
this.mini = true;
|
||||
// included via etemplate2.css
|
||||
//this.egw().includeCSS('../../../vendor/bower-asset/dist/dist2html.css');
|
||||
_this.div = document.createElement("div");
|
||||
jQuery(_this.div).addClass('et2_diff');
|
||||
return _this;
|
||||
this.div = document.createElement("div");
|
||||
jQuery(this.div).addClass('et2_diff');
|
||||
}
|
||||
et2_diff.prototype.set_value = function (value) {
|
||||
set_value(value) {
|
||||
jQuery(this.div).empty();
|
||||
if (typeof value == 'string') {
|
||||
// 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);
|
||||
}
|
||||
this.check_mini();
|
||||
};
|
||||
et2_diff.prototype.check_mini = function () {
|
||||
}
|
||||
check_mini() {
|
||||
if (!this.mini) {
|
||||
return false;
|
||||
}
|
||||
@ -94,13 +74,13 @@ var et2_diff = /** @class */ (function (_super) {
|
||||
width: 'auto',
|
||||
modal: true,
|
||||
buttons: [{ text: self.egw().lang('ok'), click: function () { jQuery(this).dialog("close"); } }],
|
||||
open: function () {
|
||||
open() {
|
||||
if (jQuery(this).parent().height() > jQuery(window).height()) {
|
||||
jQuery(this).height(jQuery(window).height() * 0.7);
|
||||
}
|
||||
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
|
||||
dialog_div.dialog("destroy");
|
||||
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;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Make the diff into a mini-diff
|
||||
*
|
||||
* @param {DOMNode|String} view
|
||||
*/
|
||||
et2_diff.prototype.minify = function (view) {
|
||||
minify(view) {
|
||||
view = jQuery(view)
|
||||
.addClass('mini')
|
||||
// Dialog changes these, if resized
|
||||
@ -127,17 +107,17 @@ var et2_diff = /** @class */ (function (_super) {
|
||||
jQuery('th', view).hide();
|
||||
jQuery('td.equal', view).hide()
|
||||
.prevAll().hide();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Expand mini-diff
|
||||
*
|
||||
* @param {DOMNode|String} view
|
||||
*/
|
||||
et2_diff.prototype.un_minify = function (view) {
|
||||
un_minify(view) {
|
||||
jQuery(view).removeClass('mini').show();
|
||||
jQuery('th', view).show();
|
||||
jQuery('td.equal', view).show();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Code for implementing et2_IDetachedDOM
|
||||
* 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
|
||||
*/
|
||||
et2_diff.prototype.getDetachedAttributes = function (_attrs) {
|
||||
getDetachedAttributes(_attrs) {
|
||||
_attrs.push("value", "label");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns an array of DOM nodes. The (relativly) same DOM-Nodes have to be
|
||||
* passed to the "setDetachedAttributes" function in the same order.
|
||||
*/
|
||||
et2_diff.prototype.getDetachedNodes = function () {
|
||||
getDetachedNodes() {
|
||||
return [this.div];
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Sets the given associative attribute->value array and applies the
|
||||
* 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
|
||||
* given values.
|
||||
*/
|
||||
et2_diff.prototype.setDetachedAttributes = function (_nodes, _values) {
|
||||
setDetachedAttributes(_nodes, _values) {
|
||||
this.div = _nodes[0];
|
||||
if (typeof _values['label'] != 'undefined') {
|
||||
this.set_label(_values['label']);
|
||||
@ -177,14 +157,12 @@ var et2_diff = /** @class */ (function (_super) {
|
||||
if (typeof _values['value'] != 'undefined') {
|
||||
this.set_value(_values['value']);
|
||||
}
|
||||
};
|
||||
et2_diff._attributes = {
|
||||
}
|
||||
}
|
||||
et2_diff._attributes = {
|
||||
"value": {
|
||||
"type": "any"
|
||||
}
|
||||
};
|
||||
return et2_diff;
|
||||
}(et2_core_valueWidget_1.et2_valueWidget));
|
||||
exports.et2_diff = et2_diff;
|
||||
et2_core_widget_1.et2_register_widget(et2_diff, ["diff"]);
|
||||
};
|
||||
et2_register_widget(et2_diff, ["diff"]);
|
||||
//# sourceMappingURL=et2_widget_diff.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2012
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -20,6 +19,7 @@
|
||||
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_valueWidget} from "./et2_core_valueWidget";
|
||||
import {et2_IDetachedDOM} from "./et2_core_interfaces";
|
||||
|
||||
/**
|
||||
* Class that displays the diff between two [text] values
|
||||
|
@ -1,38 +1,23 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Dropdown Button object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
/vendor/bower-asset/jquery-ui/jquery-ui.js;
|
||||
et2_baseWidget;
|
||||
*/
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_inputWidget } from './et2_core_inputWidget';
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
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
|
||||
*
|
||||
@ -47,33 +32,32 @@ var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
*
|
||||
* @augments et2_inputWidget
|
||||
*/
|
||||
var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
__extends(et2_dropdown_button, _super);
|
||||
export class et2_dropdown_button extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_dropdown_button
|
||||
*/
|
||||
function et2_dropdown_button(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_dropdown_button._attributes, _child || {})) || this;
|
||||
_this.internal_ids = {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_dropdown_button._attributes, _child || {}));
|
||||
this.internal_ids = {
|
||||
div: "",
|
||||
button: "",
|
||||
menu: ""
|
||||
};
|
||||
_this.div = null;
|
||||
_this.buttons = null;
|
||||
_this.button = null;
|
||||
_this.arrow = null;
|
||||
_this.menu = null;
|
||||
_this.image = null;
|
||||
_this.clicked = false;
|
||||
_this.label_updates = true;
|
||||
_this.value = null;
|
||||
this.div = null;
|
||||
this.buttons = null;
|
||||
this.button = null;
|
||||
this.arrow = null;
|
||||
this.menu = null;
|
||||
this.image = null;
|
||||
this.clicked = false;
|
||||
this.label_updates = true;
|
||||
this.value = null;
|
||||
/**
|
||||
* 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.2"><a href="#">Option-1.2</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>\
|
||||
<li data-id="opt_1.5"><a href="#">Option-1.5</a></li>\
|
||||
</ul>';
|
||||
_this.clicked = false;
|
||||
var self = _this;
|
||||
this.clicked = false;
|
||||
let self = this;
|
||||
// Create the individual UI elements
|
||||
// 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()
|
||||
.menu({
|
||||
select: function (event, ui) {
|
||||
self.onselect.call(self, event, ui.item);
|
||||
}
|
||||
});
|
||||
_this.buttons = jQuery(document.createElement("div"))
|
||||
this.buttons = jQuery(document.createElement("div"))
|
||||
.addClass("et2_dropdown");
|
||||
// Main "wrapper" div
|
||||
_this.div = jQuery(document.createElement("div"))
|
||||
.attr("id", _this.internal_ids.div)
|
||||
.append(_this.buttons)
|
||||
.append(_this.menu);
|
||||
this.div = jQuery(document.createElement("div"))
|
||||
.attr("id", this.internal_ids.div)
|
||||
.append(this.buttons)
|
||||
.append(this.menu);
|
||||
// Left side - activates click action
|
||||
_this.button = jQuery(document.createElement("button"))
|
||||
.attr("id", _this.internal_ids.button)
|
||||
this.button = jQuery(document.createElement("button"))
|
||||
.attr("id", this.internal_ids.button)
|
||||
.attr("type", "button")
|
||||
.addClass("ui-widget ui-corner-left").removeClass("ui-corner-all")
|
||||
.appendTo(_this.buttons);
|
||||
.appendTo(this.buttons);
|
||||
// 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")
|
||||
.attr("type", "button")
|
||||
.click(function () {
|
||||
@ -133,17 +117,16 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
})
|
||||
// This is the actual down arrow icon
|
||||
.append("<div class='ui-icon ui-icon-triangle-1-s'/>")
|
||||
.appendTo(_this.buttons);
|
||||
.appendTo(this.buttons);
|
||||
// Common button UI
|
||||
_this.buttons.children("button")
|
||||
this.buttons.children("button")
|
||||
.addClass("ui-state-default")
|
||||
.hover(function () { jQuery(this).addClass("ui-state-hover"); }, function () { jQuery(this).removeClass("ui-state-hover"); });
|
||||
// Icon
|
||||
_this.image = jQuery(document.createElement("img"));
|
||||
_this.setDOMNode(_this.div[0]);
|
||||
return _this;
|
||||
this.image = jQuery(document.createElement("img"));
|
||||
this.setDOMNode(this.div[0]);
|
||||
}
|
||||
et2_dropdown_button.prototype.destroy = function () {
|
||||
destroy() {
|
||||
// Destroy widget
|
||||
if (this.menu && this.menu.data('ui-menu'))
|
||||
this.menu.menu("destroy");
|
||||
@ -155,9 +138,9 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
this.menu = null;
|
||||
// Remove
|
||||
this.div.empty().remove();
|
||||
};
|
||||
et2_dropdown_button.prototype.set_id = function (_id) {
|
||||
_super.prototype.set_id.call(this, _id);
|
||||
}
|
||||
set_id(_id) {
|
||||
super.set_id(_id);
|
||||
// Update internal IDs - not really needed since we refer by internal
|
||||
// javascript reference, but good to keep up to date
|
||||
this.internal_ids = {
|
||||
@ -165,29 +148,29 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
button: this.dom_id,
|
||||
menu: this.dom_id + "_menu"
|
||||
};
|
||||
for (var key in this.internal_ids) {
|
||||
for (let key in this.internal_ids) {
|
||||
if (this[key] == null)
|
||||
continue;
|
||||
this[key].attr("id", this.internal_ids[key]);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set if the button label changes to match the selected option
|
||||
*
|
||||
* @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;
|
||||
};
|
||||
et2_dropdown_button.prototype.set_accesskey = function (key) {
|
||||
}
|
||||
set_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) {
|
||||
this.set_image(_image);
|
||||
}
|
||||
};
|
||||
et2_dropdown_button.prototype.set_image = function (_image) {
|
||||
}
|
||||
set_image(_image) {
|
||||
if (!this.isInTree() || this.image == null)
|
||||
return;
|
||||
if (!_image.trim()) {
|
||||
@ -196,7 +179,7 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.image.show();
|
||||
}
|
||||
var src = this.egw().image(_image);
|
||||
let src = this.egw().image(_image);
|
||||
if (src) {
|
||||
this.image.attr("src", src);
|
||||
}
|
||||
@ -207,60 +190,60 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.image.hide();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Overwritten to maintain an internal clicked attribute
|
||||
*
|
||||
* @param _ev
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
et2_dropdown_button.prototype.click = function (_ev) {
|
||||
click(_ev) {
|
||||
// ignore click on readonly button
|
||||
if (this.options.readonly)
|
||||
return false;
|
||||
this.clicked = true;
|
||||
if (!_super.prototype.click.call(this, _ev)) {
|
||||
if (!super.click(_ev)) {
|
||||
this.clicked = false;
|
||||
return false;
|
||||
}
|
||||
this.clicked = false;
|
||||
return true;
|
||||
};
|
||||
et2_dropdown_button.prototype.onselect = function (event, selected_node) {
|
||||
}
|
||||
onselect(event, selected_node) {
|
||||
this.set_value(selected_node.attr("data-id"));
|
||||
this.change(selected_node);
|
||||
};
|
||||
et2_dropdown_button.prototype.attachToDOM = function () {
|
||||
var res = _super.prototype.attachToDOM.call(this);
|
||||
}
|
||||
attachToDOM() {
|
||||
let res = super.attachToDOM();
|
||||
// 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");
|
||||
this.button.off().bind("click.et2_baseWidget", this, function (e) {
|
||||
return e.data.click.call(e.data, this);
|
||||
});
|
||||
return res;
|
||||
};
|
||||
et2_dropdown_button.prototype.set_label = function (_value) {
|
||||
}
|
||||
set_label(_value) {
|
||||
if (this.button) {
|
||||
this.label = _value;
|
||||
this.button.text(_value)
|
||||
.prepend(this.image);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the options for the dropdown
|
||||
*
|
||||
* @param options Object ID => Label pairs
|
||||
*/
|
||||
et2_dropdown_button.prototype.set_select_options = function (options) {
|
||||
set_select_options(options) {
|
||||
this.menu.first().empty();
|
||||
// Allow more complicated content, if passed
|
||||
if (typeof options == "string") {
|
||||
this.menu.append(options);
|
||||
}
|
||||
else {
|
||||
var add_complex_1 = function (node, options) {
|
||||
for (var key in options) {
|
||||
var item = void 0;
|
||||
let add_complex = function (node, options) {
|
||||
for (let key in options) {
|
||||
let item;
|
||||
if (typeof options[key] == "string") {
|
||||
item = jQuery("<li data-id='" + key + "'><a href='#'>" + options[key] + "</a></li>");
|
||||
}
|
||||
@ -270,7 +253,7 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
// Optgroup
|
||||
else {
|
||||
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);
|
||||
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");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set tab index
|
||||
*/
|
||||
et2_dropdown_button.prototype.set_tabindex = function (index) {
|
||||
set_tabindex(index) {
|
||||
jQuery(this.button).attr("tabindex", index);
|
||||
};
|
||||
et2_dropdown_button.prototype.set_value = function (new_value) {
|
||||
var menu_item = jQuery("[data-id='" + new_value + "']", this.menu);
|
||||
}
|
||||
set_value(new_value) {
|
||||
let menu_item = jQuery("[data-id='" + new_value + "']", this.menu);
|
||||
if (menu_item.length) {
|
||||
this.value = new_value;
|
||||
if (this.label_updates) {
|
||||
@ -303,16 +286,16 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
this.set_label(this.options.label);
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_dropdown_button.prototype.getValue = function () {
|
||||
}
|
||||
getValue() {
|
||||
return this.value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set options.readonly
|
||||
*
|
||||
* @param {boolean} _ro
|
||||
*/
|
||||
et2_dropdown_button.prototype.set_readonly = function (_ro) {
|
||||
set_readonly(_ro) {
|
||||
if (_ro != this.options.readonly) {
|
||||
this.options.readonly = _ro;
|
||||
// don't make readonly dropdown buttons clickable
|
||||
@ -323,8 +306,9 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
.css('cursor', _ro ? 'default' : 'pointer');
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_dropdown_button.attributes = {
|
||||
}
|
||||
}
|
||||
et2_dropdown_button.attributes = {
|
||||
"label": {
|
||||
"name": "caption",
|
||||
"type": "string",
|
||||
@ -375,9 +359,6 @@ var et2_dropdown_button = /** @class */ (function (_super) {
|
||||
"required": {
|
||||
"ignore": true
|
||||
}
|
||||
};
|
||||
return et2_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"]);
|
||||
};
|
||||
et2_register_widget(et2_dropdown_button, ["dropdown_button"]);
|
||||
//# sourceMappingURL=et2_widget_dropdown_button.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2013
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
@ -19,6 +18,8 @@
|
||||
import {et2_inputWidget} from './et2_core_inputWidget';
|
||||
import {WidgetConfig, et2_register_widget} from "./et2_core_widget";
|
||||
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
|
||||
|
@ -1,28 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Dynheight object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.et2_dynheight = void 0;
|
||||
/*egw:use
|
||||
/vendor/bower-asset/jquery/dist/jquery.js;
|
||||
et2_core_inheritance;
|
||||
*/
|
||||
import { egw } from "../jsapi/egw_global";
|
||||
/**
|
||||
* 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
|
||||
* nasty and time consuming calculations.
|
||||
*/
|
||||
var et2_dynheight = /** @class */ (function () {
|
||||
function et2_dynheight(_outerNode, _innerNode, _minHeight) {
|
||||
export class et2_dynheight {
|
||||
constructor(_outerNode, _innerNode, _minHeight) {
|
||||
this.initialized = false;
|
||||
this.minHeight = 0;
|
||||
this.bottomNodes = [];
|
||||
@ -32,11 +29,11 @@ var et2_dynheight = /** @class */ (function () {
|
||||
this.innerNode = jQuery(_innerNode);
|
||||
this.minHeight = _minHeight;
|
||||
}
|
||||
et2_dynheight.prototype.destroy = function () {
|
||||
destroy() {
|
||||
this.outerNode = null;
|
||||
this.innerNode = null;
|
||||
this.bottomNodes = [];
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resizes the inner node. When this is done, the callback function is
|
||||
* called.
|
||||
@ -44,21 +41,21 @@ var et2_dynheight = /** @class */ (function () {
|
||||
* @param {function} _callback
|
||||
* @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
|
||||
// trigger the callback function
|
||||
if (this.innerNode.is(":visible")) {
|
||||
// Initialize the height calculation
|
||||
this._initialize();
|
||||
// Get the outer container height and offset, if available
|
||||
var oh = this.outerNode.height();
|
||||
var ot = this.outerNode.offset() ? this.outerNode.offset().top : 0;
|
||||
const oh = this.outerNode.height();
|
||||
const ot = this.outerNode.offset() ? this.outerNode.offset().top : 0;
|
||||
// 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"
|
||||
var bminTop = this.bottomNodes.length ? Infinity : 0;
|
||||
var bmaxBot = 0;
|
||||
for (var i = 0; i < this.bottomNodes.length; i++) {
|
||||
let bminTop = this.bottomNodes.length ? Infinity : 0;
|
||||
let bmaxBot = 0;
|
||||
for (let i = 0; i < this.bottomNodes.length; i++) {
|
||||
// Ignore hidden popups
|
||||
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'));
|
||||
@ -68,9 +65,9 @@ var et2_dynheight = /** @class */ (function () {
|
||||
if (!this.bottomNodes[i].is(':visible'))
|
||||
continue;
|
||||
// Get height, top and bottom and calculate the maximum/minimum
|
||||
var bh_1 = this.bottomNodes[i].outerHeight(true);
|
||||
var bt = this.bottomNodes[i].offset().top;
|
||||
var bb = bh_1 + bt;
|
||||
let bh = this.bottomNodes[i].outerHeight(true);
|
||||
let bt = this.bottomNodes[i].offset().top;
|
||||
const bb = bh + bt;
|
||||
if (i == 0 || bminTop > bt) {
|
||||
bminTop = bt;
|
||||
}
|
||||
@ -79,15 +76,15 @@ var et2_dynheight = /** @class */ (function () {
|
||||
}
|
||||
}
|
||||
// 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
|
||||
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.innerNode.height(h);
|
||||
// Update the width
|
||||
// Some checking to make sure it doesn't overflow the width when user
|
||||
// resizes the window
|
||||
var w = this.outerNode.width();
|
||||
let w = this.outerNode.width();
|
||||
if (w > jQuery(window).width()) {
|
||||
// 50px border, totally arbitrary, but we just need to make sure it's inside
|
||||
w = jQuery(window).width() - 50;
|
||||
@ -100,7 +97,7 @@ var et2_dynheight = /** @class */ (function () {
|
||||
_callback.call(_context, w, h);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Function used internally which collects all DOM-Nodes which are located
|
||||
* below this element.
|
||||
@ -108,51 +105,49 @@ var et2_dynheight = /** @class */ (function () {
|
||||
* @param {HTMLElement} _node
|
||||
* @param {number} _bottom
|
||||
*/
|
||||
et2_dynheight.prototype._collectBottomNodes = function (_node, _bottom) {
|
||||
_collectBottomNodes(_node, _bottom) {
|
||||
// Calculate the bottom position of the inner node
|
||||
if (typeof _bottom == "undefined") {
|
||||
_bottom = this.innerNode.offset().top + this.innerNode.height();
|
||||
}
|
||||
if (_node) {
|
||||
// Accumulate the outer margin of the parent elements
|
||||
var node = jQuery(_node);
|
||||
var ooh = node.outerHeight(true);
|
||||
var oh = node.height();
|
||||
const node = jQuery(_node);
|
||||
const ooh = node.outerHeight(true);
|
||||
const oh = node.height();
|
||||
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
|
||||
// recursively to the parent nodes until the _outerNode or body is
|
||||
// reached.
|
||||
var self_1 = this;
|
||||
const self = this;
|
||||
jQuery(_node).children().each(function () {
|
||||
var $this = jQuery(this);
|
||||
var top = $this.offset().top;
|
||||
if (this != self_1.innerNode[0] && top >= _bottom) {
|
||||
self_1.bottomNodes.push($this);
|
||||
const $this = jQuery(this);
|
||||
const top = $this.offset().top;
|
||||
if (this != self.innerNode[0] && top >= _bottom) {
|
||||
self.bottomNodes.push($this);
|
||||
}
|
||||
});
|
||||
if (_node != this.outerNode[0] && _node != jQuery("body")[0]) {
|
||||
this._collectBottomNodes(_node.parentNode, _bottom);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Used internally to calculate some information which will not change over
|
||||
* the time.
|
||||
*/
|
||||
et2_dynheight.prototype._initialize = function () {
|
||||
_initialize() {
|
||||
if (!this.initialized) {
|
||||
// Collect all bottomNodes and calculates the outer margin
|
||||
this.bottomNodes = [];
|
||||
this.outerMargin = 0;
|
||||
this._collectBottomNodes(this.innerNode[0].parentNode);
|
||||
// Calculate the inner margin
|
||||
var ioh = this.innerNode.outerHeight(true);
|
||||
var ih = this.innerNode.height();
|
||||
const ioh = this.innerNode.outerHeight(true);
|
||||
const ih = this.innerNode.height();
|
||||
this.innerMargin = ioh - ih;
|
||||
this.initialized = true;
|
||||
}
|
||||
};
|
||||
return et2_dynheight;
|
||||
}());
|
||||
exports.et2_dynheight = et2_dynheight;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=et2_widget_dynheight.js.map
|
@ -4,10 +4,9 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Andreas Stöckel
|
||||
* @copyright Stylite 2011
|
||||
* @version $Id$
|
||||
* @copyright EGroupware GmbH 2011-2021
|
||||
*/
|
||||
|
||||
/*egw:use
|
||||
@ -15,6 +14,8 @@
|
||||
et2_core_inheritance;
|
||||
*/
|
||||
|
||||
import {egw} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -1,32 +1,18 @@
|
||||
"use strict";
|
||||
/*
|
||||
* Egroupware etemplate2 JS Entry widget
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @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
|
||||
et2_core_valueWidget;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_createWidget, et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_valueWidget } from "./et2_core_valueWidget";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { et2_no_init } from "./et2_core_common";
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
var et2_entry = /** @class */ (function (_super) {
|
||||
__extends(et2_entry, _super);
|
||||
function et2_entry(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
export class et2_entry extends et2_valueWidget {
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {})) || this;
|
||||
_this.widget = null;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {}));
|
||||
this.widget = null;
|
||||
// Often the ID conflicts, so check prefix
|
||||
if (_attrs.id && _attrs.id.indexOf(et2_entry.prefix) < 0) {
|
||||
_attrs.id = et2_entry.prefix + _attrs.id;
|
||||
}
|
||||
var value = _attrs.value;
|
||||
_this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {})) || this;
|
||||
let value = _attrs.value;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_entry._attributes, _child || {}));
|
||||
// Save value from parsing, but only if set
|
||||
if (value) {
|
||||
_this.options.value = value;
|
||||
this.options.value = value;
|
||||
}
|
||||
_this.widget = null;
|
||||
_this.setDOMNode(document.createElement('span'));
|
||||
return _this;
|
||||
this.widget = null;
|
||||
this.setDOMNode(document.createElement('span'));
|
||||
}
|
||||
et2_entry.prototype.loadFromXML = function (_node) {
|
||||
loadFromXML(_node) {
|
||||
// Load the nodes as usual
|
||||
_super.prototype.loadFromXML.call(this, _node);
|
||||
super.loadFromXML(_node);
|
||||
// Do the magic
|
||||
this.loadField();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Initialize widget for entry field
|
||||
*/
|
||||
et2_entry.prototype.loadField = function () {
|
||||
loadField() {
|
||||
// Create widget of correct type
|
||||
var attrs = {
|
||||
let attrs = {
|
||||
id: this.id + (this.options.field ? '[' + this.options.field + ']' : ''),
|
||||
type: 'label',
|
||||
readonly: this.options.readonly
|
||||
};
|
||||
var modifications = this.getArrayMgr("modifications");
|
||||
let modifications = this.getArrayMgr("modifications");
|
||||
if (modifications && this.options.field) {
|
||||
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.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 was set, find the record explicitly.
|
||||
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' : '';
|
||||
}
|
||||
if (this.options.alternate_fields) {
|
||||
var sum = 0;
|
||||
var fields = this.options.alternate_fields.split(':');
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var negate = (fields[i][0] == "-");
|
||||
var value = this.getArrayMgr('content').getEntry(fields[i].replace('-', ''));
|
||||
let sum = 0;
|
||||
let fields = this.options.alternate_fields.split(':');
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
let negate = (fields[i][0] == "-");
|
||||
let value = this.getArrayMgr('content').getEntry(fields[i].replace('-', ''));
|
||||
sum += typeof value === 'undefined' ? 0 : (parseFloat(value) * (negate ? -1 : 1));
|
||||
if (value && this.options.field !== 'sum') {
|
||||
widget.options.value = value;
|
||||
@ -118,8 +101,9 @@ var et2_entry = /** @class */ (function (_super) {
|
||||
widget.options.value = sum;
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_entry._attributes = {
|
||||
}
|
||||
}
|
||||
et2_entry._attributes = {
|
||||
field: {
|
||||
'name': '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: {
|
||||
default: true
|
||||
}
|
||||
};
|
||||
et2_entry.legacyOptions = ["field", "compare", "alternate_fields"];
|
||||
et2_entry.prefix = '~';
|
||||
return et2_entry;
|
||||
}(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']);
|
||||
};
|
||||
et2_entry.legacyOptions = ["field", "compare", "alternate_fields"];
|
||||
et2_entry.prefix = '~';
|
||||
et2_register_widget(et2_entry, ["entry", 'contact-value', 'contact-account', 'contact-template', 'infolog-value', 'tracker-value', 'records-value']);
|
||||
//# sourceMappingURL=et2_widget_entry.js.map
|
@ -3,7 +3,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
*/
|
||||
|
||||
@ -12,9 +12,10 @@
|
||||
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 {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {et2_no_init} from "./et2_core_common";
|
||||
|
||||
/**
|
||||
* A widget to display a value from an entry
|
||||
@ -30,7 +31,7 @@ import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
*
|
||||
* @augments et2_valueWidget
|
||||
*/
|
||||
class et2_entry extends et2_valueWidget
|
||||
export class et2_entry extends et2_valueWidget
|
||||
{
|
||||
static readonly _attributes : any = {
|
||||
field: {
|
||||
|
@ -1,36 +1,21 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Favorite widget
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
et2_dropdown_button;
|
||||
et2_extension_nextmatch;
|
||||
*/
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_widget_dropdown_button_1 = require("./et2_widget_dropdown_button");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
import { et2_dropdown_button } from "./et2_widget_dropdown_button";
|
||||
import { ClassWithAttributes } from "./et2_core_inheritance";
|
||||
import { app, egw, egw_getFramework } from "../jsapi/egw_global";
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
var et2_favorites = /** @class */ (function (_super) {
|
||||
__extends(et2_favorites, _super);
|
||||
export class et2_favorites extends et2_dropdown_button {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_favorites
|
||||
*/
|
||||
function et2_favorites(_parent, _attrs, _child) {
|
||||
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_favorites._attributes, _child || {})) || this;
|
||||
constructor(_parent, _attrs, _child) {
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_favorites._attributes, _child || {}));
|
||||
// Some convenient variables, used in closures / event handlers
|
||||
_this.header = null;
|
||||
_this.nextmatch = null;
|
||||
_this.favSortedList = null;
|
||||
_this.sidebox_target = null;
|
||||
this.header = null;
|
||||
this.nextmatch = null;
|
||||
this.favSortedList = null;
|
||||
this.sidebox_target = null;
|
||||
// If filter was set server side, we need to remember it until nm is created
|
||||
_this.nm_filter = false;
|
||||
_this.sidebox_target = jQuery("#" + _this.options.sidebox_target);
|
||||
if (_this.sidebox_target.length == 0 && egw_getFramework() != null) {
|
||||
var egw_fw = egw_getFramework();
|
||||
_this.sidebox_target = jQuery("#" + _this.options.sidebox_target, egw_fw.sidemenuDiv);
|
||||
this.nm_filter = false;
|
||||
this.sidebox_target = jQuery("#" + this.options.sidebox_target);
|
||||
if (this.sidebox_target.length == 0 && egw_getFramework() != null) {
|
||||
let egw_fw = egw_getFramework();
|
||||
this.sidebox_target = jQuery("#" + this.options.sidebox_target, egw_fw.sidemenuDiv);
|
||||
}
|
||||
// Store array of sorted items
|
||||
_this.favSortedList = ['blank'];
|
||||
var apps = egw().user('apps');
|
||||
this.favSortedList = ['blank'];
|
||||
let apps = egw().user('apps');
|
||||
et2_favorites.is_admin = (typeof apps['admin'] != "undefined");
|
||||
// Make sure we have an app
|
||||
if (!_this.options.app) {
|
||||
_this.options.app = _this.getInstanceManager().app;
|
||||
if (!this.options.app) {
|
||||
this.options.app = this.getInstanceManager().app;
|
||||
}
|
||||
_this.stored_filters = _this.load_favorites(_this.options.app);
|
||||
_this.preferred = egw.preference(_this.options.default_pref, _this.options.app);
|
||||
if (!_this.preferred || typeof _this.stored_filters[_this.preferred] == "undefined") {
|
||||
_this.preferred = "blank";
|
||||
this.stored_filters = this.load_favorites(this.options.app);
|
||||
this.preferred = egw.preference(this.options.default_pref, this.options.app);
|
||||
if (!this.preferred || typeof this.stored_filters[this.preferred] == "undefined") {
|
||||
this.preferred = "blank";
|
||||
}
|
||||
// It helps to have the ID properly set before we get too far
|
||||
_this.set_id(_this.id);
|
||||
_this.init_filters(_this);
|
||||
_this.menu.addClass("favorites");
|
||||
this.set_id(this.id);
|
||||
this.init_filters(this);
|
||||
this.menu.addClass("favorites");
|
||||
// Set the default (button) value
|
||||
_this.set_value(_this.preferred, true);
|
||||
var self = _this;
|
||||
this.set_value(this.preferred, true);
|
||||
let self = this;
|
||||
// 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
|
||||
event.stopImmediatePropagation();
|
||||
// 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
|
||||
var sideBoxDOMNodeSort = function (_favSList) {
|
||||
var favS = jQuery.isArray(_favSList) ? _favSList.slice(0).reverse() : [];
|
||||
for (var i = 0; i < favS.length; i++) {
|
||||
let sideBoxDOMNodeSort = function (_favSList) {
|
||||
let favS = jQuery.isArray(_favSList) ? _favSList.slice(0).reverse() : [];
|
||||
for (let i = 0; i < favS.length; i++) {
|
||||
self.sidebox_target.children().find('[data-id$="' + favS[i] + '"]').prependTo(self.sidebox_target.children());
|
||||
}
|
||||
};
|
||||
//Add Sortable handler to nm fav. menu
|
||||
jQuery(_this.menu).sortable({
|
||||
jQuery(this.menu).sortable({
|
||||
items: 'li:not([data-id$="add"])',
|
||||
placeholder: 'ui-fav-sortable-placeholder',
|
||||
delay: 250,
|
||||
@ -139,7 +123,7 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
}
|
||||
});
|
||||
// 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[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(); });
|
||||
// Trigger refresh of menu options now that events are registered
|
||||
// to update sidebox
|
||||
if (_this.sidebox_target.length > 0) {
|
||||
_this.init_filters(_this);
|
||||
if (this.sidebox_target.length > 0) {
|
||||
this.init_filters(this);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Load favorites from preferences
|
||||
*
|
||||
* @param app String Load favorites from this application
|
||||
*/
|
||||
et2_favorites.prototype.load_favorites = function (app) {
|
||||
load_favorites(app) {
|
||||
// Default blank filter
|
||||
var stored_filters = {
|
||||
let stored_filters = {
|
||||
'blank': {
|
||||
name: this.egw().lang("No filters"),
|
||||
state: {}
|
||||
}
|
||||
};
|
||||
// Load saved favorites
|
||||
var preferences = egw.preference("*", app);
|
||||
for (var pref_name in preferences) {
|
||||
let preferences = egw.preference("*", app);
|
||||
for (let pref_name in preferences) {
|
||||
if (pref_name.indexOf(et2_favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object') {
|
||||
var name_1 = pref_name.substr(et2_favorites.PREFIX.length);
|
||||
stored_filters[name_1] = preferences[pref_name];
|
||||
let name = pref_name.substr(et2_favorites.PREFIX.length);
|
||||
stored_filters[name] = preferences[pref_name];
|
||||
// Keep older favorites working - they used to store nm filters in 'filters',not state
|
||||
if (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 = {};
|
||||
}
|
||||
else {
|
||||
for (var name_2 in stored_filters) {
|
||||
if (this.favSortedList.indexOf(name_2) < 0) {
|
||||
this.favSortedList.push(name_2);
|
||||
for (let name in stored_filters) {
|
||||
if (this.favSortedList.indexOf(name) < 0) {
|
||||
this.favSortedList.push(name);
|
||||
}
|
||||
}
|
||||
this.egw().set_preference(this.options.app, 'fav_sort_pref', this.favSortedList);
|
||||
if (this.favSortedList.length > 0) {
|
||||
var sortedListObj = {};
|
||||
for (var i = 0; i < this.favSortedList.length; i++) {
|
||||
let sortedListObj = {};
|
||||
for (let i = 0; i < this.favSortedList.length; i++) {
|
||||
if (typeof stored_filters[this.favSortedList[i]] != 'undefined') {
|
||||
sortedListObj[this.favSortedList[i]] = stored_filters[this.favSortedList[i]];
|
||||
}
|
||||
@ -210,18 +193,18 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return stored_filters;
|
||||
};
|
||||
}
|
||||
// Create & set filter options for dropdown menu
|
||||
et2_favorites.prototype.init_filters = function (widget, filters) {
|
||||
init_filters(widget, filters) {
|
||||
if (typeof filters == "undefined") {
|
||||
filters = this.stored_filters;
|
||||
}
|
||||
var options = {};
|
||||
for (var name_3 in filters) {
|
||||
options[name_3] = "<input type='radio' name='" + this.internal_ids.menu + "[button][favorite]' value='" + name_3 + "' title='" +
|
||||
let options = {};
|
||||
for (let name in filters) {
|
||||
options[name] = "<input type='radio' name='" + this.internal_ids.menu + "[button][favorite]' value='" + name + "' title='" +
|
||||
this.egw().lang('Set as default') + "'/>" +
|
||||
(filters[name_3].name != undefined ? filters[name_3].name : name_3) +
|
||||
(filters[name_3].group != false && !et2_favorites.is_admin || name_3 == 'blank' ? "" :
|
||||
(filters[name].name != undefined ? filters[name].name : name) +
|
||||
(filters[name].group != false && !et2_favorites.is_admin || name == 'blank' ? "" :
|
||||
"<div class='ui-icon ui-icon-trash' title='" + this.egw().lang('Delete') + "'/>");
|
||||
}
|
||||
// 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);
|
||||
// Set radio to current value
|
||||
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) {
|
||||
this.nextmatch.applyFilters(filters);
|
||||
}
|
||||
else {
|
||||
console.log(filters);
|
||||
}
|
||||
};
|
||||
et2_favorites.prototype.onclick = function (node) {
|
||||
}
|
||||
onclick(node) {
|
||||
// Apply preferred filter - make sure it's an object, and not a reference
|
||||
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)
|
||||
@ -254,15 +237,15 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
else {
|
||||
alert(this.egw().lang("No default set"));
|
||||
}
|
||||
};
|
||||
}
|
||||
// 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");
|
||||
if (this.value == "add" && this.nextmatch) {
|
||||
// Get current filters
|
||||
var current_filters = jQuery.extend({}, this.nextmatch.activeFilters);
|
||||
let current_filters = jQuery.extend({}, this.nextmatch.activeFilters);
|
||||
// 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
|
||||
if (typeof current_filters == 'undefined') {
|
||||
current_filters[extra] = this.nextmatch.options.settings[extra];
|
||||
@ -272,7 +255,7 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
delete current_filters.selcolumns;
|
||||
// Add in application's settings
|
||||
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]];
|
||||
}
|
||||
}
|
||||
@ -285,26 +268,26 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
// Reset filters when select no filters
|
||||
this.set_nm_filters({});
|
||||
}
|
||||
};
|
||||
et2_favorites.prototype.set_value = function (filter_name, parent) {
|
||||
}
|
||||
set_value(filter_name, parent) {
|
||||
if (parent) {
|
||||
return _super.prototype.set_value.call(this, filter_name);
|
||||
return super.set_value(filter_name);
|
||||
}
|
||||
if (filter_name == 'add')
|
||||
return false;
|
||||
app[this.options.app].setState(this.stored_filters[filter_name]);
|
||||
return false;
|
||||
};
|
||||
et2_favorites.prototype.getValue = function () {
|
||||
}
|
||||
getValue() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the nextmatch to filter
|
||||
* From et2_INextmatchHeader interface
|
||||
*
|
||||
* @param {et2_nextmatch} nextmatch
|
||||
*/
|
||||
et2_favorites.prototype.setNextmatch = function (nextmatch) {
|
||||
setNextmatch(nextmatch) {
|
||||
this.nextmatch = nextmatch;
|
||||
if (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'
|
||||
this.init_filters(this);
|
||||
};
|
||||
et2_favorites._attributes = {
|
||||
}
|
||||
}
|
||||
et2_favorites._attributes = {
|
||||
"default_pref": {
|
||||
"name": "Default preference key",
|
||||
"type": "string",
|
||||
@ -341,10 +325,7 @@ var et2_favorites = /** @class */ (function (_super) {
|
||||
label_updates: { "default": false },
|
||||
image: { "default": egw().image('fav_filter') },
|
||||
statustext: { "default": "Favorite queries", "type": "string" }
|
||||
};
|
||||
et2_favorites.PREFIX = "favorite_";
|
||||
return et2_favorites;
|
||||
}(et2_widget_dropdown_button_1.et2_dropdown_button));
|
||||
exports.et2_favorites = et2_favorites;
|
||||
et2_core_widget_1.et2_register_widget(et2_favorites, ["favorites"]);
|
||||
};
|
||||
et2_favorites.PREFIX = "favorite_";
|
||||
et2_register_widget(et2_favorites, ["favorites"]);
|
||||
//# sourceMappingURL=et2_widget_favorites.js.map
|
@ -4,7 +4,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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_dropdown_button} from "./et2_widget_dropdown_button";
|
||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||
import {app, egw, egw_getFramework} from "../jsapi/egw_global";
|
||||
|
||||
/**
|
||||
* Favorites widget, designed for use with a nextmatch widget
|
||||
|
@ -1,103 +1,86 @@
|
||||
"use strict";
|
||||
/**
|
||||
* EGroupware eTemplate2 - JS Number object
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @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
|
||||
et2_core_inputWidget;
|
||||
phpgwapi.Resumable.resumable;
|
||||
api.Resumable.resumable;
|
||||
*/
|
||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||
var et2_core_widget_1 = require("./et2_core_widget");
|
||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||
import { et2_inputWidget } from "./et2_core_inputWidget";
|
||||
import { et2_register_widget } from "./et2_core_widget";
|
||||
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
|
||||
*
|
||||
* @augments et2_inputWidget
|
||||
*/
|
||||
var et2_file = /** @class */ (function (_super) {
|
||||
__extends(et2_file, _super);
|
||||
export class et2_file extends et2_inputWidget {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf et2_file
|
||||
*/
|
||||
function et2_file(_parent, _attrs, _child) {
|
||||
var _this =
|
||||
constructor(_parent, _attrs, _child) {
|
||||
// Call the inherited constructor
|
||||
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_file._attributes, _child || {})) || this;
|
||||
_this.asyncOptions = {};
|
||||
_this.input = null;
|
||||
_this.progress = null;
|
||||
_this.span = null;
|
||||
_this.node = null;
|
||||
_this.input = null;
|
||||
_this.progress = null;
|
||||
_this.span = null;
|
||||
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_file._attributes, _child || {}));
|
||||
this.asyncOptions = {};
|
||||
this.input = null;
|
||||
this.progress = null;
|
||||
this.span = null;
|
||||
this.node = null;
|
||||
this.input = null;
|
||||
this.progress = null;
|
||||
this.span = null;
|
||||
// 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
|
||||
_this.options.value = jQuery.extend({}, _this.options.value);
|
||||
if (!_this.options.id) {
|
||||
this.options.value = jQuery.extend({}, this.options.value);
|
||||
if (!this.options.id) {
|
||||
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
|
||||
if (_this.options.id.substr(-2) == "[]") {
|
||||
_this.options.multiple = true;
|
||||
if (this.options.id.substr(-2) == "[]") {
|
||||
this.options.multiple = true;
|
||||
}
|
||||
// If ID ends in /, it's a directory - allow multiple
|
||||
else if (_this.options.id.substr(-1) === "/") {
|
||||
_this.options.multiple = true;
|
||||
else if (this.options.id.substr(-1) === "/") {
|
||||
this.options.multiple = true;
|
||||
_attrs.multiple = true;
|
||||
}
|
||||
// Set up the URL to have the request ID & the widget ID
|
||||
var instance = _this.getInstanceManager();
|
||||
var self = _this;
|
||||
_this.asyncOptions = jQuery.extend({}, _this.getAsyncOptions(_this));
|
||||
_this.asyncOptions.fieldName = _this.options.id;
|
||||
_this.createInputWidget();
|
||||
_this.set_readonly(_this.options.readonly);
|
||||
return _this;
|
||||
var instance = this.getInstanceManager();
|
||||
let self = this;
|
||||
this.asyncOptions = jQuery.extend({}, this.getAsyncOptions(this));
|
||||
this.asyncOptions.fieldName = this.options.id;
|
||||
this.createInputWidget();
|
||||
this.set_readonly(this.options.readonly);
|
||||
}
|
||||
et2_file.prototype.destroy = function () {
|
||||
_super.prototype.destroy.call(this);
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.set_drop_target(null);
|
||||
this.node = null;
|
||||
this.input = null;
|
||||
this.span = null;
|
||||
this.progress = null;
|
||||
};
|
||||
et2_file.prototype.createInputWidget = function () {
|
||||
}
|
||||
createInputWidget() {
|
||||
this.node = jQuery(document.createElement("div")).addClass("et2_file");
|
||||
this.span = jQuery(document.createElement("span"))
|
||||
.addClass('et2_file_span et2_button')
|
||||
.appendTo(this.node);
|
||||
if (this.options.label != '')
|
||||
this.span.addClass('et2_button_text');
|
||||
var span = this.span;
|
||||
let span = this.span;
|
||||
this.input = jQuery(document.createElement("input"))
|
||||
.attr("type", "file").attr("placeholder", this.options.blur)
|
||||
.addClass("et2_file_upload")
|
||||
@ -116,7 +99,7 @@ var et2_file = /** @class */ (function (_super) {
|
||||
});
|
||||
if (this.options.accept)
|
||||
this.input.attr('accept', this.options.accept);
|
||||
var self = this;
|
||||
let self = this;
|
||||
// trigger native input upload file
|
||||
if (!this.options.readonly)
|
||||
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
|
||||
}
|
||||
if (this.options.progress) {
|
||||
var widget = this.getRoot().getWidgetById(this.options.progress);
|
||||
let widget = this.getRoot().getWidgetById(this.options.progress);
|
||||
if (widget) {
|
||||
//may be not available at createInputWidget time
|
||||
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
|
||||
if (!this.options.drop_target)
|
||||
this.resumable.assignDrop([this.getDOMNode()]);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get any specific async upload options
|
||||
*/
|
||||
et2_file.prototype.getAsyncOptions = function (self) {
|
||||
getAsyncOptions(self) {
|
||||
return {
|
||||
// Callbacks
|
||||
onStart: function (event, file_count) {
|
||||
@ -175,43 +158,43 @@ var et2_file = /** @class */ (function (_super) {
|
||||
// Disable checking for already uploaded chunks
|
||||
testChunks: false
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_file.prototype.set_drop_target = function (new_target) {
|
||||
set_drop_target(new_target) {
|
||||
// Cancel old drop target
|
||||
if (this.options.drop_target) {
|
||||
var widget_1 = this.getRoot().getWidgetById(this.options.drop_target);
|
||||
var drop_target_1 = widget_1 && widget_1.getDOMNode() || document.getElementById(this.options.drop_target);
|
||||
if (drop_target_1) {
|
||||
this.resumable.unAssignDrop(drop_target_1);
|
||||
let widget = this.getRoot().getWidgetById(this.options.drop_target);
|
||||
let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
|
||||
if (drop_target) {
|
||||
this.resumable.unAssignDrop(drop_target);
|
||||
}
|
||||
}
|
||||
this.options.drop_target = new_target;
|
||||
if (!this.options.drop_target)
|
||||
return;
|
||||
// Set up new drop target
|
||||
var widget = this.getRoot().getWidgetById(this.options.drop_target);
|
||||
var drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
|
||||
let widget = this.getRoot().getWidgetById(this.options.drop_target);
|
||||
let drop_target = widget && widget.getDOMNode() || document.getElementById(this.options.drop_target);
|
||||
if (drop_target) {
|
||||
this.resumable.assignDrop([drop_target]);
|
||||
}
|
||||
else {
|
||||
this.egw().debug("warn", "Did not find file drop target %s", this.options.drop_target);
|
||||
}
|
||||
};
|
||||
et2_file.prototype.attachToDOM = function () {
|
||||
var res = _super.prototype.attachToDOM.call(this);
|
||||
}
|
||||
attachToDOM() {
|
||||
let res = super.attachToDOM();
|
||||
// Override parent's change, file widget will fire change when finished uploading
|
||||
this.input.unbind("change.et2_inputWidget");
|
||||
return res;
|
||||
};
|
||||
et2_file.prototype.getValue = function () {
|
||||
}
|
||||
getValue() {
|
||||
return this.options.value ? this.options.value : this.input.val();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* 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") {
|
||||
value = {};
|
||||
}
|
||||
@ -234,7 +217,7 @@ var et2_file = /** @class */ (function (_super) {
|
||||
this.input.unwrap();
|
||||
return;
|
||||
}
|
||||
var addFile = jQuery.proxy(function (i, file) {
|
||||
let addFile = jQuery.proxy(function (i, file) {
|
||||
this.resumable.addFile(file, event);
|
||||
}, this);
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set the value for label
|
||||
* The label is used as caption for span tag which customize the HTML file upload styling
|
||||
*
|
||||
* @param {string} value text value of label
|
||||
*/
|
||||
et2_file.prototype.set_label = function (value) {
|
||||
set_label(value) {
|
||||
if (this.span != null && value != null) {
|
||||
this.span.text(value);
|
||||
}
|
||||
};
|
||||
et2_file.prototype.getInputNode = function () {
|
||||
}
|
||||
getInputNode() {
|
||||
if (typeof this.input == 'undefined')
|
||||
return false;
|
||||
return this.input[0];
|
||||
};
|
||||
et2_file.prototype.set_mime = function (mime) {
|
||||
}
|
||||
set_mime(mime) {
|
||||
if (!mime) {
|
||||
this.options.mime = null;
|
||||
}
|
||||
@ -276,24 +259,24 @@ var et2_file = /** @class */ (function (_super) {
|
||||
else {
|
||||
this.options.mime = mime;
|
||||
}
|
||||
};
|
||||
et2_file.prototype.set_multiple = function (_multiple) {
|
||||
}
|
||||
set_multiple(_multiple) {
|
||||
this.options.multiple = _multiple;
|
||||
if (_multiple) {
|
||||
return this.input.attr("multiple", "multiple");
|
||||
}
|
||||
return this.input.removeAttr("multiple");
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check to see if the provided file's mimetype matches
|
||||
*
|
||||
* @param f File object
|
||||
* @return boolean
|
||||
*/
|
||||
et2_file.prototype.checkMime = function (f) {
|
||||
checkMime(f) {
|
||||
if (!this.options.mime)
|
||||
return true;
|
||||
var mime = '';
|
||||
let mime = '';
|
||||
if (this.options.mime.indexOf("/") != 0) {
|
||||
// Lower case it now, if it's not a regex
|
||||
mime = this.options.mime.toLowerCase();
|
||||
@ -312,8 +295,8 @@ var et2_file = /** @class */ (function (_super) {
|
||||
}
|
||||
// Not right mime
|
||||
return false;
|
||||
};
|
||||
et2_file.prototype._fileAdded = function (file, event) {
|
||||
}
|
||||
_fileAdded(file, event) {
|
||||
// Manual additions have no event
|
||||
if (typeof event == 'undefined') {
|
||||
event = {};
|
||||
@ -341,21 +324,21 @@ var et2_file = /** @class */ (function (_super) {
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Add in the request id
|
||||
*/
|
||||
et2_file.prototype.beforeSend = function (form) {
|
||||
beforeSend(form) {
|
||||
var instance = this.getInstanceManager();
|
||||
return {
|
||||
request_id: instance.etemplate_exec_id,
|
||||
widget_id: this.id
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Disables submit buttons while uploading
|
||||
*/
|
||||
et2_file.prototype.onStart = function (event, file_count) {
|
||||
onStart(event, file_count) {
|
||||
// Hide any previous errors
|
||||
this.hideMessage();
|
||||
event.data = this;
|
||||
@ -367,11 +350,11 @@ var et2_file = /** @class */ (function (_super) {
|
||||
if (this.options.onStart)
|
||||
return et2_call(this.options.onStart, event, file_count);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Re-enables submit buttons when done
|
||||
*/
|
||||
et2_file.prototype.onFinish = function () {
|
||||
onFinish() {
|
||||
this.disabled_buttons.removeAttr("disabled").css('cursor', 'pointer').removeClass('et2_button_ro');
|
||||
var file_count = this.resumable.files.length;
|
||||
// Remove files from list
|
||||
@ -397,13 +380,13 @@ var et2_file = /** @class */ (function (_super) {
|
||||
// Fire legacy change action when done
|
||||
this.change(this.input);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
et2_file.prototype._build_progressDropDownList = function () {
|
||||
_build_progressDropDownList() {
|
||||
this.progress.addClass("progress_dropDown_fileList");
|
||||
//Add uploading indicator and bind hover handler on it
|
||||
jQuery(this.node).find('span').addClass('totalProgress_loader');
|
||||
@ -416,14 +399,14 @@ var et2_file = /** @class */ (function (_super) {
|
||||
jQuery('.progress_dropDown_fileList').hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates the elements used for displaying the file, and it's upload status, and
|
||||
* attaches them to the DOM
|
||||
*
|
||||
* @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);
|
||||
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));
|
||||
@ -448,20 +431,20 @@ var et2_file = /** @class */ (function (_super) {
|
||||
}
|
||||
}
|
||||
return error == "";
|
||||
};
|
||||
et2_file.prototype._fileProgress = function (file) {
|
||||
}
|
||||
_fileProgress(file) {
|
||||
if (this.progress) {
|
||||
jQuery("li[data-file='" + file.fileName.replace(/'/g, '"') + "'] > span.progressBar > p").css("width", Math.ceil(file.progress() * 100) + "%");
|
||||
}
|
||||
return true;
|
||||
};
|
||||
et2_file.prototype.onError = function (event, name, error) {
|
||||
}
|
||||
onError(event, name, error) {
|
||||
console.warn(event, name, error);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A file upload is finished, update the UI
|
||||
*/
|
||||
et2_file.prototype.finishUpload = function (file, response) {
|
||||
finishUpload(file, response) {
|
||||
var name = file.fileName || 'file';
|
||||
if (typeof response == 'string')
|
||||
response = jQuery.parseJSON(response);
|
||||
@ -502,13 +485,13 @@ var et2_file = /** @class */ (function (_super) {
|
||||
this.onFinishOne(event, response, name);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Remove a file from the list of values
|
||||
*
|
||||
* @param {File|string} File object, or file name, to remove
|
||||
*/
|
||||
et2_file.prototype.remove_file = function (file) {
|
||||
remove_file(file) {
|
||||
//console.info(filename);
|
||||
if (typeof file == 'string') {
|
||||
file = { fileName: file };
|
||||
@ -522,11 +505,11 @@ var et2_file = /** @class */ (function (_super) {
|
||||
}
|
||||
if (file.isComplete && !file.isComplete() && file.cancel)
|
||||
file.cancel();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Cancel a file - event callback
|
||||
*/
|
||||
et2_file.prototype.cancel = function (e) {
|
||||
cancel(e) {
|
||||
e.preventDefault();
|
||||
// Look for file name in list
|
||||
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)
|
||||
target.remove();
|
||||
jQuery(e.target).remove();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Set readonly
|
||||
*
|
||||
* @param {boolean} _ro boolean readonly state, true means readonly
|
||||
*/
|
||||
et2_file.prototype.set_readonly = function (_ro) {
|
||||
set_readonly(_ro) {
|
||||
if (typeof _ro != "undefined") {
|
||||
this.options.readonly = _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(); });
|
||||
}
|
||||
}
|
||||
};
|
||||
et2_file._attributes = {
|
||||
}
|
||||
}
|
||||
et2_file._attributes = {
|
||||
"multiple": {
|
||||
"name": "Multiple files",
|
||||
"type": "boolean",
|
||||
@ -632,9 +616,6 @@ var et2_file = /** @class */ (function (_super) {
|
||||
"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!
|
||||
}
|
||||
};
|
||||
return et2_file;
|
||||
}(et2_core_inputWidget_1.et2_inputWidget));
|
||||
exports.et2_file = et2_file;
|
||||
et2_core_widget_1.et2_register_widget(et2_file, ["file"]);
|
||||
};
|
||||
et2_register_widget(et2_file, ["file"]);
|
||||
//# sourceMappingURL=et2_widget_file.js.map
|
@ -4,20 +4,23 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @link https://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright Nathan Gray 2011
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/*egw:uses
|
||||
et2_core_inputWidget;
|
||||
phpgwapi.Resumable.resumable;
|
||||
api.Resumable.resumable;
|
||||
*/
|
||||
|
||||
import {et2_inputWidget} from "./et2_core_inputWidget";
|
||||
import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||
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
|
||||
@ -293,7 +296,7 @@ export class et2_file extends et2_inputWidget
|
||||
if(!this.options.drop_target) return;
|
||||
|
||||
// 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);
|
||||
if(drop_target)
|
||||
{
|
||||
@ -603,7 +606,7 @@ export class et2_file extends et2_inputWidget
|
||||
|
||||
if(this.options.progress)
|
||||
{
|
||||
var widget = this.getRoot().getWidgetById(this.options.progress);
|
||||
var widget = <et2_DOMWidget>this.getRoot().getWidgetById(this.options.progress);
|
||||
if(widget)
|
||||
{
|
||||
this.progress = jQuery(widget.getDOMNode());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user