fix old system dialog is not destroyed after closed

This commit is contained in:
Xuan Sang LE 2020-05-29 23:34:35 +02:00
parent 1c32f2010c
commit ced3777d30
5 changed files with 17 additions and 6 deletions

View File

@ -35,7 +35,7 @@ namespace OS {
*/ */
export abstract class SubWindow extends BaseModel { export abstract class SubWindow extends BaseModel {
modal: false; modal: false;
parent: BaseModel; parent: BaseModel | typeof GUI;
/** /**
*Creates an instance of SubWindow. *Creates an instance of SubWindow.
@ -91,8 +91,9 @@ namespace OS {
* @memberof SubWindow * @memberof SubWindow
*/ */
meta(): API.PackageMetaType { meta(): API.PackageMetaType {
if (this.parent && this.parent.meta) { const p = this.parent as BaseModel;
return this.parent.meta(); if (p && p.meta) {
return p.meta();
} }
} }

View File

@ -165,7 +165,7 @@ namespace OS {
dialog = d as GUI.BaseDialog; dialog = d as GUI.BaseDialog;
} }
dialog.parent = undefined; dialog.parent = GUI;
dialog.handle = resolve; dialog.handle = resolve;
dialog.pid = -1; dialog.pid = -1;
dialog.data = data; dialog.data = data;

View File

@ -60,7 +60,6 @@ namespace OS {
} }
protected mount() { protected mount() {
this._onbtclick = (e) => {};
$(this.refs.button).click((e) => { $(this.refs.button).click((e) => {
const evt: TagEventType = { const evt: TagEventType = {
id: this.aid, id: this.aid,
@ -76,6 +75,7 @@ namespace OS {
protected init(): void { protected init(): void {
this.enable = true; this.enable = true;
this.toggle = false; this.toggle = false;
this._onbtclick = (e) => {};
} }
protected calibrate(): void {} protected calibrate(): void {}
reload(d?: any): void {} reload(d?: any): void {}

View File

@ -57,7 +57,10 @@ namespace OS {
set(v: GenericObject<any>) { set(v: GenericObject<any>) {
for (let k in v) { for (let k in v) {
let descriptor = this.descriptor_of(k); let descriptor = this.descriptor_of(k);
if (descriptor && descriptor.set) this[k] = v[k]; if (descriptor && descriptor.set)
{
this[k] = v[k];
}
} }
} }

View File

@ -95,6 +95,13 @@ test("Test button tag behavior", () =>{
bt.onbtclick = cb bt.onbtclick = cb
$("button",bt).trigger("click"); $("button",bt).trigger("click");
expect(cb).toBeCalledTimes(1); expect(cb).toBeCalledTimes(1);
const data = {
text: "name",
onbtclick: jest.fn()
};
bt.set(data);
$("button",bt).trigger("click");
expect(data.onbtclick).toBeCalledTimes(1);
}); });
// Label test // Label test