@sap-ux/preview-middleware 0.16.58 → 0.16.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/client/adp/controllers/AddFragment.controller.js +3 -2
  2. package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
  3. package/dist/client/adp/controllers/ControllerExtension.controller.js +3 -18
  4. package/dist/client/adp/controllers/ControllerExtension.controller.ts +2 -24
  5. package/dist/client/adp/init-dialogs.js +22 -7
  6. package/dist/client/adp/init-dialogs.ts +31 -8
  7. package/dist/client/adp/init.js +19 -40
  8. package/dist/client/adp/init.ts +17 -56
  9. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +70 -0
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +71 -0
  11. package/dist/client/adp/quick-actions/common/op-add-header-field.js +59 -0
  12. package/dist/client/adp/quick-actions/common/op-add-header-field.ts +71 -0
  13. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +261 -0
  14. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +305 -0
  15. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +67 -0
  16. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +84 -0
  17. package/dist/client/adp/quick-actions/fe-v2/registry.js +57 -0
  18. package/dist/client/adp/quick-actions/fe-v2/registry.ts +69 -0
  19. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +84 -0
  20. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +90 -0
  21. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +88 -0
  22. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +97 -0
  23. package/dist/client/adp/quick-actions/fe-v4/registry.js +51 -0
  24. package/dist/client/adp/quick-actions/fe-v4/registry.ts +58 -0
  25. package/dist/client/adp/quick-actions/fe-v4/utils.js +54 -0
  26. package/dist/client/adp/quick-actions/fe-v4/utils.ts +47 -0
  27. package/dist/client/adp/quick-actions/load.js +46 -0
  28. package/dist/client/adp/quick-actions/load.ts +23 -0
  29. package/dist/client/adp/utils.js +97 -1
  30. package/dist/client/adp/utils.ts +83 -0
  31. package/dist/client/cpe/changes/service.js +2 -2
  32. package/dist/client/cpe/changes/service.ts +2 -2
  33. package/dist/client/cpe/control-data.js +3 -3
  34. package/dist/client/cpe/control-data.ts +8 -7
  35. package/dist/client/cpe/init.js +14 -8
  36. package/dist/client/cpe/init.ts +25 -11
  37. package/dist/client/cpe/outline/{utils.js → editable.js} +3 -30
  38. package/dist/client/cpe/outline/{utils.ts → editable.ts} +1 -29
  39. package/dist/client/cpe/outline/nodes.js +27 -9
  40. package/dist/client/cpe/outline/nodes.ts +33 -8
  41. package/dist/client/cpe/outline/service.js +60 -0
  42. package/dist/client/cpe/outline/service.ts +73 -0
  43. package/dist/client/cpe/quick-actions/quick-action-definition.js +6 -0
  44. package/dist/client/cpe/quick-actions/quick-action-definition.ts +115 -0
  45. package/dist/client/cpe/quick-actions/quick-action-service.js +101 -0
  46. package/dist/client/cpe/quick-actions/quick-action-service.ts +142 -0
  47. package/dist/client/cpe/quick-actions/registry.js +145 -0
  48. package/dist/client/cpe/quick-actions/registry.ts +156 -0
  49. package/dist/client/cpe/quick-actions/utils.js +94 -0
  50. package/dist/client/cpe/quick-actions/utils.ts +114 -0
  51. package/dist/client/cpe/rta-service.ts +1 -0
  52. package/dist/client/cpe/selection.js +3 -3
  53. package/dist/client/cpe/selection.ts +1 -1
  54. package/dist/client/cpe/types.ts +7 -3
  55. package/dist/client/cpe/ui5-utils.js +1 -17
  56. package/dist/client/cpe/ui5-utils.ts +0 -17
  57. package/dist/client/cpe/utils.js +50 -1
  58. package/dist/client/cpe/utils.ts +54 -0
  59. package/dist/client/i18n.js +43 -0
  60. package/dist/client/i18n.ts +34 -0
  61. package/dist/client/manifest.json +1 -1
  62. package/dist/client/messagebundle.properties +17 -0
  63. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +6 -1
  64. package/dist/client/utils/application.js +34 -0
  65. package/dist/client/utils/application.ts +27 -0
  66. package/dist/client/utils/core.js +70 -0
  67. package/dist/client/utils/core.ts +61 -0
  68. package/package.json +4 -4
  69. package/dist/client/cpe/outline/index.js +0 -40
  70. package/dist/client/cpe/outline/index.ts +0 -37
@@ -1,5 +1,14 @@
1
1
  import MessageToast from 'sap/m/MessageToast';
2
+ import Element from 'sap/ui/core/Element';
2
3
  import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
4
+ import type DTElement from 'sap/ui/dt/Element';
5
+ import type ManagedObject from 'sap/ui/base/ManagedObject';
6
+ import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
7
+ import Log from 'sap/base/Log';
8
+ import FlexUtils from 'sap/ui/fl/Utils';
9
+
10
+ import { getError } from '../utils/error';
11
+ import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../utils/version';
3
12
 
4
13
  export interface Deferred<T> {
5
14
  promise: Promise<T>;
@@ -63,3 +72,77 @@ export function notifyUser(message: string, duration: number = 5000) {
63
72
  duration
64
73
  });
65
74
  }
75
+
76
+ /**
77
+ * Check if element is sync view
78
+ *
79
+ * @param element Design time Element
80
+ * @returns boolean if element is sync view or not
81
+ */
82
+ function isSyncView(element: DTElement): boolean {
83
+ return element?.getMetadata()?.getName()?.includes('XMLView') && element?.oAsyncState === undefined;
84
+ }
85
+
86
+ /**
87
+ * Get Ids for all sync views
88
+ *
89
+ * @param ui5VersionInfo UI5 Version Information
90
+ *
91
+ * @returns array of Ids for application sync views
92
+ */
93
+ export async function getAllSyncViewsIds(ui5VersionInfo: Ui5VersionInfo): Promise<string[]> {
94
+ const syncViewIds: string[] = [];
95
+ try {
96
+ if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 120 })) {
97
+ const elements = Element.registry.filter(() => true) as DTElement[];
98
+ elements.forEach((ui5Element) => {
99
+ if (isSyncView(ui5Element)) {
100
+ syncViewIds.push(ui5Element.getId());
101
+ }
102
+ });
103
+ } else {
104
+ const ElementRegistry = (await import('sap/ui/core/ElementRegistry')).default;
105
+ const elements = ElementRegistry.all() as Record<string, DTElement>;
106
+ Object.entries(elements).forEach(([key, ui5Element]) => {
107
+ if (isSyncView(ui5Element)) {
108
+ syncViewIds.push(key);
109
+ }
110
+ });
111
+ }
112
+ } catch (error) {
113
+ Log.error('Could not get application sync views', getError(error));
114
+ }
115
+
116
+ return syncViewIds;
117
+ }
118
+
119
+ interface ControllerInfo {
120
+ controllerName: string;
121
+ viewId: string;
122
+ }
123
+
124
+ /**
125
+ * Gets controller name and view ID for the given UI5 control.
126
+ *
127
+ * @param control UI5 control.
128
+ * @returns The controller name and view ID.
129
+ */
130
+
131
+ export function getControllerInfoForControl(control: ManagedObject): ControllerInfo {
132
+ const view = FlexUtils.getViewForControl(control);
133
+ const controllerName = view.getController().getMetadata().getName();
134
+ const viewId = view.getId();
135
+ return { controllerName, viewId };
136
+ }
137
+
138
+ /**
139
+ * Gets controller name and view ID for the given overlay control.
140
+ *
141
+ * @param overlayControl The overlay control.
142
+ * @returns The controller name and view ID.
143
+ */
144
+
145
+ export function getControllerInfo(overlayControl: ElementOverlay): ControllerInfo {
146
+ const control = overlayControl.getElement();
147
+ return getControllerInfoForControl(control);
148
+ }
@@ -153,8 +153,8 @@ sap.ui.define([
153
153
  try {
154
154
  if (typeof command.getCommands === 'function') {
155
155
  const subCommands = command.getCommands();
156
- subCommands.forEach(command => {
157
- const pendingChange = this.prepareChangeType(command, inactiveCommandCount, i);
156
+ subCommands.forEach(subCommand => {
157
+ const pendingChange = this.prepareChangeType(subCommand, inactiveCommandCount, i);
158
158
  if (pendingChange) {
159
159
  activeChanges.push(pendingChange);
160
160
  }
@@ -265,8 +265,8 @@ export class ChangeService {
265
265
  try {
266
266
  if (typeof command.getCommands === 'function') {
267
267
  const subCommands = command.getCommands();
268
- subCommands.forEach((command) => {
269
- const pendingChange = this.prepareChangeType(command, inactiveCommandCount, i);
268
+ subCommands.forEach((subCommand) => {
269
+ const pendingChange = this.prepareChangeType(subCommand, inactiveCommandCount, i);
270
270
  if (pendingChange) {
271
271
  activeChanges.push(pendingChange);
272
272
  }
@@ -27,7 +27,7 @@ sap.ui.define([
27
27
  const analyzedType = {
28
28
  primitiveType: 'any',
29
29
  ui5Type: null,
30
- enumValues: null,
30
+ enumValues: undefined,
31
31
  isArray: false
32
32
  };
33
33
  const propertyType = property?.getType();
@@ -63,8 +63,8 @@ sap.ui.define([
63
63
  analyzedType.primitiveType = name;
64
64
  }
65
65
  analyzedType.ui5Type = typeName;
66
- if (analyzedType.primitiveType === 'enum') {
67
- analyzedType.enumValues = sap.ui.require(analyzedType.ui5Type.split('.').join('/'));
66
+ if (analyzedType.primitiveType === 'enum' && typeof propertyDataType?.getEnumValues === 'function') {
67
+ analyzedType.enumValues = propertyDataType.getEnumValues();
68
68
  }
69
69
  }
70
70
  return analyzedType;
@@ -18,9 +18,7 @@ import { UI5ControlProperty } from './types';
18
18
  import DataType from 'sap/ui/base/DataType';
19
19
 
20
20
  type AnalyzedType = Pick<UI5ControlProperty, 'isArray' | 'primitiveType' | 'ui5Type' | 'enumValues'>;
21
- interface Name {
22
- getName(): string;
23
- }
21
+
24
22
  /**
25
23
  * A property is disabled if it is an array or the type is 'any'
26
24
  * - since we currently don't have a good editor for it Otherwise, it is enabled.
@@ -73,7 +71,7 @@ function analyzePropertyType(property: ManagedObjectMetadataProperties): Analyze
73
71
  const analyzedType: AnalyzedType = {
74
72
  primitiveType: 'any',
75
73
  ui5Type: null,
76
- enumValues: null,
74
+ enumValues: undefined,
77
75
  isArray: false
78
76
  };
79
77
  const propertyType = property?.getType();
@@ -105,8 +103,11 @@ function analyzePropertyType(property: ManagedObjectMetadataProperties): Analyze
105
103
  if (propertyDataType && !(propertyDataType instanceof DataType)) {
106
104
  return analyzedType;
107
105
  }
106
+ // enum values are created differently and use DataType as prototype, which only has stubs for instance functions -> getName returns undefined
107
+ // array and base types also return undefined, but we have already handled those above
108
+ // https://github.com/SAP/openui5/blob/203ce22763a76e28b7a422f6c635a42480f733f1/src/sap.ui.core/src/sap/ui/base/DataType.js#L430
108
109
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
109
- const name = (Object.getPrototypeOf(propertyDataType) as Name).getName();
110
+ const name = (Object.getPrototypeOf(propertyDataType) as DataType).getName();
110
111
  if (!name) {
111
112
  analyzedType.primitiveType = 'enum';
112
113
  } else {
@@ -115,8 +116,8 @@ function analyzePropertyType(property: ManagedObjectMetadataProperties): Analyze
115
116
  analyzedType.ui5Type = typeName;
116
117
 
117
118
  // Determine base type for SAP types
118
- if (analyzedType.primitiveType === 'enum') {
119
- analyzedType.enumValues = sap.ui.require(analyzedType.ui5Type.split('.').join('/'));
119
+ if (analyzedType.primitiveType === 'enum' && typeof propertyDataType?.getEnumValues === 'function') {
120
+ analyzedType.enumValues = propertyDataType.getEnumValues();
120
121
  }
121
122
  }
122
123
 
@@ -1,23 +1,24 @@
1
1
  'use strict';
2
2
  sap.ui.define([
3
+ 'sap/base/Log',
3
4
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
4
- './outline/index',
5
+ './outline/service',
5
6
  './selection',
6
7
  './changes/service',
7
8
  './documentation',
8
- 'sap/base/Log',
9
9
  './logger',
10
10
  './ui5-utils',
11
11
  './connector-service',
12
12
  './rta-service',
13
- '../utils/error'
14
- ], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils, ___connector_service, ___rta_service, ___utils_error) {
13
+ '../utils/error',
14
+ './quick-actions/quick-action-service'
15
+ ], function (Log, ___sap_ux_private_control_property_editor_common, ___outline_service, ___selection, ___changes_service, ___documentation, ___logger, ___ui5_utils, ___connector_service, ___rta_service, ___utils_error, ___quick_actions_quick_action_service) {
15
16
  'use strict';
16
17
  const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
17
18
  const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
18
19
  const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
19
20
  const appLoaded = ___sap_ux_private_control_property_editor_common['appLoaded'];
20
- const initOutline = ___outline_index['initOutline'];
21
+ const OutlineService = ___outline_service['OutlineService'];
21
22
  const SelectionService = ___selection['SelectionService'];
22
23
  const ChangeService = ___changes_service['ChangeService'];
23
24
  const loadDefaultLibraries = ___documentation['loadDefaultLibraries'];
@@ -26,7 +27,9 @@ sap.ui.define([
26
27
  const WorkspaceConnectorService = ___connector_service['WorkspaceConnectorService'];
27
28
  const RtaService = ___rta_service['RtaService'];
28
29
  const getError = ___utils_error['getError'];
30
+ const QuickActionService = ___quick_actions_quick_action_service['QuickActionService'];
29
31
  function init(rta) {
32
+ let registries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
30
33
  Log.info('Initializing Control Property Editor');
31
34
  const flexSettings = rta.getFlexSettings();
32
35
  if (flexSettings.telemetry === true) {
@@ -40,11 +43,15 @@ sap.ui.define([
40
43
  const changesService = new ChangeService({ rta }, selectionService);
41
44
  const connectorService = new WorkspaceConnectorService();
42
45
  const rtaService = new RtaService(rta);
46
+ const outlineService = new OutlineService(rta);
47
+ const quickActionService = new QuickActionService(rta, outlineService, registries);
43
48
  const services = [
44
49
  selectionService,
45
50
  changesService,
46
51
  connectorService,
47
- rtaService
52
+ outlineService,
53
+ rtaService,
54
+ quickActionService
48
55
  ];
49
56
  try {
50
57
  loadDefaultLibraries();
@@ -58,9 +65,8 @@ sap.ui.define([
58
65
  }
59
66
  }, logger);
60
67
  for (const service of services) {
61
- service.init(sendAction, subscribe);
68
+ service.init(sendAction, subscribe)?.catch(reason => Log.error('Service Initalization Failed: ', getError(reason)));
62
69
  }
63
- initOutline(rta, sendAction).catch(error => Log.error('Error during initialization of Control Property Editor', getError(error)));
64
70
  const icons = getIcons();
65
71
  sendAction(iconsLoaded(icons));
66
72
  sendAction(appLoaded());
@@ -1,3 +1,6 @@
1
+ import Log from 'sap/base/Log';
2
+ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
3
+
1
4
  import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
2
5
  import {
3
6
  startPostMessageCommunication,
@@ -5,21 +8,24 @@ import {
5
8
  enableTelemetry,
6
9
  appLoaded
7
10
  } from '@sap-ux-private/control-property-editor-common';
8
- import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
9
11
 
10
12
  import type { ActionHandler, Service } from './types';
11
- import { initOutline } from './outline/index';
13
+ import { OutlineService } from './outline/service';
12
14
  import { SelectionService } from './selection';
13
15
  import { ChangeService } from './changes/service';
14
16
  import { loadDefaultLibraries } from './documentation';
15
- import Log from 'sap/base/Log';
16
17
  import { logger } from './logger';
17
18
  import { getIcons } from './ui5-utils';
18
19
  import { WorkspaceConnectorService } from './connector-service';
19
20
  import { RtaService } from './rta-service';
20
21
  import { getError } from '../utils/error';
22
+ import { QuickActionService } from './quick-actions/quick-action-service';
23
+ import type { QuickActionDefinitionRegistry } from './quick-actions/registry';
21
24
 
22
- export default function init(rta: RuntimeAuthoring): Promise<void> {
25
+ export default function init(
26
+ rta: RuntimeAuthoring,
27
+ registries: QuickActionDefinitionRegistry<string>[] = []
28
+ ): Promise<void> {
23
29
  Log.info('Initializing Control Property Editor');
24
30
 
25
31
  // enable telemetry if requested
@@ -42,7 +48,17 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
42
48
  const changesService = new ChangeService({ rta }, selectionService);
43
49
  const connectorService = new WorkspaceConnectorService();
44
50
  const rtaService = new RtaService(rta);
45
- const services: Service[] = [selectionService, changesService, connectorService, rtaService];
51
+ const outlineService = new OutlineService(rta);
52
+ const quickActionService = new QuickActionService(rta, outlineService, registries);
53
+ const services: Service[] = [
54
+ selectionService,
55
+ changesService,
56
+ connectorService,
57
+ outlineService,
58
+ rtaService,
59
+ quickActionService
60
+ ];
61
+
46
62
  try {
47
63
  loadDefaultLibraries();
48
64
  const { sendAction } = startPostMessageCommunication<ExternalAction>(
@@ -60,13 +76,11 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
60
76
  );
61
77
 
62
78
  for (const service of services) {
63
- service.init(sendAction, subscribe);
79
+ service
80
+ .init(sendAction, subscribe)
81
+ ?.catch((reason) => Log.error('Service Initalization Failed: ', getError(reason)));
64
82
  }
65
- // For initOutline to complete the RTA needs to already running (to access RTA provided services).
66
- // That can only happen if the plugin initialization has completed.
67
- initOutline(rta, sendAction).catch((error) =>
68
- Log.error('Error during initialization of Control Property Editor', getError(error))
69
- );
83
+
70
84
  const icons = getIcons();
71
85
 
72
86
  sendAction(iconsLoaded(icons));
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils", "sap/ui/core/Component", "../../utils/version"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils, Component, ____utils_version) {
3
+ sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../../utils/core"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ____utils_core) {
4
4
  "use strict";
5
5
 
6
6
  const buildControlData = ___control_data["buildControlData"];
7
7
  const getRuntimeControl = ___utils["getRuntimeControl"];
8
- const getComponent = ___ui5_utils["getComponent"];
9
- const isLowerThanMinimalUi5Version = ____utils_version["isLowerThanMinimalUi5Version"];
8
+ const getComponent = ____utils_core["getComponent"];
10
9
  const isEditable = function () {
11
10
  let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
12
11
  let editable = false;
@@ -31,36 +30,10 @@ sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/d
31
30
  }
32
31
  return editable;
33
32
  };
34
-
35
- /**
36
- * Function that checks if control is reuse component
37
- *
38
- * @param controlId id control
39
- * @param ui5VersionInfo UI5 version information
40
- * @returns boolean if control is from reused component view
41
- */
42
- const isReuseComponent = (controlId, ui5VersionInfo) => {
43
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
44
- major: 1,
45
- minor: 115
46
- })) {
47
- return false;
48
- }
49
- const component = Component.getComponentById(controlId);
50
- if (!component) {
51
- return false;
52
- }
53
- const manifest = component.getManifest();
54
- if (!manifest) {
55
- return false;
56
- }
57
- return manifest['sap.app']?.type === 'component';
58
- };
59
33
  var __exports = {
60
34
  __esModule: true
61
35
  };
62
36
  __exports.isEditable = isEditable;
63
- __exports.isReuseComponent = isReuseComponent;
64
37
  return __exports;
65
38
  });
66
- //# sourceMappingURL=utils.js.map
39
+ //# sourceMappingURL=editable.js.map
@@ -2,10 +2,7 @@ import { buildControlData } from '../control-data';
2
2
  import { getRuntimeControl } from '../utils';
3
3
  import OverlayUtil from 'sap/ui/dt/OverlayUtil';
4
4
  import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
5
- import { getComponent } from '../ui5-utils';
6
- import Component from 'sap/ui/core/Component';
7
- import { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
8
- import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../../utils/version';
5
+ import { getComponent } from '../../utils/core';
9
6
 
10
7
  export const isEditable = (id = ''): boolean => {
11
8
  let editable = false;
@@ -30,28 +27,3 @@ export const isEditable = (id = ''): boolean => {
30
27
  }
31
28
  return editable;
32
29
  };
33
-
34
- /**
35
- * Function that checks if control is reuse component
36
- *
37
- * @param controlId id control
38
- * @param ui5VersionInfo UI5 version information
39
- * @returns boolean if control is from reused component view
40
- */
41
- export const isReuseComponent = (controlId: string, ui5VersionInfo: Ui5VersionInfo): boolean => {
42
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 115 })) {
43
- return false;
44
- }
45
-
46
- const component = Component.getComponentById(controlId);
47
- if (!component) {
48
- return false;
49
- }
50
-
51
- const manifest = component.getManifest() as Manifest;
52
- if (!manifest) {
53
- return false;
54
- }
55
-
56
- return manifest['sap.app']?.type === 'component';
57
- };
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_version) {
3
+ sap.ui.define(["../../utils/version", "../../utils/core", "../utils", "./editable"], function (____utils_version, ____utils_core, ___utils, ___editable) {
4
4
  "use strict";
5
5
 
6
- const isEditable = ___utils["isEditable"];
7
- const isReuseComponent = ___utils["isReuseComponent"];
8
6
  const getUi5Version = ____utils_version["getUi5Version"];
7
+ const getControlById = ____utils_core["getControlById"];
8
+ const isReuseComponent = ___utils["isReuseComponent"];
9
+ const isEditable = ___editable["isEditable"];
9
10
  /**
10
11
  * Retrieves additional data for a given control ID.
11
12
  *
@@ -13,7 +14,7 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
13
14
  * @returns An object containing the text and the technical name of the control.
14
15
  */
15
16
  function getAdditionalData(id) {
16
- const control = sap.ui.getCore().byId(id);
17
+ const control = getControlById(id);
17
18
  if (!control) {
18
19
  return {};
19
20
  }
@@ -64,6 +65,20 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
64
65
  hasDefaultContent: false
65
66
  });
66
67
  }
68
+ /**
69
+ * Creates conrol index for all controls in the app.
70
+ *
71
+ * @param {ControlTreeIndex} controlIndex - Control index for the ui5 app.
72
+ * @param {OutlineNode} node - control node added to the outline.
73
+ */
74
+ function indexNode(controlIndex, node) {
75
+ const indexedControls = controlIndex[node.controlType];
76
+ if (indexedControls) {
77
+ indexedControls.push(node);
78
+ } else {
79
+ controlIndex[node.controlType] = [node];
80
+ }
81
+ }
67
82
 
68
83
  /**
69
84
  * Transform node.
@@ -71,9 +86,10 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
71
86
  * @param input outline view node
72
87
  * @param scenario type of project
73
88
  * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
74
- * @returns {Promise<OutlineNode[]>} transformed outline tree nodes
89
+ * @param controlIndex Control tree index
90
+ * @returns transformed outline tree nodes
75
91
  */
76
- async function transformNodes(input, scenario, reuseComponentsIds) {
92
+ async function transformNodes(input, scenario, reuseComponentsIds, controlIndex) {
77
93
  const stack = [...input];
78
94
  const items = [];
79
95
  const ui5VersionInfo = await getUi5Version();
@@ -88,7 +104,7 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
88
104
  text
89
105
  } = getAdditionalData(current.id);
90
106
  const technicalName = current.technicalName.split('.').slice(-1)[0];
91
- const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, reuseComponentsIds) : await transformNodes(children, scenario, reuseComponentsIds);
107
+ const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, reuseComponentsIds, controlIndex) : await transformNodes(children, scenario, reuseComponentsIds, controlIndex);
92
108
  const node = {
93
109
  controlId: current.id,
94
110
  controlType: current.technicalName,
@@ -97,6 +113,7 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
97
113
  visible: current.visible ?? true,
98
114
  children: transformedChildren
99
115
  };
116
+ indexNode(controlIndex, node);
100
117
  fillReuseComponents(reuseComponentsIds, current, scenario, ui5VersionInfo);
101
118
  items.push(node);
102
119
  }
@@ -145,9 +162,10 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
145
162
  * @param children outline view node children
146
163
  * @param scenario type of project
147
164
  * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
165
+ * @param controlIndex Control tree index
148
166
  * @returns transformed outline tree nodes
149
167
  */
150
- async function handleDuplicateNodes(children, scenario, reuseComponentsIds) {
168
+ async function handleDuplicateNodes(children, scenario, reuseComponentsIds, controlIndex) {
151
169
  const extPointIDs = new Set();
152
170
  children.forEach(child => {
153
171
  if (child.type === 'extensionPoint') {
@@ -159,7 +177,7 @@ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_
159
177
  }
160
178
  });
161
179
  const uniqueChildren = children.filter(child => !extPointIDs.has(child.id));
162
- return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
180
+ return transformNodes(uniqueChildren, scenario, reuseComponentsIds, controlIndex);
163
181
  }
164
182
  var __exports = {
165
183
  __esModule: true
@@ -1,8 +1,14 @@
1
1
  import type { OutlineNode } from '@sap-ux-private/control-property-editor-common';
2
2
  import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
3
3
  import type { Scenario } from 'sap/ui/fl/Scenario';
4
- import { isEditable, isReuseComponent } from './utils';
4
+
5
5
  import { getUi5Version, Ui5VersionInfo } from '../../utils/version';
6
+ import { getControlById } from '../../utils/core';
7
+
8
+ import type { ControlTreeIndex } from '../types';
9
+ import { isReuseComponent } from '../utils';
10
+
11
+ import { isEditable } from './editable';
6
12
 
7
13
  interface AdditionalData {
8
14
  text?: string;
@@ -16,7 +22,7 @@ interface AdditionalData {
16
22
  * @returns An object containing the text and the technical name of the control.
17
23
  */
18
24
  function getAdditionalData(id: string): AdditionalData {
19
- const control = sap.ui.getCore().byId(id);
25
+ const control = getControlById(id);
20
26
  if (!control) {
21
27
  return {};
22
28
  }
@@ -71,6 +77,20 @@ function addChildToExtensionPoint(id: string, children: OutlineNode[]) {
71
77
  hasDefaultContent: false
72
78
  });
73
79
  }
80
+ /**
81
+ * Creates conrol index for all controls in the app.
82
+ *
83
+ * @param {ControlTreeIndex} controlIndex - Control index for the ui5 app.
84
+ * @param {OutlineNode} node - control node added to the outline.
85
+ */
86
+ function indexNode(controlIndex: ControlTreeIndex, node: OutlineNode): void {
87
+ const indexedControls = controlIndex[node.controlType];
88
+ if (indexedControls) {
89
+ indexedControls.push(node);
90
+ } else {
91
+ controlIndex[node.controlType] = [node];
92
+ }
93
+ }
74
94
 
75
95
  /**
76
96
  * Transform node.
@@ -78,12 +98,14 @@ function addChildToExtensionPoint(id: string, children: OutlineNode[]) {
78
98
  * @param input outline view node
79
99
  * @param scenario type of project
80
100
  * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
81
- * @returns {Promise<OutlineNode[]>} transformed outline tree nodes
101
+ * @param controlIndex Control tree index
102
+ * @returns transformed outline tree nodes
82
103
  */
83
104
  export async function transformNodes(
84
105
  input: OutlineViewNode[],
85
106
  scenario: Scenario,
86
- reuseComponentsIds: Set<string>
107
+ reuseComponentsIds: Set<string>,
108
+ controlIndex: ControlTreeIndex
87
109
  ): Promise<OutlineNode[]> {
88
110
  const stack = [...input];
89
111
  const items: OutlineNode[] = [];
@@ -100,8 +122,8 @@ export async function transformNodes(
100
122
  const technicalName = current.technicalName.split('.').slice(-1)[0];
101
123
 
102
124
  const transformedChildren = isAdp
103
- ? await handleDuplicateNodes(children, scenario, reuseComponentsIds)
104
- : await transformNodes(children, scenario, reuseComponentsIds);
125
+ ? await handleDuplicateNodes(children, scenario, reuseComponentsIds, controlIndex)
126
+ : await transformNodes(children, scenario, reuseComponentsIds, controlIndex);
105
127
 
106
128
  const node: OutlineNode = {
107
129
  controlId: current.id,
@@ -112,6 +134,7 @@ export async function transformNodes(
112
134
  children: transformedChildren
113
135
  };
114
136
 
137
+ indexNode(controlIndex, node);
115
138
  fillReuseComponents(reuseComponentsIds, current, scenario, ui5VersionInfo);
116
139
 
117
140
  items.push(node);
@@ -167,12 +190,14 @@ function fillReuseComponents(
167
190
  * @param children outline view node children
168
191
  * @param scenario type of project
169
192
  * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
193
+ * @param controlIndex Control tree index
170
194
  * @returns transformed outline tree nodes
171
195
  */
172
196
  export async function handleDuplicateNodes(
173
197
  children: OutlineViewNode[],
174
198
  scenario: Scenario,
175
- reuseComponentsIds: Set<string>
199
+ reuseComponentsIds: Set<string>,
200
+ controlIndex: ControlTreeIndex
176
201
  ): Promise<OutlineNode[]> {
177
202
  const extPointIDs = new Set<string>();
178
203
 
@@ -185,5 +210,5 @@ export async function handleDuplicateNodes(
185
210
 
186
211
  const uniqueChildren = children.filter((child) => !extPointIDs.has(child.id));
187
212
 
188
- return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
213
+ return transformNodes(uniqueChildren, scenario, reuseComponentsIds, controlIndex);
189
214
  }