/** sap.m */ import type Button from 'sap/m/Button'; import type Dialog from 'sap/m/Dialog'; import type ComboBox from 'sap/m/ComboBox'; /** sap.ui.core */ import type UI5Element from 'sap/ui/core/Element'; /** sap.ui.base */ import type Event from 'sap/ui/base/Event'; /** sap.ui.model */ import JSONModel from 'sap/ui/model/json/JSONModel'; /** sap.ui.rta */ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring'; /** sap.suite.ui.generic */ import type AppComponentV2 from 'sap/suite/ui/generic/template/lib/AppComponent'; import { getResourceModel } from '../../i18n.js'; import CommandExecutor from '../command-executor.js'; import BaseDialog from './BaseDialog.controller.js'; import CommandFactory from 'sap/ui/rta/command/CommandFactory'; import { CommunicationService } from '../../cpe/communication-service.js'; import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common'; import { generateRoutePattern } from '../quick-actions/fe-v4/utils.js'; import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition.js'; import { PageDescriptorV4 } from './types.js'; type SubpageType = 'ObjectPage' | 'CustomPage'; export interface PageDescriptorV2 { appType: 'fe-v2'; appComponent: AppComponentV2; entitySet: string; pageType: string; } export interface AddSubpageOptions { appReference: string; title: string; navProperties: { navProperty: string; entitySet: string }[]; pageDescriptor: PageDescriptorV2 | PageDescriptorV4; } export type AddSubpageModel = JSONModel & { getProperty(sPath: '/title'): string; getProperty(sPath: '/navigationData'): { navProperty: string; entitySet: string }[]; getProperty(sPath: '/selectedPageType/key'): SubpageType; getProperty(sPath: '/selectedNavigation/key'): string; }; /** * @namespace open.ux.preview.client.adp.controllers */ export default class AddSubpage extends BaseDialog { constructor( name: string, overlays: UI5Element, rta: RuntimeAuthoring, readonly options: AddSubpageOptions, telemetryData?: QuickActionTelemetryData ) { super(name, telemetryData); this.rta = rta; this.overlays = overlays; this.model = new JSONModel({ title: options.title, navigationData: options.navProperties }); this.commandExecutor = new CommandExecutor(this.rta); } /** * Setups the Dialog and the JSON Model * * @param {Dialog} dialog - Dialog instance */ async setup(dialog: Dialog): Promise { this.dialog = dialog; this.setEscapeHandler(); this.buildDialogData(); const resourceModel = await getResourceModel('open.ux.preview.client'); this.dialog.setModel(resourceModel, 'i18n'); this.dialog.setModel(this.model); this.dialog.open(); } onPageTypeChange() { // TODO: to be supported in future releases } onNavigationChange(event: Event) { const source = event.getSource(); const selectedKey = source.getSelectedKey(); this.model.setProperty('/selectedNavigation/key', selectedKey); } /** * Handles create button press * * @param event Event */ async onCreateBtnPress(event: Event) { const source = event.getSource