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

View File

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

View File

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

View File

@ -57,7 +57,10 @@ namespace OS {
set(v: GenericObject<any>) {
for (let k in v) {
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
$("button",bt).trigger("click");
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