@sap-ux/preview-middleware 0.16.57 → 0.16.59

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 (71) 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/tsconfig.tsbuildinfo +1 -0
  65. package/dist/client/utils/application.js +34 -0
  66. package/dist/client/utils/application.ts +27 -0
  67. package/dist/client/utils/core.js +70 -0
  68. package/dist/client/utils/core.ts +61 -0
  69. package/package.json +5 -5
  70. package/dist/client/cpe/outline/index.js +0 -40
  71. package/dist/client/cpe/outline/index.ts +0 -37
@@ -16,8 +16,9 @@ sap.ui.define(["sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../c
16
16
  * @namespace open.ux.preview.client.adp.controllers
17
17
  */
18
18
  const AddFragment = BaseDialog.extend("open.ux.preview.client.adp.controllers.AddFragment", {
19
- constructor: function _constructor(name, overlays, rta) {
19
+ constructor: function _constructor(name, overlays, rta, aggregation) {
20
20
  BaseDialog.prototype.constructor.call(this, name);
21
+ this.aggregation = aggregation;
21
22
  this.rta = rta;
22
23
  this.overlays = overlays;
23
24
  this.model = new JSONModel();
@@ -120,7 +121,7 @@ sap.ui.define(["sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../c
120
121
  }
121
122
  return false;
122
123
  });
123
- const defaultAggregation = controlMetadata.getDefaultAggregationName();
124
+ const defaultAggregation = this.aggregation ?? controlMetadata.getDefaultAggregationName();
124
125
  const selectedControlName = controlMetadata.getName();
125
126
  let selectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation));
126
127
  selectedControlChildren = selectedControlChildren.map(key => {
@@ -44,7 +44,7 @@ type AddFragmentModel = JSONModel & {
44
44
  * @namespace open.ux.preview.client.adp.controllers
45
45
  */
46
46
  export default class AddFragment extends BaseDialog<AddFragmentModel> {
47
- constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring) {
47
+ constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring, private aggregation?: string) {
48
48
  super(name);
49
49
  this.rta = rta;
50
50
  this.overlays = overlays;
@@ -181,7 +181,7 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
181
181
  }
182
182
  return false;
183
183
  });
184
- const defaultAggregation = controlMetadata.getDefaultAggregationName();
184
+ const defaultAggregation = this.aggregation ?? controlMetadata.getDefaultAggregationName();
185
185
  const selectedControlName = controlMetadata.getName();
186
186
 
187
187
  let selectedControlChildren: string[] | number[] = Object.keys(
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/JSONModel", "sap/ui/fl/Utils", "../api-handler", "./BaseDialog.controller"], function (MessageToast, sap_ui_core_library, JSONModel, Utils, ___api_handler, __BaseDialog) {
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (MessageToast, sap_ui_core_library, JSONModel, ___api_handler, __BaseDialog, ___utils) {
4
4
  "use strict";
5
5
 
6
6
  function _interopRequireDefault(obj) {
@@ -15,6 +15,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
15
15
  const writeChange = ___api_handler["writeChange"];
16
16
  const writeController = ___api_handler["writeController"];
17
17
  const BaseDialog = _interopRequireDefault(__BaseDialog);
18
+ const getControllerInfo = ___utils["getControllerInfo"];
18
19
  /**
19
20
  * @namespace open.ux.preview.client.adp.controllers
20
21
  */
@@ -102,7 +103,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
102
103
  const {
103
104
  controllerName,
104
105
  viewId
105
- } = this.getControllerInfo(overlayControl);
106
+ } = getControllerInfo(overlayControl);
106
107
  const existingController = await this.getExistingController(controllerName);
107
108
  if (existingController) {
108
109
  const {
@@ -119,22 +120,6 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
119
120
  }
120
121
  }
121
122
  },
122
- /**
123
- * Gets controller name and view ID for the given overlay control.
124
- *
125
- * @param overlayControl The overlay control.
126
- * @returns The controller name and view ID.
127
- */
128
- getControllerInfo: function _getControllerInfo(overlayControl) {
129
- const control = overlayControl.getElement();
130
- const view = Utils.getViewForControl(control);
131
- const controllerName = view.getController().getMetadata().getName();
132
- const viewId = view.getId();
133
- return {
134
- controllerName,
135
- viewId
136
- };
137
- },
138
123
  /**
139
124
  * Updates the model properties for an existing controller.
140
125
  *
@@ -17,9 +17,6 @@ import JSONModel from 'sap/ui/model/json/JSONModel';
17
17
  /** sap.ui.rta */
18
18
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
19
19
 
20
- /** sap.ui.fl */
21
- import Utils from 'sap/ui/fl/Utils';
22
-
23
20
  /** sap.ui.layout */
24
21
  import type SimpleForm from 'sap/ui/layout/form/SimpleForm';
25
22
 
@@ -35,16 +32,12 @@ import {
35
32
  writeController
36
33
  } from '../api-handler';
37
34
  import BaseDialog from './BaseDialog.controller';
35
+ import { getControllerInfo } from '../utils';
38
36
 
39
37
  interface ControllerExtensionService {
40
38
  add: (codeRef: string, viewId: string) => Promise<{ creation: string }>;
41
39
  }
42
40
 
43
- interface ControllerInfo {
44
- controllerName: string;
45
- viewId: string;
46
- }
47
-
48
41
  type ControllerModel = JSONModel & {
49
42
  getProperty(sPath: '/controllersList'): { controllerName: string }[];
50
43
  getProperty(sPath: '/controllerExists'): boolean;
@@ -164,7 +157,7 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
164
157
  const selectorId = this.overlays.getId();
165
158
  const overlayControl = sap.ui.getCore().byId(selectorId) as unknown as ElementOverlay;
166
159
 
167
- const { controllerName, viewId } = this.getControllerInfo(overlayControl);
160
+ const { controllerName, viewId } = getControllerInfo(overlayControl);
168
161
  const existingController = await this.getExistingController(controllerName);
169
162
 
170
163
  if (existingController) {
@@ -184,21 +177,6 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
184
177
  }
185
178
  }
186
179
  }
187
-
188
- /**
189
- * Gets controller name and view ID for the given overlay control.
190
- *
191
- * @param overlayControl The overlay control.
192
- * @returns The controller name and view ID.
193
- */
194
- private getControllerInfo(overlayControl: ElementOverlay): ControllerInfo {
195
- const control = overlayControl.getElement();
196
- const view = Utils.getViewForControl(control);
197
- const controllerName = view.getController().getMetadata().getName();
198
- const viewId = view.getId();
199
- return { controllerName, viewId };
200
- }
201
-
202
180
  /**
203
181
  * Updates the model properties for an existing controller.
204
182
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/outline/utils"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_outline_utils) {
3
+ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/utils"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_utils) {
4
4
  "use strict";
5
5
 
6
6
  function _interopRequireDefault(obj) {
@@ -9,13 +9,28 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
9
9
  const AddFragment = _interopRequireDefault(__AddFragment);
10
10
  const ControllerExtension = _interopRequireDefault(__ControllerExtension);
11
11
  const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
12
- const isReuseComponent = ___cpe_outline_utils["isReuseComponent"];
12
+ const isReuseComponent = ___cpe_utils["isReuseComponent"];
13
13
  var DialogNames = /*#__PURE__*/function (DialogNames) {
14
14
  DialogNames["ADD_FRAGMENT"] = "AddFragment";
15
15
  DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
16
16
  DialogNames["ADD_FRAGMENT_AT_EXTENSION_POINT"] = "ExtensionPoint";
17
17
  return DialogNames;
18
18
  }(DialogNames || {});
19
+ /**
20
+ * Handler for enablement of Extend With Controller context menu entry
21
+ *
22
+ * @param control UI5 control.
23
+ * @param syncViewsIds Runtime Authoring
24
+ * @param ui5VersionInfo UI5 version information
25
+ *
26
+ * @returns boolean whether menu item is enabled or not
27
+ */
28
+ function isControllerExtensionEnabledForControl(control, syncViewsIds, ui5VersionInfo) {
29
+ const clickedControlId = FlUtils.getViewForControl(control).getId();
30
+ const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
31
+ return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
32
+ }
33
+
19
34
  /**
20
35
  * Handler for enablement of Extend With Controller context menu entry
21
36
  *
@@ -29,9 +44,7 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
29
44
  if (overlays.length === 0 || overlays.length > 1) {
30
45
  return false;
31
46
  }
32
- const clickedControlId = FlUtils.getViewForControl(overlays[0].getElement()).getId();
33
- const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
34
- return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
47
+ return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo);
35
48
  };
36
49
 
37
50
  /**
@@ -79,12 +92,13 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
79
92
  * @param rta Runtime Authoring
80
93
  * @param dialogName Dialog name
81
94
  * @param extensionPointData Control ID
95
+ * @param aggregation Name of aggregation that should be selected when dialog is opened
82
96
  */
83
- async function handler(overlay, rta, dialogName, extensionPointData) {
97
+ async function handler(overlay, rta, dialogName, extensionPointData, aggregation) {
84
98
  let controller;
85
99
  switch (dialogName) {
86
100
  case DialogNames.ADD_FRAGMENT:
87
- controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
101
+ controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, aggregation);
88
102
  break;
89
103
  case DialogNames.CONTROLLER_EXTENSION:
90
104
  controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
@@ -130,6 +144,7 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
130
144
  __esModule: true
131
145
  };
132
146
  __exports.DialogNames = DialogNames;
147
+ __exports.isControllerExtensionEnabledForControl = isControllerExtensionEnabledForControl;
133
148
  __exports.isControllerExtensionEnabled = isControllerExtensionEnabled;
134
149
  __exports.isFragmentCommandEnabled = isFragmentCommandEnabled;
135
150
  __exports.getAddFragmentItemText = getAddFragmentItemText;
@@ -19,7 +19,7 @@ import ControllerExtension from './controllers/ControllerExtension.controller';
19
19
  import { ExtensionPointData } from './extension-point';
20
20
  import ExtensionPoint from './controllers/ExtensionPoint.controller';
21
21
  import ManagedObject from 'sap/ui/base/ManagedObject';
22
- import { isReuseComponent } from '../cpe/outline/utils';
22
+ import { isReuseComponent } from '../cpe/utils';
23
23
  import { Ui5VersionInfo } from '../utils/version';
24
24
 
25
25
  export const enum DialogNames {
@@ -30,6 +30,26 @@ export const enum DialogNames {
30
30
 
31
31
  type Controller = AddFragment | ControllerExtension | ExtensionPoint;
32
32
 
33
+ /**
34
+ * Handler for enablement of Extend With Controller context menu entry
35
+ *
36
+ * @param control UI5 control.
37
+ * @param syncViewsIds Runtime Authoring
38
+ * @param ui5VersionInfo UI5 version information
39
+ *
40
+ * @returns boolean whether menu item is enabled or not
41
+ */
42
+ export function isControllerExtensionEnabledForControl(
43
+ control: ManagedObject,
44
+ syncViewsIds: string[],
45
+ ui5VersionInfo: Ui5VersionInfo
46
+ ): boolean {
47
+ const clickedControlId = FlUtils.getViewForControl(control).getId();
48
+ const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
49
+
50
+ return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
51
+ }
52
+
33
53
  /**
34
54
  * Handler for enablement of Extend With Controller context menu entry
35
55
  *
@@ -47,11 +67,7 @@ export const isControllerExtensionEnabled = (
47
67
  if (overlays.length === 0 || overlays.length > 1) {
48
68
  return false;
49
69
  }
50
-
51
- const clickedControlId = FlUtils.getViewForControl(overlays[0].getElement()).getId();
52
- const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
53
-
54
- return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
70
+ return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo);
55
71
  };
56
72
 
57
73
  /**
@@ -102,18 +118,25 @@ export const getAddFragmentItemText = (overlay: ElementOverlay) => {
102
118
  * @param rta Runtime Authoring
103
119
  * @param dialogName Dialog name
104
120
  * @param extensionPointData Control ID
121
+ * @param aggregation Name of aggregation that should be selected when dialog is opened
105
122
  */
106
123
  export async function handler(
107
124
  overlay: UI5Element,
108
125
  rta: RuntimeAuthoring,
109
126
  dialogName: DialogNames,
110
- extensionPointData?: ExtensionPointData
127
+ extensionPointData?: ExtensionPointData,
128
+ aggregation?: string
111
129
  ): Promise<void> {
112
130
  let controller: Controller;
113
131
 
114
132
  switch (dialogName) {
115
133
  case DialogNames.ADD_FRAGMENT:
116
- controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
134
+ controller = new AddFragment(
135
+ `open.ux.preview.client.adp.controllers.${dialogName}`,
136
+ overlay,
137
+ rta,
138
+ aggregation
139
+ );
117
140
  break;
118
141
  case DialogNames.CONTROLLER_EXTENSION:
119
142
  controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
@@ -1,12 +1,16 @@
1
1
  'use strict';
2
2
  sap.ui.define([
3
3
  'sap/base/Log',
4
- '../cpe/init',
5
- './init-dialogs',
6
4
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
7
5
  '../utils/error',
8
- '../utils/version'
9
- ], function (log, __init, ___init_dialogs, ___sap_ux_private_control_property_editor_common, ___utils_error, ___utils_version) {
6
+ '../utils/version',
7
+ '../cpe/init',
8
+ '../utils/application',
9
+ '../i18n',
10
+ './quick-actions/load',
11
+ './utils',
12
+ './init-dialogs'
13
+ ], function (log, ___sap_ux_private_control_property_editor_common, ___utils_error, ___utils_version, __init, ___utils_application, ___i18n, ___quick_actions_load, ___utils, ___init_dialogs) {
10
14
  'use strict';
11
15
  function _interopRequireDefault(obj) {
12
16
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
@@ -24,8 +28,6 @@ sap.ui.define([
24
28
  });
25
29
  });
26
30
  }
27
- const init = _interopRequireDefault(__init);
28
- const initDialogs = ___init_dialogs['initDialogs'];
29
31
  const showMessage = ___sap_ux_private_control_property_editor_common['showMessage'];
30
32
  const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
31
33
  const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
@@ -33,6 +35,12 @@ sap.ui.define([
33
35
  const getUi5Version = ___utils_version['getUi5Version'];
34
36
  const getUI5VersionValidationMessage = ___utils_version['getUI5VersionValidationMessage'];
35
37
  const isLowerThanMinimalUi5Version = ___utils_version['isLowerThanMinimalUi5Version'];
38
+ const init = _interopRequireDefault(__init);
39
+ const getApplicationType = ___utils_application['getApplicationType'];
40
+ const getTextBundle = ___i18n['getTextBundle'];
41
+ const loadDefinitions = ___quick_actions_load['loadDefinitions'];
42
+ const getAllSyncViewsIds = ___utils['getAllSyncViewsIds'];
43
+ const initDialogs = ___init_dialogs['initDialogs'];
36
44
  var __exports = async function (rta) {
37
45
  const flexSettings = rta.getFlexSettings();
38
46
  if (flexSettings.telemetry === true) {
@@ -62,7 +70,9 @@ sap.ui.define([
62
70
  const extPointService = new ExtensionPointService(rta);
63
71
  extPointService.init(subscribe);
64
72
  }
65
- await init(rta);
73
+ const applicationType = getApplicationType(rta.getRootControlInstance().getManifest());
74
+ const quickActionRegistries = await loadDefinitions(applicationType);
75
+ await init(rta, quickActionRegistries);
66
76
  if (isLowerThanMinimalUi5Version(ui5VersionInfo)) {
67
77
  sendAction(showMessage({
68
78
  message: getUI5VersionValidationMessage(ui5VersionInfo),
@@ -71,44 +81,13 @@ sap.ui.define([
71
81
  return;
72
82
  }
73
83
  if (syncViewsIds.length > 0) {
84
+ const bundle = await getTextBundle();
74
85
  sendAction(showMessage({
75
- message: 'Have in mind that synchronous views are detected for this application and controller extensions are not supported for such views. Controller extension functionality on these views will be disabled.',
86
+ message: bundle.getText('ADP_SYNC_VIEWS_MESSAGE'),
76
87
  shouldHideIframe: false
77
88
  }));
78
89
  }
79
90
  log.debug('ADP init executed.');
80
91
  };
81
- async function getAllSyncViewsIds(ui5VersionInfo) {
82
- const syncViewIds = [];
83
- try {
84
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
85
- major: 1,
86
- minor: 120
87
- })) {
88
- const Element = (await __ui5_require_async('sap/ui/core/Element')).default;
89
- const elements = Element.registry.filter(() => true);
90
- elements.forEach(ui5Element => {
91
- if (isSyncView(ui5Element)) {
92
- syncViewIds.push(ui5Element.getId());
93
- }
94
- });
95
- } else {
96
- const ElementRegistry = (await __ui5_require_async('sap/ui/core/ElementRegistry')).default;
97
- const elements = ElementRegistry.all();
98
- Object.entries(elements).forEach(_ref => {
99
- let [key, ui5Element] = _ref;
100
- if (isSyncView(ui5Element)) {
101
- syncViewIds.push(key);
102
- }
103
- });
104
- }
105
- } catch (error) {
106
- log.error('Could not get application sync views', getError(error));
107
- }
108
- return syncViewIds;
109
- }
110
- const isSyncView = element => {
111
- return element?.getMetadata()?.getName()?.includes('XMLView') && element?.oAsyncState === undefined;
112
- };
113
92
  return __exports;
114
93
  });
@@ -1,22 +1,24 @@
1
1
  import log from 'sap/base/Log';
2
2
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
3
- import init from '../cpe/init';
4
- import { initDialogs } from './init-dialogs';
3
+
5
4
  import {
6
5
  ExternalAction,
7
6
  showMessage,
8
7
  startPostMessageCommunication,
9
8
  enableTelemetry
10
9
  } from '@sap-ux-private/control-property-editor-common';
10
+
11
11
  import { ActionHandler } from '../cpe/types';
12
- import UI5Element from 'sap/ui/dt/Element';
13
12
  import { getError } from '../utils/error';
14
- import {
15
- getUi5Version,
16
- getUI5VersionValidationMessage,
17
- isLowerThanMinimalUi5Version,
18
- Ui5VersionInfo
19
- } from '../utils/version';
13
+ import { getUi5Version, getUI5VersionValidationMessage, isLowerThanMinimalUi5Version } from '../utils/version';
14
+
15
+ import init from '../cpe/init';
16
+ import { getApplicationType } from '../utils/application';
17
+ import { getTextBundle } from '../i18n';
18
+
19
+ import { loadDefinitions } from './quick-actions/load';
20
+ import { getAllSyncViewsIds } from './utils';
21
+ import { initDialogs } from './init-dialogs';
20
22
 
21
23
  export default async function (rta: RuntimeAuthoring) {
22
24
  const flexSettings = rta.getFlexSettings();
@@ -55,7 +57,10 @@ export default async function (rta: RuntimeAuthoring) {
55
57
  extPointService.init(subscribe);
56
58
  }
57
59
 
58
- await init(rta);
60
+ const applicationType = getApplicationType(rta.getRootControlInstance().getManifest());
61
+ const quickActionRegistries = await loadDefinitions(applicationType);
62
+
63
+ await init(rta, quickActionRegistries);
59
64
 
60
65
  if (isLowerThanMinimalUi5Version(ui5VersionInfo)) {
61
66
  sendAction(showMessage({ message: getUI5VersionValidationMessage(ui5VersionInfo), shouldHideIframe: true }));
@@ -63,10 +68,10 @@ export default async function (rta: RuntimeAuthoring) {
63
68
  }
64
69
 
65
70
  if (syncViewsIds.length > 0) {
71
+ const bundle = await getTextBundle();
66
72
  sendAction(
67
73
  showMessage({
68
- message:
69
- 'Have in mind that synchronous views are detected for this application and controller extensions are not supported for such views. Controller extension functionality on these views will be disabled.',
74
+ message: bundle.getText('ADP_SYNC_VIEWS_MESSAGE'),
70
75
  shouldHideIframe: false
71
76
  })
72
77
  );
@@ -74,47 +79,3 @@ export default async function (rta: RuntimeAuthoring) {
74
79
 
75
80
  log.debug('ADP init executed.');
76
81
  }
77
-
78
- /**
79
- * Get Ids for all sync views
80
- *
81
- * @param ui5VersionInfo UI5 Version Information
82
- *
83
- * @returns array of Ids for application sync views
84
- */
85
- async function getAllSyncViewsIds(ui5VersionInfo: Ui5VersionInfo): Promise<string[]> {
86
- const syncViewIds: string[] = [];
87
- try {
88
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 120 })) {
89
- const Element = (await import('sap/ui/core/Element')).default;
90
- const elements = Element.registry.filter(() => true) as UI5Element[];
91
- elements.forEach((ui5Element) => {
92
- if (isSyncView(ui5Element)) {
93
- syncViewIds.push(ui5Element.getId());
94
- }
95
- });
96
- } else {
97
- const ElementRegistry = (await import('sap/ui/core/ElementRegistry')).default;
98
- const elements = ElementRegistry.all() as Record<string, UI5Element>;
99
- Object.entries(elements).forEach(([key, ui5Element]) => {
100
- if (isSyncView(ui5Element)) {
101
- syncViewIds.push(key);
102
- }
103
- });
104
- }
105
- } catch (error) {
106
- log.error('Could not get application sync views', getError(error));
107
- }
108
-
109
- return syncViewIds;
110
- }
111
-
112
- /**
113
- * Check if element is sync view
114
- *
115
- * @param element UI5Element
116
- * @returns boolean if element is sync view or not
117
- */
118
- const isSyncView = (element: UI5Element): boolean => {
119
- return element?.getMetadata()?.getName()?.includes('XMLView') && element?.oAsyncState === undefined;
120
- };
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+ sap.ui.define([
3
+ 'sap/ui/dt/OverlayRegistry',
4
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
+ '../../../utils/version',
6
+ '../../utils',
7
+ '../../../cpe/quick-actions/utils',
8
+ '../../init-dialogs',
9
+ '../../api-handler'
10
+ ], function (OverlayRegistry, ___sap_ux_private_control_property_editor_common, _____utils_version, ____utils, _____cpe_quick_actions_utils, ____init_dialogs, ____api_handler) {
11
+ 'use strict';
12
+ const SIMPLE_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['SIMPLE_QUICK_ACTION_KIND'];
13
+ const getUi5Version = _____utils_version['getUi5Version'];
14
+ const getAllSyncViewsIds = ____utils['getAllSyncViewsIds'];
15
+ const getControllerInfoForControl = ____utils['getControllerInfoForControl'];
16
+ const getRelevantControlFromActivePage = _____cpe_quick_actions_utils['getRelevantControlFromActivePage'];
17
+ const DialogNames = ____init_dialogs['DialogNames'];
18
+ const handler = ____init_dialogs['handler'];
19
+ const isControllerExtensionEnabledForControl = ____init_dialogs['isControllerExtensionEnabledForControl'];
20
+ const getExistingController = ____api_handler['getExistingController'];
21
+ const ADD_CONTROLLER_TO_PAGE_TYPE = 'add-controller-to-page';
22
+ const CONTROL_TYPES = [
23
+ 'sap.f.DynamicPage',
24
+ 'sap.uxap.ObjectPageLayout'
25
+ ];
26
+ class AddControllerToPageQuickAction {
27
+ kind = SIMPLE_QUICK_ACTION_KIND;
28
+ type = ADD_CONTROLLER_TO_PAGE_TYPE;
29
+ get id() {
30
+ return `${ this.context.key }-${ this.type }`;
31
+ }
32
+ isActive = false;
33
+ controllerExists = false;
34
+ constructor(context) {
35
+ this.context = context;
36
+ }
37
+ async initialize() {
38
+ for (const control of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)) {
39
+ const version = await getUi5Version();
40
+ const syncViewsIds = await getAllSyncViewsIds(version);
41
+ const controlInfo = getControllerInfoForControl(control);
42
+ const data = await getExistingController(controlInfo.controllerName);
43
+ this.isActive = isControllerExtensionEnabledForControl(control, syncViewsIds, version);
44
+ this.controllerExists = data?.controllerExists;
45
+ this.control = control;
46
+ break;
47
+ }
48
+ }
49
+ getActionObject() {
50
+ const key = this.controllerExists ? 'QUICK_ACTION_SHOW_PAGE_CONTROLLER' : 'QUICK_ACTION_ADD_PAGE_CONTROLLER';
51
+ return {
52
+ kind: SIMPLE_QUICK_ACTION_KIND,
53
+ id: this.id,
54
+ enabled: this.isActive,
55
+ title: this.context.resourceBundle.getText(key)
56
+ };
57
+ }
58
+ async execute() {
59
+ if (this.control) {
60
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
61
+ await handler(overlay, this.context.rta, DialogNames.CONTROLLER_EXTENSION);
62
+ }
63
+ return [];
64
+ }
65
+ }
66
+ var __exports = { __esModule: true };
67
+ __exports.ADD_CONTROLLER_TO_PAGE_TYPE = ADD_CONTROLLER_TO_PAGE_TYPE;
68
+ __exports.AddControllerToPageQuickAction = AddControllerToPageQuickAction;
69
+ return __exports;
70
+ });
@@ -0,0 +1,71 @@
1
+ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
2
+ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
+ import UI5Element from 'sap/ui/core/Element';
4
+
5
+ import { SIMPLE_QUICK_ACTION_KIND, SimpleQuickAction } from '@sap-ux-private/control-property-editor-common';
6
+
7
+ import { getUi5Version } from '../../../utils/version';
8
+ import { getAllSyncViewsIds, getControllerInfoForControl } from '../../utils';
9
+ import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
10
+ import type {
11
+ QuickActionContext,
12
+ SimpleQuickActionDefinition
13
+ } from '../../../cpe/quick-actions/quick-action-definition';
14
+
15
+ import { DialogNames, handler, isControllerExtensionEnabledForControl } from '../../init-dialogs';
16
+ import { getExistingController } from '../../api-handler';
17
+
18
+ export const ADD_CONTROLLER_TO_PAGE_TYPE = 'add-controller-to-page';
19
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
20
+
21
+
22
+ /**
23
+ * Quick Action for adding controller to a page.
24
+ */
25
+ export class AddControllerToPageQuickAction implements SimpleQuickActionDefinition {
26
+ readonly kind = SIMPLE_QUICK_ACTION_KIND;
27
+ readonly type = ADD_CONTROLLER_TO_PAGE_TYPE;
28
+ public get id(): string {
29
+ return `${this.context.key}-${this.type}`;
30
+ }
31
+
32
+ isActive = false;
33
+ private controllerExists = false;
34
+ private control: UI5Element | undefined;
35
+ constructor(private context: QuickActionContext) {}
36
+
37
+ async initialize(): Promise<void> {
38
+ for (const control of getRelevantControlFromActivePage(
39
+ this.context.controlIndex,
40
+ this.context.view,
41
+ CONTROL_TYPES
42
+ )) {
43
+ const version = await getUi5Version();
44
+ const syncViewsIds = await getAllSyncViewsIds(version);
45
+ const controlInfo = getControllerInfoForControl(control);
46
+ const data = await getExistingController(controlInfo.controllerName);
47
+ this.isActive = isControllerExtensionEnabledForControl(control, syncViewsIds, version);
48
+ this.controllerExists = data?.controllerExists;
49
+ this.control = control;
50
+ break;
51
+ }
52
+ }
53
+
54
+ getActionObject(): SimpleQuickAction {
55
+ const key = this.controllerExists ? 'QUICK_ACTION_SHOW_PAGE_CONTROLLER' : 'QUICK_ACTION_ADD_PAGE_CONTROLLER';
56
+ return {
57
+ kind: SIMPLE_QUICK_ACTION_KIND,
58
+ id: this.id,
59
+ enabled: this.isActive,
60
+ title: this.context.resourceBundle.getText(key)
61
+ };
62
+ }
63
+
64
+ async execute(): Promise<FlexCommand[]> {
65
+ if (this.control) {
66
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
67
+ await handler(overlay, this.context.rta, DialogNames.CONTROLLER_EXTENSION);
68
+ }
69
+ return [];
70
+ }
71
+ }