-
Notifications
You must be signed in to change notification settings - Fork 68
JsWidgets: add simple tab box #342
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
base: releases/25.2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,192 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2010, 2025 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 { | ||||||
| Action, CheckBoxField, Event, Form, FormModel, GroupBox, InitModelOf, Menu, MessageBoxes, models, PropertyChangeEvent, scout, SimpleTabAreaDisplayStyle, SimpleTabAreaPosition, SimpleTabBox, SimpleTabBoxViewActivateEvent, SimpleTabView, | ||||||
| SmartField, Status, StatusSeverity, StringField | ||||||
| } from '@eclipse-scout/core'; | ||||||
| import SimpleTabBoxFormModel from './SimpleTabBoxFormModel'; | ||||||
| import {SimpleTabBoxFormWidgetMap} from '../index'; | ||||||
|
|
||||||
| export class SimpleTabBoxForm extends Form { | ||||||
| declare widgetMap: SimpleTabBoxFormWidgetMap; | ||||||
|
|
||||||
| simpleTabBox: SimpleTabBox; | ||||||
| addTabMenu: Menu; | ||||||
| deleteTabMenu: Menu; | ||||||
|
|
||||||
| simpleTabAreaPropertiesBox: GroupBox; | ||||||
| displayStyleField: SmartField<SimpleTabAreaDisplayStyle>; | ||||||
| positionField: SmartField<SimpleTabAreaPosition>; | ||||||
|
|
||||||
| simpleTabPropertiesBox: GroupBox; | ||||||
| titleField: StringField; | ||||||
| subTitleField: StringField; | ||||||
| iconIdField: SmartField<string>; | ||||||
| closableField: CheckBoxField; | ||||||
| statusField: SmartField<StatusSeverity>; | ||||||
|
|
||||||
| protected _tabCounter: number; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to separate the declaration and the initialization. As there is no difference in e.g. the
Suggested change
|
||||||
|
|
||||||
| constructor() { | ||||||
| super(); | ||||||
|
|
||||||
| this.simpleTabBox = null; | ||||||
| this.addTabMenu = null; | ||||||
| this.deleteTabMenu = null; | ||||||
|
|
||||||
| this.simpleTabAreaPropertiesBox = null; | ||||||
| this.displayStyleField = null; | ||||||
| this.positionField = null; | ||||||
|
|
||||||
| this.simpleTabPropertiesBox = null; | ||||||
| this.titleField = null; | ||||||
| this.subTitleField = null; | ||||||
| this.iconIdField = null; | ||||||
| this.closableField = null; | ||||||
| this.statusField = null; | ||||||
|
|
||||||
| this._tabCounter = 0; | ||||||
| } | ||||||
|
|
||||||
| protected override _jsonModel(): FormModel { | ||||||
| return models.get(SimpleTabBoxFormModel); | ||||||
| } | ||||||
|
|
||||||
| protected override _init(model: InitModelOf<this>) { | ||||||
| super._init(model); | ||||||
|
|
||||||
| this.simpleTabBox = this.widget('SimpleTabBox'); | ||||||
| this.simpleTabBox.on('viewActivate', this._onSimpleTabBoxViewActivate.bind(this)); | ||||||
|
|
||||||
| this.addTabMenu = this.widget('AddTabMenu'); | ||||||
| this.addTabMenu.on('action', this._onAddTabMenuAction.bind(this)); | ||||||
|
|
||||||
| this.deleteTabMenu = this.widget('DeleteTabMenu'); | ||||||
| this.deleteTabMenu.on('action', this._onDeleteTabMenuAction.bind(this)); | ||||||
|
|
||||||
| this.simpleTabAreaPropertiesBox = this.widget('SimpleTabAreaPropertiesBox'); | ||||||
|
|
||||||
| this.displayStyleField = this.widget('DisplayStyleField'); | ||||||
| this.displayStyleField.setValue(this.simpleTabBox.tabArea.displayStyle); | ||||||
| this.displayStyleField.on('propertyChange:value', this._onDisplayStyleFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.positionField = this.widget('PositionField'); | ||||||
| this.positionField.setValue(this.simpleTabBox.tabArea.position); | ||||||
| this.positionField.on('propertyChange:value', this._onPositionFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.simpleTabPropertiesBox = this.widget('SimpleTabPropertiesBox'); | ||||||
|
|
||||||
| this.titleField = this.widget('TitleField'); | ||||||
| this.titleField.on('propertyChange:value', this._onTitleFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.subTitleField = this.widget('SubTitleField'); | ||||||
| this.subTitleField.on('propertyChange:value', this._onSubTitleFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.iconIdField = this.widget('IconIdField'); | ||||||
| this.iconIdField.on('propertyChange:value', this._onIconIdFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.closableField = this.widget('ClosableField'); | ||||||
| this.closableField.on('propertyChange:value', this._onClosableFieldValueChange.bind(this)); | ||||||
|
|
||||||
| this.statusField = this.widget('StatusField'); | ||||||
| this.statusField.on('propertyChange:value', this._onStatusFieldValueChange.bind(this)); | ||||||
| } | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initialize action and event tab |
||||||
|
|
||||||
| protected _onSimpleTabBoxViewActivate(event: SimpleTabBoxViewActivateEvent) { | ||||||
| this._updateSimpleTabPropertyFields(); | ||||||
| } | ||||||
|
|
||||||
| protected _updateSimpleTabPropertyFields() { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
|
|
||||||
| this.titleField.setValue(activeTab?.title); | ||||||
| this.subTitleField.setValue(activeTab?.subTitle); | ||||||
| this.iconIdField.setValue(activeTab?.iconId); | ||||||
| this.closableField.setValue(activeTab?.closable); | ||||||
| this.statusField.setValue(activeTab?.status?.severity); | ||||||
| } | ||||||
|
|
||||||
| protected _onAddTabMenuAction(event: Event<Action>) { | ||||||
| this.simpleTabBox.addView(this._createSampleTabView()); | ||||||
| this.simpleTabPropertiesBox.setEnabled(true); | ||||||
| } | ||||||
|
|
||||||
| protected _createSampleTabView() { | ||||||
| const count = ++this._tabCounter; | ||||||
|
|
||||||
| return scout.create(SimpleTabBoxViewGroupBox, { | ||||||
| parent: this.simpleTabBox, | ||||||
| title: 'Tab ' + count | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| protected _onDeleteTabMenuAction(event: Event<Action>) { | ||||||
| this.simpleTabBox.removeView(this.simpleTabBox.currentView); | ||||||
|
|
||||||
| if (this.simpleTabBox.tabArea.getTabs().length === 0) { | ||||||
| this.simpleTabPropertiesBox.setEnabled(false); | ||||||
| this._updateSimpleTabPropertyFields(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| protected _onDisplayStyleFieldValueChange(event: PropertyChangeEvent<SimpleTabAreaDisplayStyle>) { | ||||||
| this.simpleTabBox.tabArea.setDisplayStyle(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onPositionFieldValueChange(event: PropertyChangeEvent<SimpleTabAreaPosition>) { | ||||||
| this.simpleTabBox.tabArea.setPosition(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onTitleFieldValueChange(event: PropertyChangeEvent<string>) { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
| activeTab?.setTitle(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onSubTitleFieldValueChange(event: PropertyChangeEvent<string>) { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
| activeTab?.setSubTitle(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onIconIdFieldValueChange(event: PropertyChangeEvent<string>) { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
| activeTab?.setIconId(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onClosableFieldValueChange(event: PropertyChangeEvent<boolean>) { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
| activeTab?.setClosable(event.newValue); | ||||||
| } | ||||||
|
|
||||||
| protected _onStatusFieldValueChange(event: PropertyChangeEvent<StatusSeverity>) { | ||||||
| const activeTab = this.simpleTabBox.controller.getTab(this.simpleTabBox.currentView); | ||||||
| activeTab.setStatus(scout.create(Status, { | ||||||
| severity: event.newValue, | ||||||
| message: 'some status message..' | ||||||
| })); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| export class SimpleTabBoxViewGroupBox extends GroupBox implements SimpleTabView { | ||||||
|
|
||||||
| protected override _attach() { | ||||||
| this.$parent.append(this.$container); | ||||||
| } | ||||||
|
|
||||||
| protected override _detach() { | ||||||
| this.$container.detach(); | ||||||
| } | ||||||
|
|
||||||
| abort() { | ||||||
| MessageBoxes.createOk(this) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you not remove the view? |
||||||
| .withBody(this.session.text('ThanksForClickingMe')) | ||||||
| .withYes(this.session.text('YoureWelcome')) | ||||||
| .buildAndOpen(); | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pages are ordered alphabetically and
Simple...comes afterSequence....