@sap-ux/preview-middleware 0.16.80 → 0.16.82

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 (48) hide show
  1. package/dist/client/adp/api-handler.js +142 -142
  2. package/dist/client/adp/command-executor.js +58 -58
  3. package/dist/client/adp/control-utils.js +44 -44
  4. package/dist/client/adp/controllers/AddFragment.controller.js +5 -1
  5. package/dist/client/adp/controllers/AddFragment.controller.ts +5 -1
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +105 -105
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  9. package/dist/client/adp/init-dialogs.js +159 -159
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +54 -54
  11. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +35 -35
  12. package/dist/client/adp/quick-actions/common/op-add-header-field.js +47 -47
  13. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +98 -98
  14. package/dist/client/adp/quick-actions/fe-v2/create-page-action.js +35 -35
  15. package/dist/client/adp/quick-actions/fe-v2/create-page-action.ts +2 -2
  16. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +69 -69
  17. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +57 -57
  18. package/dist/client/adp/quick-actions/fe-v2/registry.js +60 -60
  19. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +79 -79
  20. package/dist/client/adp/quick-actions/fe-v4/registry.js +50 -50
  21. package/dist/client/adp/quick-actions/fe-v4/utils.js +52 -52
  22. package/dist/client/adp/quick-actions/load.js +48 -48
  23. package/dist/client/adp/utils.js +160 -160
  24. package/dist/client/cpe/changes/flex-change.js +51 -51
  25. package/dist/client/cpe/changes/index.js +10 -10
  26. package/dist/client/cpe/changes/validator.js +34 -34
  27. package/dist/client/cpe/documentation.js +164 -164
  28. package/dist/client/cpe/logger.js +30 -30
  29. package/dist/client/cpe/outline/editable.js +37 -37
  30. package/dist/client/cpe/outline/nodes.js +187 -187
  31. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  32. package/dist/client/cpe/quick-actions/registry.js +143 -143
  33. package/dist/client/cpe/quick-actions/utils.js +92 -92
  34. package/dist/client/cpe/types.js +4 -4
  35. package/dist/client/cpe/ui5-utils.js +33 -33
  36. package/dist/client/cpe/utils.js +97 -97
  37. package/dist/client/flp/WorkspaceConnector.js +87 -87
  38. package/dist/client/flp/common.js +28 -28
  39. package/dist/client/flp/enableFakeConnector.js +84 -84
  40. package/dist/client/flp/initConnectors.js +30 -30
  41. package/dist/client/flp/initRta.js +178 -178
  42. package/dist/client/i18n.js +56 -56
  43. package/dist/client/utils/application.js +32 -32
  44. package/dist/client/utils/core.js +68 -68
  45. package/dist/client/utils/error.js +19 -19
  46. package/dist/client/utils/version.js +68 -68
  47. package/package.json +5 -5
  48. package/dist/client/tsconfig.tsbuildinfo +0 -1
@@ -1,140 +1,140 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (JSONModel, ___api_handler, __BaseDialog, ___utils) {
4
- "use strict";
5
-
6
- function _interopRequireDefault(obj) {
7
- return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
- }
9
- const getFragments = ___api_handler["getFragments"];
10
- const BaseDialog = _interopRequireDefault(__BaseDialog);
11
- const notifyUser = ___utils["notifyUser"];
12
- /**
13
- * @namespace open.ux.preview.client.adp.controllers
14
- */
15
- const ExtensionPoint = BaseDialog.extend("open.ux.preview.client.adp.controllers.ExtensionPoint", {
16
- constructor: function _constructor(name, _overlays, rta, data) {
17
- BaseDialog.prototype.constructor.call(this, name);
18
- this.model = new JSONModel();
19
- this.data = data;
20
- this.rta = rta;
21
- },
22
- /**
23
- * Setups the Dialog and the JSON Model
24
- *
25
- * @param {Dialog} dialog - Dialog instance
26
- */
27
- setup: async function _setup(dialog) {
28
- this.dialog = dialog;
29
- this.setEscapeHandler();
30
- await this.buildDialogData();
31
- this.dialog.setModel(this.model);
32
- this.dialog.open();
33
- },
34
- /**
35
- * Handles create button press
36
- *
37
- * @param event Event
38
- */
39
- onCreateBtnPress: function _onCreateBtnPress(event) {
40
- const source = event.getSource();
41
- source.setEnabled(false);
42
- const fragmentName = this.model.getProperty('/newFragmentName');
43
- this.createExtensionPointFragmentChange(fragmentName);
44
- notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
45
- this.handleDialogClose();
46
- },
47
- /**
48
- * Handler for extension point select control
49
- *
50
- * @param event Select control change event
51
- */
52
- onExtensionPointHandler: function _onExtensionPointHandler(event) {
53
- const source = event.getSource();
54
- const selectedItem = source.getSelectedItem();
55
- let extensionPointName = '';
56
- if (selectedItem) {
57
- extensionPointName = selectedItem.getText();
58
- }
59
- this.model.setProperty('/extensionPointName', extensionPointName);
60
- const hasDefaultContent = this.hasDefaultContentForName(extensionPointName);
61
- this.model.setProperty('/hasDefaultContent', hasDefaultContent);
62
- },
63
- /**
64
- * Determines whether there is default content associated with the given name.
65
- *
66
- * @param {string} name - The name to check for associated default content.
67
- * @returns {boolean} - True if there is non-empty default content associated with the name, false otherwise.
68
- */
69
- hasDefaultContentForName: function _hasDefaultContentForName(name) {
70
- const defaultContent = this.data?.info.find(v => v.name === name)?.defaultContent;
71
- return defaultContent ? defaultContent.length > 0 : false;
72
- },
73
- /**
74
- * Builds data that is used in the dialog
75
- */
76
- buildDialogData: async function _buildDialogData() {
77
- const name = this.data?.name;
78
- if (name) {
79
- const hasDefaultContent = this.hasDefaultContentForName(name);
80
- const extensionPointList = [{
81
- key: 0,
82
- value: name
83
- }];
84
- this.updateModel(name, 0, extensionPointList, false, hasDefaultContent);
85
- } else {
86
- // In this case we are selecting from the application. There can be many extension points under one control.
87
- const extensionPointList = this.data.info.map((v, idx) => {
88
- return {
89
- key: idx,
90
- value: v.name
91
- };
92
- });
93
- const firstElName = extensionPointList[0].value;
94
- const enabled = extensionPointList.length > 1;
95
- const hasDefaultContent = this.hasDefaultContentForName(firstElName);
96
- this.updateModel(firstElName, 0, extensionPointList, enabled, hasDefaultContent);
97
- }
98
- try {
99
- const {
100
- fragments
101
- } = await getFragments();
102
- this.model.setProperty('/fragmentList', fragments);
103
- } catch (e) {
104
- this.handleError(e);
105
- }
106
- },
107
- /**
108
- * Updates the Select control according to provided values
109
- *
110
- * @param name Extension point name
111
- * @param key Selected extension point key
112
- * @param list All of the extension points that are under a view
113
- * @param enabled Enables the select control
114
- * @param hasDefaultContent Whether there is default content associated with the extension name
115
- */
116
- updateModel: function _updateModel(name, key, list, enabled, hasDefaultContent) {
117
- this.model.setProperty('/extensionPointName', name);
118
- this.model.setProperty('/extensionPointKey', key);
119
- this.model.setProperty('/extensionPointList', list);
120
- this.model.setProperty('/extensionListEnabled', enabled);
121
- this.model.setProperty('/hasDefaultContent', hasDefaultContent);
122
- },
123
- /**
124
- * Creates add xml at extension point changes
125
- *
126
- * @param fragmentName Fragment name
127
- */
128
- createExtensionPointFragmentChange: function _createExtensionPointFragmentChange(fragmentName) {
129
- const extensionPointName = this.model.getProperty('/extensionPointName');
130
- const modifiedValue = {
131
- fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
132
- fragmentPath: `fragments/${fragmentName}.fragment.xml`,
133
- extensionPointName
134
- };
135
- this.data.deferred.resolve(modifiedValue);
136
- }
137
- });
138
- return ExtensionPoint;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (JSONModel, ___api_handler, __BaseDialog, ___utils) {
4
+ "use strict";
5
+
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
+ }
9
+ const getFragments = ___api_handler["getFragments"];
10
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
11
+ const notifyUser = ___utils["notifyUser"];
12
+ /**
13
+ * @namespace open.ux.preview.client.adp.controllers
14
+ */
15
+ const ExtensionPoint = BaseDialog.extend("open.ux.preview.client.adp.controllers.ExtensionPoint", {
16
+ constructor: function _constructor(name, _overlays, rta, data) {
17
+ BaseDialog.prototype.constructor.call(this, name);
18
+ this.model = new JSONModel();
19
+ this.data = data;
20
+ this.rta = rta;
21
+ },
22
+ /**
23
+ * Setups the Dialog and the JSON Model
24
+ *
25
+ * @param {Dialog} dialog - Dialog instance
26
+ */
27
+ setup: async function _setup(dialog) {
28
+ this.dialog = dialog;
29
+ this.setEscapeHandler();
30
+ await this.buildDialogData();
31
+ this.dialog.setModel(this.model);
32
+ this.dialog.open();
33
+ },
34
+ /**
35
+ * Handles create button press
36
+ *
37
+ * @param event Event
38
+ */
39
+ onCreateBtnPress: function _onCreateBtnPress(event) {
40
+ const source = event.getSource();
41
+ source.setEnabled(false);
42
+ const fragmentName = this.model.getProperty('/newFragmentName');
43
+ this.createExtensionPointFragmentChange(fragmentName);
44
+ notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
45
+ this.handleDialogClose();
46
+ },
47
+ /**
48
+ * Handler for extension point select control
49
+ *
50
+ * @param event Select control change event
51
+ */
52
+ onExtensionPointHandler: function _onExtensionPointHandler(event) {
53
+ const source = event.getSource();
54
+ const selectedItem = source.getSelectedItem();
55
+ let extensionPointName = '';
56
+ if (selectedItem) {
57
+ extensionPointName = selectedItem.getText();
58
+ }
59
+ this.model.setProperty('/extensionPointName', extensionPointName);
60
+ const hasDefaultContent = this.hasDefaultContentForName(extensionPointName);
61
+ this.model.setProperty('/hasDefaultContent', hasDefaultContent);
62
+ },
63
+ /**
64
+ * Determines whether there is default content associated with the given name.
65
+ *
66
+ * @param {string} name - The name to check for associated default content.
67
+ * @returns {boolean} - True if there is non-empty default content associated with the name, false otherwise.
68
+ */
69
+ hasDefaultContentForName: function _hasDefaultContentForName(name) {
70
+ const defaultContent = this.data?.info.find(v => v.name === name)?.defaultContent;
71
+ return defaultContent ? defaultContent.length > 0 : false;
72
+ },
73
+ /**
74
+ * Builds data that is used in the dialog
75
+ */
76
+ buildDialogData: async function _buildDialogData() {
77
+ const name = this.data?.name;
78
+ if (name) {
79
+ const hasDefaultContent = this.hasDefaultContentForName(name);
80
+ const extensionPointList = [{
81
+ key: 0,
82
+ value: name
83
+ }];
84
+ this.updateModel(name, 0, extensionPointList, false, hasDefaultContent);
85
+ } else {
86
+ // In this case we are selecting from the application. There can be many extension points under one control.
87
+ const extensionPointList = this.data.info.map((v, idx) => {
88
+ return {
89
+ key: idx,
90
+ value: v.name
91
+ };
92
+ });
93
+ const firstElName = extensionPointList[0].value;
94
+ const enabled = extensionPointList.length > 1;
95
+ const hasDefaultContent = this.hasDefaultContentForName(firstElName);
96
+ this.updateModel(firstElName, 0, extensionPointList, enabled, hasDefaultContent);
97
+ }
98
+ try {
99
+ const {
100
+ fragments
101
+ } = await getFragments();
102
+ this.model.setProperty('/fragmentList', fragments);
103
+ } catch (e) {
104
+ this.handleError(e);
105
+ }
106
+ },
107
+ /**
108
+ * Updates the Select control according to provided values
109
+ *
110
+ * @param name Extension point name
111
+ * @param key Selected extension point key
112
+ * @param list All of the extension points that are under a view
113
+ * @param enabled Enables the select control
114
+ * @param hasDefaultContent Whether there is default content associated with the extension name
115
+ */
116
+ updateModel: function _updateModel(name, key, list, enabled, hasDefaultContent) {
117
+ this.model.setProperty('/extensionPointName', name);
118
+ this.model.setProperty('/extensionPointKey', key);
119
+ this.model.setProperty('/extensionPointList', list);
120
+ this.model.setProperty('/extensionListEnabled', enabled);
121
+ this.model.setProperty('/hasDefaultContent', hasDefaultContent);
122
+ },
123
+ /**
124
+ * Creates add xml at extension point changes
125
+ *
126
+ * @param fragmentName Fragment name
127
+ */
128
+ createExtensionPointFragmentChange: function _createExtensionPointFragmentChange(fragmentName) {
129
+ const extensionPointName = this.model.getProperty('/extensionPointName');
130
+ const modifiedValue = {
131
+ fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
132
+ fragmentPath: `fragments/${fragmentName}.fragment.xml`,
133
+ extensionPointName
134
+ };
135
+ this.data.deferred.resolve(modifiedValue);
136
+ }
137
+ });
138
+ return ExtensionPoint;
139
139
  });
140
140
  //# sourceMappingURL=ExtensionPoint.controller.js.map
@@ -1,161 +1,161 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/utils", "../i18n"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_utils, ___i18n) {
4
- "use strict";
5
-
6
- function _interopRequireDefault(obj) {
7
- return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
- }
9
- const AddFragment = _interopRequireDefault(__AddFragment);
10
- const ControllerExtension = _interopRequireDefault(__ControllerExtension);
11
- const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
12
- const isReuseComponent = ___cpe_utils["isReuseComponent"];
13
- const getTextBundle = ___i18n["getTextBundle"];
14
- var DialogNames = /*#__PURE__*/function (DialogNames) {
15
- DialogNames["ADD_FRAGMENT"] = "AddFragment";
16
- DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
17
- DialogNames["ADD_FRAGMENT_AT_EXTENSION_POINT"] = "ExtensionPoint";
18
- return DialogNames;
19
- }(DialogNames || {});
20
- /**
21
- * Handler for enablement of Extend With Controller context menu entry
22
- *
23
- * @param control UI5 control.
24
- * @param syncViewsIds Runtime Authoring
25
- * @param ui5VersionInfo UI5 version information
26
- *
27
- * @returns boolean whether menu item is enabled or not
28
- */
29
- function isControllerExtensionEnabledForControl(control, syncViewsIds, ui5VersionInfo) {
30
- const clickedControlId = FlUtils.getViewForControl(control).getId();
31
- const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
32
- return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
33
- }
34
-
35
- /**
36
- * Handler for enablement of Extend With Controller context menu entry
37
- *
38
- * @param overlays Control overlays
39
- * @param syncViewsIds Runtime Authoring
40
- * @param ui5VersionInfo UI5 version information
41
- *
42
- * @returns boolean whether menu item is enabled or not
43
- */
44
- const isControllerExtensionEnabled = (overlays, syncViewsIds, ui5VersionInfo) => {
45
- if (overlays.length === 0 || overlays.length > 1) {
46
- return false;
47
- }
48
- return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo);
49
- };
50
-
51
- /**
52
- * Determines whether the fragment command should be enabled based on the provided overlays.
53
- *
54
- * @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
55
- * @param ui5VersionInfo UI5 version information
56
- * @returns {boolean} True if the fragment command is enabled, false otherwise.
57
- */
58
- const isFragmentCommandEnabled = (overlays, ui5VersionInfo) => {
59
- if (overlays.length === 0 || overlays.length > 1) {
60
- return false;
61
- }
62
- const control = overlays[0].getElement();
63
- return hasStableId(control) && !isReuseComponent(control.getId(), ui5VersionInfo);
64
- };
65
-
66
- /**
67
- * Determines whether control has stable id
68
- * @param {ManagedObject} control - ManagedObject object representing the UI control.
69
- * @returns {boolean} True if control has stable Id, false otherwise
70
- */
71
- const hasStableId = control => {
72
- return FlUtils.checkControlId(control);
73
- };
74
-
75
- /**
76
- * Determines the text that should be displayed for the Add Fragment context menu item.
77
- *
78
- * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
79
- * @returns {string} The text of the Add Fragment context menu item.
80
- */
81
- const getAddFragmentItemText = overlay => {
82
- const control = overlay.getElement();
83
- if (control && !hasStableId(control)) {
84
- return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
85
- }
86
- return 'Add: Fragment';
87
- };
88
-
89
- /**
90
- * Handler for new context menu entry
91
- *
92
- * @param overlay Control overlays
93
- * @param rta Runtime Authoring
94
- * @param dialogName Dialog name
95
- * @param extensionPointData Control ID
96
- * @param options Dialog options
97
- */
98
- async function handler(overlay, rta, dialogName, extensionPointData) {
99
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
100
- let controller;
101
- const resources = await getTextBundle();
102
- switch (dialogName) {
103
- case DialogNames.ADD_FRAGMENT:
104
- controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
105
- aggregation: options.aggregation,
106
- title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
107
- });
108
- break;
109
- case DialogNames.CONTROLLER_EXTENSION:
110
- controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
111
- break;
112
- case DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT:
113
- controller = new ExtensionPoint(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, extensionPointData);
114
- break;
115
- }
116
- const id = dialogName === DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT ? `dialog--${dialogName}` : undefined;
117
- const dialog = await Fragment.load({
118
- name: `open.ux.preview.client.adp.ui.${dialogName}`,
119
- controller,
120
- id
121
- });
122
- await controller.setup(dialog);
123
- }
124
-
125
- /**
126
- * Adds a new item to the context menu
127
- *
128
- * @param rta Runtime Authoring
129
- * @param syncViewsIds Ids of all application sync views
130
- * @param ui5VersionInfo UI5 version information
131
- */
132
- const initDialogs = (rta, syncViewsIds, ui5VersionInfo) => {
133
- const contextMenu = rta.getDefaultPlugins().contextMenu;
134
- contextMenu.addMenuItem({
135
- id: 'ADD_FRAGMENT',
136
- text: getAddFragmentItemText,
137
- handler: async overlays => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
138
- icon: 'sap-icon://attachment-html',
139
- enabled: overlays => isFragmentCommandEnabled(overlays, ui5VersionInfo)
140
- });
141
- contextMenu.addMenuItem({
142
- id: 'EXTEND_CONTROLLER',
143
- text: 'Extend With Controller',
144
- handler: async overlays => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
145
- icon: 'sap-icon://create-form',
146
- enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds, ui5VersionInfo)
147
- });
148
- };
149
- var __exports = {
150
- __esModule: true
151
- };
152
- __exports.DialogNames = DialogNames;
153
- __exports.isControllerExtensionEnabledForControl = isControllerExtensionEnabledForControl;
154
- __exports.isControllerExtensionEnabled = isControllerExtensionEnabled;
155
- __exports.isFragmentCommandEnabled = isFragmentCommandEnabled;
156
- __exports.getAddFragmentItemText = getAddFragmentItemText;
157
- __exports.handler = handler;
158
- __exports.initDialogs = initDialogs;
159
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/utils", "../i18n"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_utils, ___i18n) {
4
+ "use strict";
5
+
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
+ }
9
+ const AddFragment = _interopRequireDefault(__AddFragment);
10
+ const ControllerExtension = _interopRequireDefault(__ControllerExtension);
11
+ const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
12
+ const isReuseComponent = ___cpe_utils["isReuseComponent"];
13
+ const getTextBundle = ___i18n["getTextBundle"];
14
+ var DialogNames = /*#__PURE__*/function (DialogNames) {
15
+ DialogNames["ADD_FRAGMENT"] = "AddFragment";
16
+ DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
17
+ DialogNames["ADD_FRAGMENT_AT_EXTENSION_POINT"] = "ExtensionPoint";
18
+ return DialogNames;
19
+ }(DialogNames || {});
20
+ /**
21
+ * Handler for enablement of Extend With Controller context menu entry
22
+ *
23
+ * @param control UI5 control.
24
+ * @param syncViewsIds Runtime Authoring
25
+ * @param ui5VersionInfo UI5 version information
26
+ *
27
+ * @returns boolean whether menu item is enabled or not
28
+ */
29
+ function isControllerExtensionEnabledForControl(control, syncViewsIds, ui5VersionInfo) {
30
+ const clickedControlId = FlUtils.getViewForControl(control).getId();
31
+ const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
32
+ return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
33
+ }
34
+
35
+ /**
36
+ * Handler for enablement of Extend With Controller context menu entry
37
+ *
38
+ * @param overlays Control overlays
39
+ * @param syncViewsIds Runtime Authoring
40
+ * @param ui5VersionInfo UI5 version information
41
+ *
42
+ * @returns boolean whether menu item is enabled or not
43
+ */
44
+ const isControllerExtensionEnabled = (overlays, syncViewsIds, ui5VersionInfo) => {
45
+ if (overlays.length === 0 || overlays.length > 1) {
46
+ return false;
47
+ }
48
+ return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo);
49
+ };
50
+
51
+ /**
52
+ * Determines whether the fragment command should be enabled based on the provided overlays.
53
+ *
54
+ * @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
55
+ * @param ui5VersionInfo UI5 version information
56
+ * @returns {boolean} True if the fragment command is enabled, false otherwise.
57
+ */
58
+ const isFragmentCommandEnabled = (overlays, ui5VersionInfo) => {
59
+ if (overlays.length === 0 || overlays.length > 1) {
60
+ return false;
61
+ }
62
+ const control = overlays[0].getElement();
63
+ return hasStableId(control) && !isReuseComponent(control.getId(), ui5VersionInfo);
64
+ };
65
+
66
+ /**
67
+ * Determines whether control has stable id
68
+ * @param {ManagedObject} control - ManagedObject object representing the UI control.
69
+ * @returns {boolean} True if control has stable Id, false otherwise
70
+ */
71
+ const hasStableId = control => {
72
+ return FlUtils.checkControlId(control);
73
+ };
74
+
75
+ /**
76
+ * Determines the text that should be displayed for the Add Fragment context menu item.
77
+ *
78
+ * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
79
+ * @returns {string} The text of the Add Fragment context menu item.
80
+ */
81
+ const getAddFragmentItemText = overlay => {
82
+ const control = overlay.getElement();
83
+ if (control && !hasStableId(control)) {
84
+ return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
85
+ }
86
+ return 'Add: Fragment';
87
+ };
88
+
89
+ /**
90
+ * Handler for new context menu entry
91
+ *
92
+ * @param overlay Control overlays
93
+ * @param rta Runtime Authoring
94
+ * @param dialogName Dialog name
95
+ * @param extensionPointData Control ID
96
+ * @param options Dialog options
97
+ */
98
+ async function handler(overlay, rta, dialogName, extensionPointData) {
99
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
100
+ let controller;
101
+ const resources = await getTextBundle();
102
+ switch (dialogName) {
103
+ case DialogNames.ADD_FRAGMENT:
104
+ controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
105
+ aggregation: options.aggregation,
106
+ title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
107
+ });
108
+ break;
109
+ case DialogNames.CONTROLLER_EXTENSION:
110
+ controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
111
+ break;
112
+ case DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT:
113
+ controller = new ExtensionPoint(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, extensionPointData);
114
+ break;
115
+ }
116
+ const id = dialogName === DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT ? `dialog--${dialogName}` : undefined;
117
+ const dialog = await Fragment.load({
118
+ name: `open.ux.preview.client.adp.ui.${dialogName}`,
119
+ controller,
120
+ id
121
+ });
122
+ await controller.setup(dialog);
123
+ }
124
+
125
+ /**
126
+ * Adds a new item to the context menu
127
+ *
128
+ * @param rta Runtime Authoring
129
+ * @param syncViewsIds Ids of all application sync views
130
+ * @param ui5VersionInfo UI5 version information
131
+ */
132
+ const initDialogs = (rta, syncViewsIds, ui5VersionInfo) => {
133
+ const contextMenu = rta.getDefaultPlugins().contextMenu;
134
+ contextMenu.addMenuItem({
135
+ id: 'ADD_FRAGMENT',
136
+ text: getAddFragmentItemText,
137
+ handler: async overlays => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
138
+ icon: 'sap-icon://attachment-html',
139
+ enabled: overlays => isFragmentCommandEnabled(overlays, ui5VersionInfo)
140
+ });
141
+ contextMenu.addMenuItem({
142
+ id: 'EXTEND_CONTROLLER',
143
+ text: 'Extend With Controller',
144
+ handler: async overlays => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
145
+ icon: 'sap-icon://create-form',
146
+ enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds, ui5VersionInfo)
147
+ });
148
+ };
149
+ var __exports = {
150
+ __esModule: true
151
+ };
152
+ __exports.DialogNames = DialogNames;
153
+ __exports.isControllerExtensionEnabledForControl = isControllerExtensionEnabledForControl;
154
+ __exports.isControllerExtensionEnabled = isControllerExtensionEnabled;
155
+ __exports.isFragmentCommandEnabled = isFragmentCommandEnabled;
156
+ __exports.getAddFragmentItemText = getAddFragmentItemText;
157
+ __exports.handler = handler;
158
+ __exports.initDialogs = initDialogs;
159
+ return __exports;
160
160
  });
161
161
  //# sourceMappingURL=init-dialogs.js.map