Deal with some typescript warnings

This commit is contained in:
nathangray 2020-02-12 15:18:10 -07:00
parent 6857c42091
commit e5895e0cef
4 changed files with 47 additions and 51 deletions

View File

@ -133,7 +133,7 @@ var et2_description = /** @class */ (function (_super) {
* @returns {Array|Array.getMedia.mediaContent} * @returns {Array|Array.getMedia.mediaContent}
*/ */
et2_description.prototype.getMedia = function (_value) { et2_description.prototype.getMedia = function (_value) {
var base_url = egw.webserverUrl.match(/^\//, 'ig') ? egw(window).window.location.origin : ''; var base_url = egw.webserverUrl.match(new RegExp(/^\//, 'ig')) ? egw(window).window.location.origin : '';
var mediaContent = []; var mediaContent = [];
if (_value) { if (_value) {
mediaContent = [{ mediaContent = [{

View File

@ -15,10 +15,9 @@
*/ */
import './et2_core_common'; import './et2_core_common';
import { ClassWithAttributes } from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import { et2_widget, et2_createWidget, et2_register_widget, WidgetConfig } from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import { et2_DOMWidget } from './et2_core_DOMWidget' import {et2_baseWidget} from './et2_core_baseWidget'
import { et2_baseWidget } from './et2_core_baseWidget'
import './et2_types'; import './et2_types';
/** /**
@ -252,7 +251,7 @@ export class et2_description extends et2_baseWidget implements et2_IDetachedDOM
*/ */
getMedia(_value) getMedia(_value)
{ {
var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin :''; var base_url = egw.webserverUrl.match(new RegExp(/^\//,'ig'))?egw(window).window.location.origin :'';
var mediaContent = []; var mediaContent = [];
if (_value) if (_value)
{ {

View File

@ -116,8 +116,6 @@ var et2_historylog = /** @class */ (function (_super) {
if (this.options.status_id === this.id) { if (this.options.status_id === this.id) {
this.egw().debug("warn", "status_id attribute should not be the same as historylog ID"); this.egw().debug("warn", "status_id attribute should not be the same as historylog ID");
} }
var _columns = typeof this.options.columns === "string" ?
this.options.columns.split(',') : this.options.columns;
// Create the dynheight component which dynamically scales the inner // Create the dynheight component which dynamically scales the inner
// container. // container.
this.div.parentsUntil('.et2_tabs').height('100%'); this.div.parentsUntil('.et2_tabs').height('100%');
@ -141,7 +139,8 @@ var et2_historylog = /** @class */ (function (_super) {
// Create widgets for columns that stay the same, and set up varying widgets // Create widgets for columns that stay the same, and set up varying widgets
this.createWidgets(); this.createWidgets();
// Create the gridview controller // Create the gridview controller
var linkCallback = function () { }; var linkCallback = function () {
};
this.controller = new et2_dataview_controller_1.et2_dataview_controller(null, this.dataview.grid); this.controller = new et2_dataview_controller_1.et2_dataview_controller(null, this.dataview.grid);
this.controller.setContext(this); this.controller.setContext(this);
this.controller.setDataProvider(this); this.controller.setDataProvider(this);
@ -193,8 +192,6 @@ var et2_historylog = /** @class */ (function (_super) {
for (var key in this.fields) { for (var key in this.fields) {
this.fields[key].widget.destroy(); this.fields[key].widget.destroy();
} }
if (this.diff)
this.diff.widget.destroy();
// Free the grid components // Free the grid components
if (this.dataview) if (this.dataview)
this.dataview.destroy(); this.dataview.destroy();
@ -275,6 +272,7 @@ var et2_historylog = /** @class */ (function (_super) {
// Save to use for each row // Save to use for each row
var nodes_1 = widget._children.length ? [] : jQuery(widget.getDetachedNodes()); var nodes_1 = widget._children.length ? [] : jQuery(widget.getDetachedNodes());
for (var i_2 = 0; i_2 < widget._children.length; i_2++) { for (var i_2 = 0; i_2 < widget._children.length; i_2++) {
// @ts-ignore
nodes_1.push(jQuery(widget._children[i_2].getDetachedNodes())); nodes_1.push(jQuery(widget._children[i_2].getDetachedNodes()));
} }
this.fields[key] = { this.fields[key] = {
@ -437,6 +435,7 @@ var et2_historylog = /** @class */ (function (_super) {
nodes = self.fields[_data.status].nodes.clone(); nodes = self.fields[_data.status].nodes.clone();
} }
for (var j = 0; j < widget._children.length; j++) { for (var j = 0; j < widget._children.length; j++) {
// @ts-ignore
nodes.push(self.fields[_data.status].nodes[j].clone()); nodes.push(self.fields[_data.status].nodes[j].clone());
if (widget._children[j].instanceOf(et2_widget_diff_1.et2_diff)) { if (widget._children[j].instanceOf(et2_widget_diff_1.et2_diff)) {
self._spanValueColumns(jQuery(this)); self._spanValueColumns(jQuery(this));

View File

@ -118,26 +118,22 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
if(tab) if(tab)
{ {
// Bind the action to when the tab is selected // Bind the action to when the tab is selected
var handler = function(e) { const handler = function (e) {
e.data.div.unbind("click.history"); e.data.div.unbind("click.history");
// Bind on click tap, because we need to update history size // Bind on click tap, because we need to update history size
// after a rezise happend and history log was not the active tab // after a rezise happend and history log was not the active tab
e.data.div.bind("click.history",{"history": e.data.history, div: tab.flagDiv}, function(e){ e.data.div.bind("click.history", {"history": e.data.history, div: tab.flagDiv}, function (e) {
if(e.data.history && e.data.history.dynheight) if (e.data.history && e.data.history.dynheight) {
{ e.data.history.dynheight.update(function (_w, _h) {
e.data.history.dynheight.update(function(_w, _h)
{
e.data.history.dataview.resize(_w, _h); e.data.history.dataview.resize(_w, _h);
}); });
} }
}); });
if (typeof e.data.history.dataview == "undefined") if (typeof e.data.history.dataview == "undefined") {
{
e.data.history.finishInit(); e.data.history.finishInit();
if(e.data.history.dynheight) if (e.data.history.dynheight) {
{ e.data.history.dynheight.update(function (_w, _h) {
e.data.history.dynheight.update(function(_w, _h) {
e.data.history.dataview.resize(_w, _h); e.data.history.dataview.resize(_w, _h);
}); });
} }
@ -184,21 +180,19 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
{ {
this.egw().debug("warn", "status_id attribute should not be the same as historylog ID"); this.egw().debug("warn", "status_id attribute should not be the same as historylog ID");
} }
var _columns = typeof this.options.columns === "string" ?
this.options.columns.split(',') : this.options.columns;
// Create the dynheight component which dynamically scales the inner // Create the dynheight component which dynamically scales the inner
// container. // container.
this.div.parentsUntil('.et2_tabs').height('100%'); this.div.parentsUntil('.et2_tabs').height('100%');
var parent = this.get_tab_info(); const parent = this.get_tab_info();
this.dynheight = new et2_dynheight(parent ? parent.contentDiv : this.div.parent(), this.dynheight = new et2_dynheight(parent ? parent.contentDiv : this.div.parent(),
this.innerDiv, 250 this.innerDiv, 250
); );
// Create the outer grid container // Create the outer grid container
this.dataview = new et2_dataview(this.innerDiv, this.egw()); this.dataview = new et2_dataview(this.innerDiv, this.egw());
var dataview_columns = []; const dataview_columns = [];
var _columns = typeof this.options.columns === "string" ? let _columns = typeof this.options.columns === "string" ?
this.options.columns.split(',') : this.options.columns; this.options.columns.split(',') : this.options.columns;
for (var i = 0; i < et2_historylog.columns.length; i++) for (var i = 0; i < et2_historylog.columns.length; i++)
{ {
@ -216,7 +210,9 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
this.createWidgets(); this.createWidgets();
// Create the gridview controller // Create the gridview controller
var linkCallback = function() {}; const linkCallback = function ()
{
};
this.controller = new et2_dataview_controller(null, this.dataview.grid); this.controller = new et2_dataview_controller(null, this.dataview.grid);
this.controller.setContext(this); this.controller.setContext(this);
this.controller.setDataProvider(this); this.controller.setDataProvider(this);
@ -224,7 +220,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
this.controller.setRowCallback(this.rowCallback); this.controller.setRowCallback(this.rowCallback);
this.controller.setActionObjectManager(null); this.controller.setActionObjectManager(null);
var total = typeof this.options.value.total !== "undefined" ? const total = typeof this.options.value.total !== "undefined" ?
this.options.value.total : 0; this.options.value.total : 0;
// This triggers an invalidate, which updates the grid // This triggers an invalidate, which updates the grid
@ -256,8 +252,9 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
} }
// Register a resize callback // Register a resize callback
var self = this; const self = this;
jQuery(window).on('resize.' +this.options.value.app + this.options.value.id, function() { jQuery(window).on('resize.' +this.options.value.app + this.options.value.id, function()
{
if (self && typeof self.dynheight != 'undefined') self.dynheight.update(function(_w, _h) { if (self && typeof self.dynheight != 'undefined') self.dynheight.update(function(_w, _h) {
self.dataview.resize(_w, _h); self.dataview.resize(_w, _h);
}); });
@ -276,15 +273,14 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
} }
// Free the widgets // Free the widgets
for(var i = 0; i < et2_historylog.columns.length; i++) for(let i = 0; i < et2_historylog.columns.length; i++)
{ {
if(et2_historylog.columns[i].widget) et2_historylog.columns[i].widget.destroy(); if(et2_historylog.columns[i].widget) et2_historylog.columns[i].widget.destroy();
} }
for(var key in this.fields) for(let key in this.fields)
{ {
this.fields[key].widget.destroy(); this.fields[key].widget.destroy();
} }
if(this.diff) this.diff.widget.destroy();
// Free the grid components // Free the grid components
if(this.dataview) this.dataview.destroy(); if(this.dataview) this.dataview.destroy();
@ -373,9 +369,9 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
for(var key in this.options.value['status-widgets']) for(var key in this.options.value['status-widgets'])
{ {
let attrs = jQuery.extend({'readonly': true, 'id': key}, this.getArrayMgr('modifications').getEntry(key)); let attrs = jQuery.extend({'readonly': true, 'id': key}, this.getArrayMgr('modifications').getEntry(key));
var field = attrs.type || this.options.value['status-widgets'][key]; const field = attrs.type || this.options.value['status-widgets'][key];
var options = null; const options = null;
var widget = this._create_widget(key, field, attrs, options); const widget = this._create_widget(key, field, attrs, options);
if(widget === null) if(widget === null)
{ {
continue; continue;
@ -387,6 +383,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
let nodes = widget._children.length ? [] : jQuery(widget.getDetachedNodes()); let nodes = widget._children.length ? [] : jQuery(widget.getDetachedNodes());
for(let i = 0; i < widget._children.length; i++) for(let i = 0; i < widget._children.length; i++)
{ {
// @ts-ignore
nodes.push(jQuery(widget._children[i].getDetachedNodes())); nodes.push(jQuery(widget._children[i].getDetachedNodes()));
} }
this.fields[key] = { this.fields[key] = {
@ -406,14 +403,14 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
_create_widget(key, field, attrs, options) _create_widget(key, field, attrs, options)
{ {
var widget = null; let widget = null;
// If field has multiple parts (is object) and isn't an obvious select box // If field has multiple parts (is object) and isn't an obvious select box
if(typeof field === 'object') if(typeof field === 'object')
{ {
// Check for multi-part statuses needing multiple widgets // Check for multi-part statuses needing multiple widgets
var need_box = false;//!this.getArrayMgr('sel_options').getEntry(key); let need_box = false;//!this.getArrayMgr('sel_options').getEntry(key);
for(var j in field) for(let j in field)
{ {
// Require widget to be a widget, to avoid invalid widgets // Require widget to be a widget, to avoid invalid widgets
// (and template, which is a widget and an infolog todo status) // (and template, which is a widget and an infolog todo status)
@ -430,8 +427,8 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
widget = et2_createWidget('vbox', attrs, this); widget = et2_createWidget('vbox', attrs, this);
for(var i in field) for(var i in field)
{ {
var type = field[i]; let type = field[i];
var child_attrs = jQuery.extend({}, attrs); const child_attrs = jQuery.extend({}, attrs);
if(typeof type === 'object') if(typeof type === 'object')
{ {
child_attrs['select_options'] = field[i]; child_attrs['select_options'] = field[i];
@ -442,7 +439,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
delete child_attrs['select_options']; delete child_attrs['select_options'];
} }
child_attrs.id = i; child_attrs.id = i;
var child = this._create_widget(i, type, child_attrs, options); const child = this._create_widget(i, type, child_attrs, options);
widget.addChild(child); widget.addChild(child);
child.transformAttributes(child_attrs); child.transformAttributes(child_attrs);
} }
@ -473,14 +470,14 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
// Parse / set legacy options // Parse / set legacy options
if(options) if(options)
{ {
var mgr = this.getArrayMgr("content"); const mgr = this.getArrayMgr("content");
for(let i = 0; i < options.length && i < widget.legacyOptions.length; i++) for(let i = 0; i < options.length && i < widget.legacyOptions.length; i++)
{ {
// Not set // Not set
if(options[i] === "") continue; if(options[i] === "") continue;
var attr = widget.attributes[widget.legacyOptions[i]]; const attr = widget.attributes[widget.legacyOptions[i]];
var attrValue = options[i]; let attrValue = options[i];
// If the attribute is marked as boolean, parse the // If the attribute is marked as boolean, parse the
// expression as bool expression. // expression as bool expression.
@ -533,7 +530,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
if ( this.options.value['num_rows'] ) if ( this.options.value['num_rows'] )
_queriedRange['num_rows'] = this.options.value['num_rows']; _queriedRange['num_rows'] = this.options.value['num_rows'];
var historylog = this; const historylog = this;
// Pass the fetch call to the API // Pass the fetch call to the API
this.egw().dataFetch( this.egw().dataFetch(
this.getInstanceManager().etemplate_exec_id, this.getInstanceManager().etemplate_exec_id,
@ -608,6 +605,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
} }
for(var j = 0; j < widget._children.length; j++) for(var j = 0; j < widget._children.length; j++)
{ {
// @ts-ignore
nodes.push(self.fields[_data.status].nodes[j].clone()); nodes.push(self.fields[_data.status].nodes[j].clone());
if(widget._children[j].instanceOf(et2_diff)) if(widget._children[j].instanceOf(et2_diff))
{ {
@ -655,11 +653,11 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
if(widget._children.length) if(widget._children.length)
{ {
// Multi-part values // Multi-part values
var box = jQuery(widget.getDOMNode()).clone(); const box = jQuery(widget.getDOMNode()).clone();
for(var j = 0; j < widget._children.length; j++) for(var j = 0; j < widget._children.length; j++)
{ {
var id = widget._children[j].id; const id = widget._children[j].id;
var widget_value = value ? value[id] || "" : ""; const widget_value = value ? value[id] || "" : "";
widget._children[j].setDetachedAttributes(nodes[j], {value:widget_value}); widget._children[j].setDetachedAttributes(nodes[j], {value:widget_value});
box.append(nodes[j]); box.append(nodes[j]);
} }
@ -740,7 +738,7 @@ export class et2_historylog extends et2_valueWidget implements et2_IDataProvider
// Resize diff widgets to match new space // Resize diff widgets to match new space
if(this.dataview) if(this.dataview)
{ {
var columns = this.dataview.getColumnMgr(); const columns = this.dataview.getColumnMgr();
jQuery('.et2_diff', this.div).closest('.innerContainer') jQuery('.et2_diff', this.div).closest('.innerContainer')
.width(columns.getColumnWidth(et2_historylog.NEW_VALUE) + columns.getColumnWidth(et2_historylog.OLD_VALUE)); .width(columns.getColumnWidth(et2_historylog.NEW_VALUE) + columns.getColumnWidth(et2_historylog.OLD_VALUE));
} }