Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page: remove destroyed detail form and table from page #982

Open
wants to merge 1 commit into
base: releases/24.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions eclipse-scout-core/src/desktop/outline/pages/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ export class Page extends TreeNode implements PageModel {
super._destroy();
if (this.detailTable) {
this.detailTable.destroy();
this.detailTable = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ist this necessary? Shouldn't this be done by the destroy handler?

}
if (this.detailForm) {
this.detailForm.destroy();
this.detailForm = null;
}
this.trigger('destroy');
}
Expand Down Expand Up @@ -433,6 +435,11 @@ export class Page extends TreeNode implements PageModel {
}
this.detailForm = form;
if (form) {
form.one('destroy', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the listener when the form changes, see FormMenu or FormTableControl

if (this.detailForm === form) {
this.detailForm = null;
}
});
this._initDetailForm(form);
}
this.triggerPropertyChange('detailForm', oldDetailForm, form);
Expand All @@ -457,6 +464,11 @@ export class Page extends TreeNode implements PageModel {
}
this.detailTable = table;
if (table) {
table.one('destroy', () => {
if (this.detailTable === table) {
this.detailTable = null;
}
});
this._initDetailTable(table);
}
this.triggerPropertyChange('detailTable', oldDetailTable, table);
Expand Down
45 changes: 43 additions & 2 deletions eclipse-scout-core/test/desktop/outline/pages/PageSpec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
import {arrays, Form, GroupBox, Outline, Page, PageWithTable, scout, Table, Widget} from '../../../../src';
import {arrays, Form, GroupBox, Outline, Page, PageWithNodes, PageWithTable, scout, Table, Widget} from '../../../../src';
import {MenuSpecHelper, OutlineSpecHelper, TableSpecHelper} from '../../../../src/testing';
import {ChildModelOf} from '../../../../src/scout';

Expand Down Expand Up @@ -75,6 +75,47 @@ describe('Page', () => {
expect(newTable.destroyed).toBe(false);
});

it('detailTable and detailForm are destroyed when page is destroyed', () => {
session.desktop.setBenchVisible(true);
session.desktop.setOutline(outline);

let parentPage = scout.create(PageWithNodes, {
parent: outline,
childNodes: [
{
objectType: Page,
detailForm: {
objectType: Form,
rootGroupBox: {
objectType: GroupBox
}
},
detailFormVisible: true,
detailTable: {
objectType: Table
},
detailTableVisible: true
}
]
});
outline.insertNode(parentPage);
outline.expandNode(parentPage);
let page = parentPage.childNodes[0];
outline.selectNode(page);

expect(page.detailTable).toBeInstanceOf(Table);
expect(page.detailForm).toBeInstanceOf(Widget);
let detailTable = page.detailTable;
let detailForm = page.detailForm;

outline.deleteNode(page);
expect(page.destroyed).toBe(true);
expect(detailForm.destroyed).toBe(true);
expect(detailTable.destroyed).toBe(true);
expect(page.detailForm).toBe(null);
expect(page.detailTable).toBe(null);
});

it('detailTable and detailForm are enhanced with parent table page menus', () => {
const parentPage = createAndInsertPage({
objectType: Table,
Expand Down