Fix favourites (& probably some more inherited stuff) broken by TypeScript conversion

Note that any properties declared in a sub-class aren't generally available until after the super() call is done, i.e. in the super constructor they're undefined.
This commit is contained in:
nathangray 2020-03-20 11:38:38 -06:00
parent 7631eb83aa
commit 34ec346821
16 changed files with 58 additions and 71 deletions

View File

@ -43,11 +43,8 @@ var AddressbookApp = /** @class */ (function (_super) {
* @memberOf app.addressbook * @memberOf app.addressbook
*/ */
function AddressbookApp() { function AddressbookApp() {
var _this =
// call parent // call parent
_super.call(this) || this; return _super.call(this, 'addressbook') || this;
_this.appname = 'addressbook';
return _this;
} }
/** /**
* Destructor * Destructor

View File

@ -17,7 +17,7 @@ import 'jqueryui';
import '../jsapi/egw_global'; import '../jsapi/egw_global';
import '../etemplate/et2_types'; import '../etemplate/et2_types';
import { EgwApp } from '../../api/js/jsapi/egw_app'; import {EgwApp} from '../../api/js/jsapi/egw_app';
/** /**
* UI for Addressbook * UI for Addressbook
@ -26,8 +26,6 @@ import { EgwApp } from '../../api/js/jsapi/egw_app';
*/ */
class AddressbookApp extends EgwApp class AddressbookApp extends EgwApp
{ {
readonly appname = 'addressbook';
/** /**
* Constructor * Constructor
* *
@ -36,7 +34,7 @@ class AddressbookApp extends EgwApp
constructor() constructor()
{ {
// call parent // call parent
super(); super('addressbook');
} }
/** /**

View File

@ -45,8 +45,7 @@ var AdminApp = /** @class */ (function (_super) {
function AdminApp() { function AdminApp() {
var _this = var _this =
// call parent // call parent
_super.call(this) || this; _super.call(this, 'admin') || this;
_this.appname = 'admin';
/** /**
* reference to iframe * reference to iframe
* *

View File

@ -17,7 +17,7 @@ import 'jqueryui';
import '../jsapi/egw_global'; import '../jsapi/egw_global';
import '../etemplate/et2_types'; import '../etemplate/et2_types';
import { EgwApp } from '../../api/js/jsapi/egw_app'; import {EgwApp} from '../../api/js/jsapi/egw_app';
/** /**
* UI for Admin * UI for Admin
@ -29,7 +29,6 @@ class AdminApp extends EgwApp
* @lends app.classes.admin * @lends app.classes.admin
*/ */
{ {
readonly appname = 'admin';
/** /**
* reference to iframe * reference to iframe
@ -67,7 +66,7 @@ class AdminApp extends EgwApp
constructor() constructor()
{ {
// call parent // call parent
super(); super('admin');
} }
/** /**

View File

@ -50,11 +50,12 @@ var EgwApp = /** @class */ (function () {
* Initialization and setup goes here, but the etemplate2 object * Initialization and setup goes here, but the etemplate2 object
* is not yet ready. * is not yet ready.
*/ */
function EgwApp() { function EgwApp(appname) {
/** /**
* Mailvelope "egroupware" Keyring * Mailvelope "egroupware" Keyring
*/ */
this.mailvelope_keyring = undefined; this.mailvelope_keyring = undefined;
this.appname = appname;
this.egw = egw(this.appname, window); this.egw = egw(this.appname, window);
// Initialize sidebox for non-popups. // Initialize sidebox for non-popups.
// ID set server side // ID set server side

View File

@ -124,15 +124,16 @@ export abstract class EgwApp
* Initialization and setup goes here, but the etemplate2 object * Initialization and setup goes here, but the etemplate2 object
* is not yet ready. * is not yet ready.
*/ */
constructor() constructor(appname: string)
{ {
this.appname = appname;
this.egw = egw(this.appname, window); this.egw = egw(this.appname, window);
// Initialize sidebox for non-popups. // Initialize sidebox for non-popups.
// ID set server side // ID set server side
if(!this.egw.is_popup()) if(!this.egw.is_popup())
{ {
var sidebox = jQuery('#favorite_sidebox_'+this.appname); var sidebox = jQuery('#favorite_sidebox_' + this.appname);
if(sidebox.length == 0 && egw_getFramework() != null) if(sidebox.length == 0 && egw_getFramework() != null)
{ {
var egw_fw = egw_getFramework(); var egw_fw = egw_getFramework();

View File

@ -96,11 +96,7 @@ var CalendarApp = /** @class */ (function (_super) {
} }
*/ */
// call parent // call parent
_super.call(this) || this; _super.call(this, 'calendar') || this;
/**
* application name
*/
_this.appname = 'calendar';
/** /**
* Needed for JSON callback * Needed for JSON callback
*/ */

View File

@ -55,10 +55,6 @@ import {et2_calendar_event} from "./et2_widget_event";
*/ */
class CalendarApp extends EgwApp class CalendarApp extends EgwApp
{ {
/**
* application name
*/
public readonly appname = 'calendar';
/** /**
* Needed for JSON callback * Needed for JSON callback
@ -161,14 +157,14 @@ class CalendarApp extends EgwApp
} }
*/ */
// call parent // call parent
super(); super('calendar');
// Scroll // Scroll
jQuery(jQuery.proxy(this._scroll,this)); jQuery(jQuery.proxy(this._scroll, this));
jQuery.extend(this.state, this.egw.preference('saved_states','calendar')); jQuery.extend(this.state, this.egw.preference('saved_states', 'calendar'));
// Set custom color for events without category // Set custom color for events without category
if(this.egw.preference('no_category_custom_color','calendar')) if(this.egw.preference('no_category_custom_color', 'calendar'))
{ {
this.egw.css( this.egw.css(
'.calendar_calEvent:not([class*="cat_"])', '.calendar_calEvent:not([class*="cat_"])',

View File

@ -39,7 +39,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
function filemanagerAPP() { function filemanagerAPP() {
var _this = var _this =
// call parent // call parent
_super.call(this) || this; _super.call(this, 'filemanager') || this;
/** /**
* path widget, by template * path widget, by template
*/ */
@ -302,7 +302,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
*/ */
filemanagerAPP.prototype._upload_callback = function (_data) { filemanagerAPP.prototype._upload_callback = function (_data) {
if (_data.msg || _data.uploaded) if (_data.msg || _data.uploaded)
window.egw_refresh(_data.msg, filemanagerAPP.appname); window.egw_refresh(_data.msg, this.appname);
var that = this; var that = this;
for (var file in _data.uploaded) { for (var file in _data.uploaded) {
if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) { if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) {
@ -513,7 +513,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
* @param _data * @param _data
*/ */
filemanagerAPP.prototype._do_action_callback = function (_data) { filemanagerAPP.prototype._do_action_callback = function (_data) {
window.egw_refresh(_data.msg, filemanagerAPP.appname); window.egw_refresh(_data.msg, this.appname);
}; };
/** /**
* Force download of a file by appending '?download' to it's download url * Force download of a file by appending '?download' to it's download url
@ -724,7 +724,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
(dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 || !dir) (dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 || !dir)
}); });
// Last 10 folders // Last 10 folders
var previous_dsts = jQuery.extend([], egw.preference('drop_history', filemanagerAPP.appname)); var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname));
var action_index = 0; var action_index = 0;
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var path = i < previous_dsts.length ? previous_dsts[i] : ''; var path = i < previous_dsts.length ? previous_dsts[i] : '';
@ -806,10 +806,10 @@ var filemanagerAPP = /** @class */ (function (_super) {
} }
} }
// Remember the target for next time // Remember the target for next time
var previous_dsts = jQuery.extend([], egw.preference('drop_history', filemanagerAPP.appname)); var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname));
previous_dsts.unshift(dst); previous_dsts.unshift(dst);
previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9); previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9);
egw.set_preference(filemanagerAPP.appname, 'drop_history', previous_dsts); egw.set_preference(this.appname, 'drop_history', previous_dsts);
// Actual action id will be something like file_drop_{move|copy|link}[_other_id], // Actual action id will be something like file_drop_{move|copy|link}[_other_id],
// but we need to send move, copy or link // but we need to send move, copy or link
var action_id = _action.id.replace("file_drop_", '').split('_', 1)[0]; var action_id = _action.id.replace("file_drop_", '').split('_', 1)[0];
@ -976,7 +976,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
*/ */
filemanagerAPP.prototype._share_link_callback = function (_data) { filemanagerAPP.prototype._share_link_callback = function (_data) {
if (_data.msg || _data.share_link) if (_data.msg || _data.share_link)
window.egw_refresh(_data.msg, filemanagerAPP.appname); window.egw_refresh(_data.msg, this.appname);
console.log("_data", _data); console.log("_data", _data);
var app = this; var app = this;
var copy_link_to_clipboard = function (evt) { var copy_link_to_clipboard = function (evt) {
@ -1101,7 +1101,6 @@ var filemanagerAPP = /** @class */ (function (_super) {
} }
return true; return true;
}; };
filemanagerAPP.appname = 'filemanager';
return filemanagerAPP; return filemanagerAPP;
}(egw_app_1.EgwApp)); }(egw_app_1.EgwApp));
exports.filemanagerAPP = filemanagerAPP; exports.filemanagerAPP = filemanagerAPP;

View File

@ -19,7 +19,6 @@ import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch";
*/ */
export class filemanagerAPP extends EgwApp export class filemanagerAPP extends EgwApp
{ {
static readonly appname = 'filemanager';
/** /**
* path widget, by template * path widget, by template
*/ */
@ -44,12 +43,12 @@ export class filemanagerAPP extends EgwApp
constructor() constructor()
{ {
// call parent // call parent
super(); super('filemanager');
// Loading filemanager in its tab and home causes us problems with // Loading filemanager in its tab and home causes us problems with
// unwanted destruction, so we check for already existing path widgets // unwanted destruction, so we check for already existing path widgets
let lists = etemplate2.getByApplication('home'); let lists = etemplate2.getByApplication('home');
for(let i = 0; i < lists.length; i++) for (let i = 0; i < lists.length; i++)
{ {
if(lists[i].app == 'filemanager' && lists[i].widgetContainer.getWidgetById('path')) if(lists[i].app == 'filemanager' && lists[i].widgetContainer.getWidgetById('path'))
{ {
@ -356,7 +355,7 @@ export class filemanagerAPP extends EgwApp
*/ */
_upload_callback(_data) _upload_callback(_data)
{ {
if(_data.msg || _data.uploaded) window.egw_refresh(_data.msg, filemanagerAPP.appname); if(_data.msg || _data.uploaded) window.egw_refresh(_data.msg, this.appname);
let that = this; let that = this;
for (let file in _data.uploaded) for (let file in _data.uploaded)
@ -364,7 +363,13 @@ export class filemanagerAPP extends EgwApp
if(_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) if(_data.uploaded[file].confirm && !_data.uploaded[file].confirmed)
{ {
let buttons = [ let buttons = [
{text: this.egw.lang("Yes"), id: "overwrite", class: "ui-priority-primary", "default": true, image: 'check'}, {
text: this.egw.lang("Yes"),
id: "overwrite",
class: "ui-priority-primary",
"default": true,
image: 'check'
},
{text: this.egw.lang("Rename"), id: "rename", image: 'edit'}, {text: this.egw.lang("Rename"), id: "rename", image: 'edit'},
{text: this.egw.lang("Cancel"), id: "cancel"} {text: this.egw.lang("Cancel"), id: "cancel"}
]; ];
@ -615,7 +620,7 @@ export class filemanagerAPP extends EgwApp
*/ */
_do_action_callback(_data) _do_action_callback(_data)
{ {
window.egw_refresh(_data.msg, filemanagerAPP.appname); window.egw_refresh(_data.msg, this.appname);
} }
/** /**
@ -877,7 +882,7 @@ export class filemanagerAPP extends EgwApp
}); });
// Last 10 folders // Last 10 folders
let previous_dsts = jQuery.extend([], <any><unknown>egw.preference('drop_history', filemanagerAPP.appname)); let previous_dsts = jQuery.extend([], <any><unknown>egw.preference('drop_history', this.appname));
let action_index = 0; let action_index = 0;
for (let i = 0; i < 10; i++) for (let i = 0; i < 10; i++)
{ {
@ -977,10 +982,10 @@ export class filemanagerAPP extends EgwApp
} }
// Remember the target for next time // Remember the target for next time
let previous_dsts = jQuery.extend([], egw.preference('drop_history', filemanagerAPP.appname)); let previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname));
previous_dsts.unshift(dst); previous_dsts.unshift(dst);
previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9); previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9);
egw.set_preference(filemanagerAPP.appname, 'drop_history', previous_dsts); egw.set_preference(this.appname, 'drop_history', previous_dsts);
// Actual action id will be something like file_drop_{move|copy|link}[_other_id], // Actual action id will be something like file_drop_{move|copy|link}[_other_id],
// but we need to send move, copy or link // but we need to send move, copy or link
@ -1183,7 +1188,7 @@ export class filemanagerAPP extends EgwApp
*/ */
_share_link_callback(_data) _share_link_callback(_data)
{ {
if(_data.msg || _data.share_link) window.egw_refresh(_data.msg, filemanagerAPP.appname); if(_data.msg || _data.share_link) window.egw_refresh(_data.msg, this.appname);
console.log("_data", _data); console.log("_data", _data);
let app = this; let app = this;

View File

@ -43,11 +43,8 @@ var InfologApp = /** @class */ (function (_super) {
* @memberOf app.infolog * @memberOf app.infolog
*/ */
function InfologApp() { function InfologApp() {
var _this =
// call parent // call parent
_super.call(this) || this; return _super.call(this, 'infolog') || this;
_this.appname = 'infolog';
return _this;
} }
/** /**
* Destructor * Destructor

View File

@ -17,7 +17,7 @@ import 'jqueryui';
import '../jsapi/egw_global'; import '../jsapi/egw_global';
import '../etemplate/et2_types'; import '../etemplate/et2_types';
import { EgwApp } from '../../api/js/jsapi/egw_app'; import {EgwApp} from '../../api/js/jsapi/egw_app';
/** /**
* UI for Infolog * UI for Infolog
@ -26,7 +26,6 @@ import { EgwApp } from '../../api/js/jsapi/egw_app';
*/ */
class InfologApp extends EgwApp class InfologApp extends EgwApp
{ {
readonly appname = 'infolog';
/** /**
* Constructor * Constructor
@ -36,7 +35,7 @@ class InfologApp extends EgwApp
constructor() constructor()
{ {
// call parent // call parent
super(); super('infolog');
} }
/** /**

View File

@ -33,7 +33,7 @@ var resourcesApp = /** @class */ (function (_super) {
* Constructor * Constructor
*/ */
function resourcesApp() { function resourcesApp() {
return _super.call(this) || this; return _super.call(this, 'resources') || this;
} }
/** /**
* Destructor * Destructor
@ -137,7 +137,6 @@ var resourcesApp = /** @class */ (function (_super) {
rBtn.set_value('own_src'); rBtn.set_value('own_src');
} }
}; };
resourcesApp.appname = 'resources';
return resourcesApp; return resourcesApp;
}(egw_app_1.EgwApp)); }(egw_app_1.EgwApp));
app.classes.resources = resourcesApp; app.classes.resources = resourcesApp;

View File

@ -16,14 +16,13 @@ import {EgwApp} from "../../api/js/jsapi/egw_app";
*/ */
class resourcesApp extends EgwApp class resourcesApp extends EgwApp
{ {
static readonly appname: string = 'resources';
/** /**
* Constructor * Constructor
*/ */
constructor() constructor()
{ {
super(); super('resources');
} }
/** /**

View File

@ -38,9 +38,7 @@ var egw_app_1 = require("../../api/js/jsapi/egw_app");
var TimesheetApp = /** @class */ (function (_super) { var TimesheetApp = /** @class */ (function (_super) {
__extends(TimesheetApp, _super); __extends(TimesheetApp, _super);
function TimesheetApp() { function TimesheetApp() {
var _this = _super !== null && _super.apply(this, arguments) || this; return _super.call(this, 'timesheet') || this;
_this.appname = 'timesheet';
return _this;
} }
/** /**
* This function is called when the etemplate2 object is loaded * This function is called when the etemplate2 object is loaded

View File

@ -17,7 +17,7 @@ import 'jqueryui';
import '../jsapi/egw_global'; import '../jsapi/egw_global';
import '../etemplate/et2_types'; import '../etemplate/et2_types';
import { EgwApp } from '../../api/js/jsapi/egw_app'; import {EgwApp} from '../../api/js/jsapi/egw_app';
/** /**
* UI for timesheet * UI for timesheet
@ -26,7 +26,11 @@ import { EgwApp } from '../../api/js/jsapi/egw_app';
*/ */
class TimesheetApp extends EgwApp class TimesheetApp extends EgwApp
{ {
readonly appname = 'timesheet';
constructor()
{
super('timesheet');
}
/** /**
* This function is called when the etemplate2 object is loaded * This function is called when the etemplate2 object is loaded
@ -36,7 +40,7 @@ class TimesheetApp extends EgwApp
* @param et2 etemplate2 Newly ready object * @param et2 etemplate2 Newly ready object
* @param string name * @param string name
*/ */
et2_ready(et2, name : string) et2_ready(et2, name: string)
{ {
// call parent // call parent
super.et2_ready(et2, name); super.et2_ready(et2, name);