From 8dd03e3d076ea8d4abeaac8af63bd04703db7cb6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 9 Feb 2020 12:27:39 +0100 Subject: [PATCH] some fixes on the TS interface of client-side api and TS conversation tool --- api/js/jsapi/egw_app.js | 6 ++---- api/js/jsapi/egw_app.ts | 5 +---- api/js/jsapi/egw_global.d.ts | 15 +++++++++++---- doc/js2ts.php | 6 ++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/api/js/jsapi/egw_app.js b/api/js/jsapi/egw_app.js index f62a6b8141..0dcc3abe67 100644 --- a/api/js/jsapi/egw_app.js +++ b/api/js/jsapi/egw_app.js @@ -44,9 +44,6 @@ require("../etemplate/et2_types"); * // Underscore private by convention * } * }); - * - * @class AppJS - * @augments Class */ var EgwApp = /** @class */ (function () { /** @@ -263,6 +260,7 @@ var EgwApp = /** @class */ (function () { * @return {boolean} false - Returns false to stop event propagation */ EgwApp.prototype.setState = function (state, template) { + var _a; // State should be an object, not a string, but we'll parse if (typeof state == "string") { if (state.indexOf('{') != -1 || state == 'null') { @@ -310,7 +308,7 @@ var EgwApp = /** @class */ (function () { url = egw.link('/index.php', jQuery.extend({ 'favorite': safe_name }, egw.link_get_registry(this.appname, 'list'))); } // if no list try index value from application - else if (egw.app(this.appname).index) { + else if ((_a = egw.app(this.appname)) === null || _a === void 0 ? void 0 : _a.index) { url = egw.link('/index.php', 'menuaction=' + egw.app(this.appname).index + '&favorite=' + safe_name); } egw.open_link(url, undefined, undefined, this.appname); diff --git a/api/js/jsapi/egw_app.ts b/api/js/jsapi/egw_app.ts index 7cb502e02e..8579e9501d 100644 --- a/api/js/jsapi/egw_app.ts +++ b/api/js/jsapi/egw_app.ts @@ -57,9 +57,6 @@ export interface PushData * // Underscore private by convention * } * }); - * - * @class AppJS - * @augments Class */ export abstract class EgwApp { @@ -367,7 +364,7 @@ export abstract class EgwApp * @param {string} template template name to check, instead of trying all templates of current app * @return {boolean} false - Returns false to stop event propagation */ - setState(state, template) + setState(state, template? : string) { // State should be an object, not a string, but we'll parse if(typeof state == "string") diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index 4997937b26..7f087024db 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -45,7 +45,7 @@ declare interface Iapplication */ declare interface IegwData { - timestamp: number; + timestamp?: number; data: {[key:string]: any}; } @@ -344,7 +344,7 @@ declare interface IegwGlobal * if string is used ambersands in vars have to be already urlencoded as '%26', function ensures they get NOT double encoded * @return {string} generated url */ - link(_url : string, _extravars : string|object) : string; + link(_url : string, _extravars? : string|object) : string; /** * Query a title of _app/_id * @@ -771,7 +771,7 @@ declare interface IegwWndLocal extends IegwGlobal * @param {object} _context * @param {string} _prefix prefix for _jsFiles */ - includeJS(_jsFiles : string|string[], _callback : Function, _context : object, _prefix? : string); + includeJS(_jsFiles : string|string[], _callback : Function, _context? : object, _prefix? : string); /** * Check if file is already included and optional mark it as included if not yet included * @@ -1209,4 +1209,11 @@ declare function egwIsMobile() : string|null; declare var mailvelope : any; declare function egw_refresh(_msg : string, app : string, id? : string|number, _type?, targetapp?, replace?, _with?, msgtype?); -declare function egw_open(); \ No newline at end of file +declare function egw_open(); + +declare function egw_getWindowLeft() : number; +declare function egw_getWindowTop() : number; +declare function egw_getWindowInnerWidth() : number; +declare function egw_getWindowInnerHeight() : number; +declare function egw_getWindowOuterWidth() : number; +declare function egw_getWindowOuterHeight() : number; diff --git a/doc/js2ts.php b/doc/js2ts.php index 1c6de7e3b3..55a9d3faca 100755 --- a/doc/js2ts.php +++ b/doc/js2ts.php @@ -24,7 +24,7 @@ $replace = array( ]); }, "/^\tappname:\s*'([^']+)',/m" => "\treadonly appname = '$1';", - "/^\t([^: ,;(]+):\s*([^()]+),/m" => "\t\$1: $2;", + "/^\t([^: ,;(\t]+?):\s*([^()]+?),/m" => "\t\$1 : any = $2;", "/^\t([^:\n]+):\s*function\s*\(.*this._super.(apply|call)\(/msU" => function($matches) { return str_replace('this._super', @@ -33,8 +33,10 @@ $replace = array( "/^\t([^:\n]+):\s*function\s*\(/m" => function($matches) { return "\t".($matches[1] === 'init' ? 'constructor' : $matches[1]).'('; }, + // TS does not like to call parent constructor with super.apply(this, arguments) and we dont have arguments ... + '/\tsuper.apply\(this, *arguments\)/' => "\tsuper()", "/^\t},$/m" => "\t}", - '/^ \* @version \$Id\$\n/m' => '', + '/^ \* @version \$Id[^$]*\$\n/m' => '', '#^ \* @link http://www.egroupware.org#m' => ' * @link: https://www.egroupware.org', );