@sap-ux/preview-middleware 0.17.37 → 0.17.39

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 (73) hide show
  1. package/README.md +26 -23
  2. package/dist/base/config.d.ts +9 -1
  3. package/dist/base/config.js +29 -5
  4. package/dist/base/flp.d.ts +1 -1
  5. package/dist/base/flp.js +16 -16
  6. package/dist/client/adp/api-handler.js +153 -153
  7. package/dist/client/adp/command-executor.js +75 -75
  8. package/dist/client/adp/control-utils.js +44 -44
  9. package/dist/client/adp/controllers/BaseDialog.controller.js +187 -187
  10. package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
  11. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  12. package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
  13. package/dist/client/adp/dialog-factory.js +122 -122
  14. package/dist/client/adp/init-dialogs.js +100 -100
  15. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +55 -55
  16. package/dist/client/adp/quick-actions/common/create-page-action.js +50 -50
  17. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +36 -36
  18. package/dist/client/adp/quick-actions/common/op-add-header-field.js +48 -48
  19. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  20. package/dist/client/adp/quick-actions/control-types.js +21 -21
  21. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  22. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  23. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  24. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +70 -70
  25. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +96 -96
  26. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
  27. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  28. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
  29. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +58 -58
  30. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  31. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
  32. package/dist/client/adp/quick-actions/fe-v2/registry.js +75 -75
  33. package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
  34. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +73 -73
  35. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +49 -49
  36. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +46 -46
  37. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
  38. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +55 -55
  39. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +82 -82
  40. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +52 -52
  41. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  42. package/dist/client/adp/quick-actions/fe-v4/registry.js +58 -58
  43. package/dist/client/adp/quick-actions/fe-v4/utils.js +47 -47
  44. package/dist/client/adp/quick-actions/load.js +44 -44
  45. package/dist/client/adp/quick-actions/quick-action-base.js +53 -53
  46. package/dist/client/adp/utils.js +160 -160
  47. package/dist/client/cpe/changes/index.js +10 -10
  48. package/dist/client/cpe/changes/validator.js +39 -39
  49. package/dist/client/cpe/documentation.js +164 -164
  50. package/dist/client/cpe/feature-service.js +36 -36
  51. package/dist/client/cpe/logger.js +30 -30
  52. package/dist/client/cpe/outline/editable.js +37 -37
  53. package/dist/client/cpe/outline/nodes.js +222 -222
  54. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  55. package/dist/client/cpe/quick-actions/registry.js +143 -143
  56. package/dist/client/cpe/quick-actions/utils.js +92 -92
  57. package/dist/client/cpe/types.js +4 -4
  58. package/dist/client/cpe/ui5-utils.js +33 -33
  59. package/dist/client/cpe/utils.js +138 -138
  60. package/dist/client/flp/WorkspaceConnector.js +86 -86
  61. package/dist/client/flp/common.js +28 -28
  62. package/dist/client/flp/enableFakeConnector.js +83 -83
  63. package/dist/client/flp/initConnectors.js +30 -30
  64. package/dist/client/flp/initRta.js +178 -178
  65. package/dist/client/i18n.js +56 -56
  66. package/dist/client/tsconfig.tsbuildinfo +1 -0
  67. package/dist/client/utils/application.js +32 -32
  68. package/dist/client/utils/core.js +68 -68
  69. package/dist/client/utils/error.js +19 -19
  70. package/dist/client/utils/fe-v4.js +118 -118
  71. package/dist/client/utils/version.js +102 -102
  72. package/dist/types/index.d.ts +13 -4
  73. package/package.json +3 -3
@@ -1,77 +1,77 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
- "use strict";
5
-
6
- const getError = ___utils_error["getError"];
7
- /**
8
- * Class responsible for handling rta calls
9
- */
10
- class CommandExecutor {
11
- /**
12
- *
13
- * @param rta Runtime Authoring
14
- */
15
- constructor(rta) {
16
- this.rta = rta;
17
- }
18
-
19
- /**
20
- * Generates command based on given values
21
- *
22
- * @param runtimeControl Managed object
23
- * @param commandName Command name
24
- * @param modifiedValue Modified value/s
25
- * @param designMetadata Design time metadata
26
- * @param flexSettings Additional flex settings
27
- */
28
- async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
- try {
30
- return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
- } catch (e) {
32
- const error = getError(e);
33
- const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
- error.message = msgToastErrorMsg;
35
- MessageToast.show(msgToastErrorMsg);
36
- throw error;
37
- }
38
- }
39
-
40
- /**
41
- * Creates composite command without nested commands
42
- *
43
- * @param runtimeControl Managed object
44
- */
45
- async createCompositeCommand(runtimeControl) {
46
- try {
47
- return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
- } catch (e) {
49
- const error = getError(e);
50
- const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
- error.message = msgToastErrorMsg;
52
- MessageToast.show(msgToastErrorMsg);
53
- throw error;
54
- }
55
- }
56
-
57
- /**
58
- * Pushed and executes the provided command
59
- *
60
- * @param command Command
61
- */
62
- async pushAndExecuteCommand(command) {
63
- try {
64
- /**
65
- * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
- */
67
- await this.rta.getCommandStack().pushAndExecute(command);
68
- } catch (e) {
69
- const error = getError(e);
70
- MessageToast.show(error.message);
71
- throw error;
72
- }
73
- }
74
- }
75
- return CommandExecutor;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
+ "use strict";
5
+
6
+ const getError = ___utils_error["getError"];
7
+ /**
8
+ * Class responsible for handling rta calls
9
+ */
10
+ class CommandExecutor {
11
+ /**
12
+ *
13
+ * @param rta Runtime Authoring
14
+ */
15
+ constructor(rta) {
16
+ this.rta = rta;
17
+ }
18
+
19
+ /**
20
+ * Generates command based on given values
21
+ *
22
+ * @param runtimeControl Managed object
23
+ * @param commandName Command name
24
+ * @param modifiedValue Modified value/s
25
+ * @param designMetadata Design time metadata
26
+ * @param flexSettings Additional flex settings
27
+ */
28
+ async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
+ try {
30
+ return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
+ } catch (e) {
32
+ const error = getError(e);
33
+ const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
+ error.message = msgToastErrorMsg;
35
+ MessageToast.show(msgToastErrorMsg);
36
+ throw error;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Creates composite command without nested commands
42
+ *
43
+ * @param runtimeControl Managed object
44
+ */
45
+ async createCompositeCommand(runtimeControl) {
46
+ try {
47
+ return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
+ } catch (e) {
49
+ const error = getError(e);
50
+ const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
+ error.message = msgToastErrorMsg;
52
+ MessageToast.show(msgToastErrorMsg);
53
+ throw error;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Pushed and executes the provided command
59
+ *
60
+ * @param command Command
61
+ */
62
+ async pushAndExecuteCommand(command) {
63
+ try {
64
+ /**
65
+ * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
+ */
67
+ await this.rta.getCommandStack().pushAndExecute(command);
68
+ } catch (e) {
69
+ const error = getError(e);
70
+ MessageToast.show(error.message);
71
+ throw error;
72
+ }
73
+ }
74
+ }
75
+ return CommandExecutor;
76
76
  });
77
77
  //# sourceMappingURL=command-executor.js.map
@@ -1,46 +1,46 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Handles calling control specific functions for retrieving control data
8
- */
9
- class ControlUtils {
10
- /**
11
- * Returns ManagedObject runtime control
12
- *
13
- * @param overlayControl Overlay
14
- * @returns {ManagedObject} Managed Object instance
15
- */
16
- static getRuntimeControl(overlayControl) {
17
- let runtimeControl;
18
- if (overlayControl.getElementInstance) {
19
- runtimeControl = overlayControl.getElementInstance();
20
- } else {
21
- runtimeControl = overlayControl.getElement();
22
- }
23
- return runtimeControl;
24
- }
25
-
26
- /**
27
- * Returns control aggregation names in an array
28
- *
29
- * @param control Managed Object runtime control
30
- * @param name Aggregation name
31
- * @returns Array of control aggregations
32
- */
33
- static getControlAggregationByName(control, name) {
34
- let result = [];
35
- const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
36
- if (aggregation) {
37
- // This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
38
- const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
39
- result = Array.isArray(names) ? names : [names];
40
- }
41
- return result;
42
- }
43
- }
44
- return ControlUtils;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Handles calling control specific functions for retrieving control data
8
+ */
9
+ class ControlUtils {
10
+ /**
11
+ * Returns ManagedObject runtime control
12
+ *
13
+ * @param overlayControl Overlay
14
+ * @returns {ManagedObject} Managed Object instance
15
+ */
16
+ static getRuntimeControl(overlayControl) {
17
+ let runtimeControl;
18
+ if (overlayControl.getElementInstance) {
19
+ runtimeControl = overlayControl.getElementInstance();
20
+ } else {
21
+ runtimeControl = overlayControl.getElement();
22
+ }
23
+ return runtimeControl;
24
+ }
25
+
26
+ /**
27
+ * Returns control aggregation names in an array
28
+ *
29
+ * @param control Managed Object runtime control
30
+ * @param name Aggregation name
31
+ * @returns Array of control aggregations
32
+ */
33
+ static getControlAggregationByName(control, name) {
34
+ let result = [];
35
+ const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
36
+ if (aggregation) {
37
+ // This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
38
+ const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
39
+ result = Array.isArray(names) ? names : [names];
40
+ }
41
+ return result;
42
+ }
43
+ }
44
+ return ControlUtils;
45
45
  });
46
46
  //# sourceMappingURL=control-utils.js.map
@@ -1,189 +1,189 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/MessageToast", "../utils", "../../utils/error", "../../utils/core", "../control-utils", "sap/ui/dt/OverlayRegistry"], function (sap_ui_core_library, Controller, MessageToast, ___utils, ____utils_error, ____utils_core, __ControlUtils, OverlayRegistry) {
4
- "use strict";
5
-
6
- function _interopRequireDefault(obj) {
7
- return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
- }
9
- const ValueState = sap_ui_core_library["ValueState"];
10
- const matchesFragmentName = ___utils["matchesFragmentName"];
11
- const getError = ____utils_error["getError"];
12
- const getControlById = ____utils_core["getControlById"];
13
- const ControlUtils = _interopRequireDefault(__ControlUtils);
14
- /**
15
- * @namespace open.ux.preview.client.adp.controllers
16
- */
17
- const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
18
- /**
19
- * Method is used in add fragment dialog controllers to get current control metadata which are needed on the dialog
20
- * @returns control metadata and target aggregations
21
- */
22
- getControlMetadata: function _getControlMetadata() {
23
- const selectorId = this.overlays.getId();
24
- let controlMetadata;
25
- const overlayControl = getControlById(selectorId);
26
- if (overlayControl) {
27
- this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
28
- controlMetadata = this.runtimeControl.getMetadata();
29
- } else {
30
- throw new Error('Cannot get overlay control');
31
- }
32
- const allAggregations = Object.keys(controlMetadata.getAllAggregations());
33
- const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
34
- const targetAggregation = allAggregations.filter(item => {
35
- if (hiddenAggregations.indexOf(item) === -1) {
36
- return item;
37
- }
38
- return false;
39
- });
40
- return {
41
- controlMetadata,
42
- targetAggregation
43
- };
44
- },
45
- /**
46
- * Fills indexArray from selected control children
47
- *
48
- * @param selectedControlChildren Array of numbers
49
- * @returns Array of key value pairs
50
- */
51
- fillIndexArray: function _fillIndexArray(selectedControlChildren) {
52
- let indexArray = [];
53
- if (selectedControlChildren.length === 0) {
54
- indexArray.push({
55
- key: 0,
56
- value: 0
57
- });
58
- } else {
59
- indexArray = selectedControlChildren.map((elem, index) => {
60
- return {
61
- key: index + 1,
62
- value: elem + 1
63
- };
64
- });
65
- indexArray.unshift({
66
- key: 0,
67
- value: 0
68
- });
69
- indexArray.push({
70
- key: selectedControlChildren.length + 1,
71
- value: selectedControlChildren.length + 1
72
- });
73
- }
74
- return indexArray;
75
- },
76
- /**
77
- * Handles fragment name input change
78
- *
79
- * @param event Event
80
- */
81
- onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
82
- const input = event.getSource();
83
- const beginBtn = this.dialog.getBeginButton();
84
- const fragmentName = input.getValue();
85
- const fragmentList = this.model.getProperty('/fragmentList');
86
- const updateDialogState = function (valueState) {
87
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
88
- input.setValueState(valueState).setValueStateText(valueStateText);
89
- beginBtn.setEnabled(valueState === ValueState.Success);
90
- };
91
- if (fragmentName.length <= 0) {
92
- updateDialogState(ValueState.None);
93
- this.model.setProperty('/newFragmentName', null);
94
- return;
95
- }
96
- const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
97
- if (fileExists) {
98
- updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
99
- return;
100
- }
101
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
102
- if (!isValidName) {
103
- updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
104
- return;
105
- }
106
- if (fragmentName.length > 64) {
107
- updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
108
- return;
109
- }
110
- const changeExists = this.checkForExistingChange(fragmentName);
111
- if (changeExists) {
112
- updateDialogState(ValueState.Error, 'Enter a different name. The fragment name entered matches the name of an unsaved fragment.');
113
- return;
114
- }
115
- updateDialogState(ValueState.Success);
116
- this.model.setProperty('/newFragmentName', fragmentName);
117
- },
118
- /**
119
- * Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
120
- *
121
- * @param {string} fragmentName - The name of the fragment to check for existing changes.
122
- * @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
123
- */
124
- checkForExistingChange: function _checkForExistingChange(fragmentName) {
125
- const allCommands = this.rta.getCommandStack().getCommands();
126
- return allCommands.some(command => {
127
- if (typeof command.getCommands === 'function') {
128
- const addXmlCommand = command.getCommands().find(c => c?.getProperty('name') === 'addXMLAtExtensionPoint');
129
- return addXmlCommand && matchesFragmentName(addXmlCommand, fragmentName);
130
- } else {
131
- return matchesFragmentName(command, fragmentName);
132
- }
133
- });
134
- },
135
- /**
136
- * Sets custom function that fires when user presses escape key.
137
- */
138
- setEscapeHandler: function _setEscapeHandler() {
139
- this.dialog.setEscapeHandler(_ref => {
140
- let {
141
- resolve
142
- } = _ref;
143
- this.handleDialogClose();
144
- resolve();
145
- });
146
- },
147
- /**
148
- * Handles the dialog closing and destruction of it.
149
- */
150
- handleDialogClose: function _handleDialogClose() {
151
- this.dialog.close();
152
- this.dialog.destroy();
153
- },
154
- /**
155
- * Function that handles runtime thrown errors with MessageToast
156
- *
157
- * @param e error instance
158
- * @throws {Error}.
159
- */
160
- handleError: function _handleError(e) {
161
- const error = getError(e);
162
- MessageToast.show(error.message, {
163
- duration: 5000
164
- });
165
- throw error;
166
- },
167
- /**
168
- * Handles the index field whenever a specific aggregation is chosen
169
- *
170
- * @param specialIndexAggregation string | number
171
- */
172
- specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
173
- const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
174
- const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
175
- if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
176
- const controlType = this.runtimeControl.getMetadata().getName();
177
- this.model.setProperty('/indexHandlingFlag', false);
178
- this.model.setProperty('/specialIndexHandlingIcon', true);
179
- this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
180
- } else {
181
- this.model.setProperty('/indexHandlingFlag', true);
182
- this.model.setProperty('/specialIndexHandlingIcon', false);
183
- this.model.setProperty('/specialIndexHandlingIconPressed', false);
184
- }
185
- }
186
- });
187
- return BaseDialog;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/MessageToast", "../utils", "../../utils/error", "../../utils/core", "../control-utils", "sap/ui/dt/OverlayRegistry"], function (sap_ui_core_library, Controller, MessageToast, ___utils, ____utils_error, ____utils_core, __ControlUtils, OverlayRegistry) {
4
+ "use strict";
5
+
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
+ }
9
+ const ValueState = sap_ui_core_library["ValueState"];
10
+ const matchesFragmentName = ___utils["matchesFragmentName"];
11
+ const getError = ____utils_error["getError"];
12
+ const getControlById = ____utils_core["getControlById"];
13
+ const ControlUtils = _interopRequireDefault(__ControlUtils);
14
+ /**
15
+ * @namespace open.ux.preview.client.adp.controllers
16
+ */
17
+ const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
18
+ /**
19
+ * Method is used in add fragment dialog controllers to get current control metadata which are needed on the dialog
20
+ * @returns control metadata and target aggregations
21
+ */
22
+ getControlMetadata: function _getControlMetadata() {
23
+ const selectorId = this.overlays.getId();
24
+ let controlMetadata;
25
+ const overlayControl = getControlById(selectorId);
26
+ if (overlayControl) {
27
+ this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
28
+ controlMetadata = this.runtimeControl.getMetadata();
29
+ } else {
30
+ throw new Error('Cannot get overlay control');
31
+ }
32
+ const allAggregations = Object.keys(controlMetadata.getAllAggregations());
33
+ const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
34
+ const targetAggregation = allAggregations.filter(item => {
35
+ if (hiddenAggregations.indexOf(item) === -1) {
36
+ return item;
37
+ }
38
+ return false;
39
+ });
40
+ return {
41
+ controlMetadata,
42
+ targetAggregation
43
+ };
44
+ },
45
+ /**
46
+ * Fills indexArray from selected control children
47
+ *
48
+ * @param selectedControlChildren Array of numbers
49
+ * @returns Array of key value pairs
50
+ */
51
+ fillIndexArray: function _fillIndexArray(selectedControlChildren) {
52
+ let indexArray = [];
53
+ if (selectedControlChildren.length === 0) {
54
+ indexArray.push({
55
+ key: 0,
56
+ value: 0
57
+ });
58
+ } else {
59
+ indexArray = selectedControlChildren.map((elem, index) => {
60
+ return {
61
+ key: index + 1,
62
+ value: elem + 1
63
+ };
64
+ });
65
+ indexArray.unshift({
66
+ key: 0,
67
+ value: 0
68
+ });
69
+ indexArray.push({
70
+ key: selectedControlChildren.length + 1,
71
+ value: selectedControlChildren.length + 1
72
+ });
73
+ }
74
+ return indexArray;
75
+ },
76
+ /**
77
+ * Handles fragment name input change
78
+ *
79
+ * @param event Event
80
+ */
81
+ onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
82
+ const input = event.getSource();
83
+ const beginBtn = this.dialog.getBeginButton();
84
+ const fragmentName = input.getValue();
85
+ const fragmentList = this.model.getProperty('/fragmentList');
86
+ const updateDialogState = function (valueState) {
87
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
88
+ input.setValueState(valueState).setValueStateText(valueStateText);
89
+ beginBtn.setEnabled(valueState === ValueState.Success);
90
+ };
91
+ if (fragmentName.length <= 0) {
92
+ updateDialogState(ValueState.None);
93
+ this.model.setProperty('/newFragmentName', null);
94
+ return;
95
+ }
96
+ const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
97
+ if (fileExists) {
98
+ updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
99
+ return;
100
+ }
101
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
102
+ if (!isValidName) {
103
+ updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
104
+ return;
105
+ }
106
+ if (fragmentName.length > 64) {
107
+ updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
108
+ return;
109
+ }
110
+ const changeExists = this.checkForExistingChange(fragmentName);
111
+ if (changeExists) {
112
+ updateDialogState(ValueState.Error, 'Enter a different name. The fragment name entered matches the name of an unsaved fragment.');
113
+ return;
114
+ }
115
+ updateDialogState(ValueState.Success);
116
+ this.model.setProperty('/newFragmentName', fragmentName);
117
+ },
118
+ /**
119
+ * Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
120
+ *
121
+ * @param {string} fragmentName - The name of the fragment to check for existing changes.
122
+ * @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
123
+ */
124
+ checkForExistingChange: function _checkForExistingChange(fragmentName) {
125
+ const allCommands = this.rta.getCommandStack().getCommands();
126
+ return allCommands.some(command => {
127
+ if (typeof command.getCommands === 'function') {
128
+ const addXmlCommand = command.getCommands().find(c => c?.getProperty('name') === 'addXMLAtExtensionPoint');
129
+ return addXmlCommand && matchesFragmentName(addXmlCommand, fragmentName);
130
+ } else {
131
+ return matchesFragmentName(command, fragmentName);
132
+ }
133
+ });
134
+ },
135
+ /**
136
+ * Sets custom function that fires when user presses escape key.
137
+ */
138
+ setEscapeHandler: function _setEscapeHandler() {
139
+ this.dialog.setEscapeHandler(_ref => {
140
+ let {
141
+ resolve
142
+ } = _ref;
143
+ this.handleDialogClose();
144
+ resolve();
145
+ });
146
+ },
147
+ /**
148
+ * Handles the dialog closing and destruction of it.
149
+ */
150
+ handleDialogClose: function _handleDialogClose() {
151
+ this.dialog.close();
152
+ this.dialog.destroy();
153
+ },
154
+ /**
155
+ * Function that handles runtime thrown errors with MessageToast
156
+ *
157
+ * @param e error instance
158
+ * @throws {Error}.
159
+ */
160
+ handleError: function _handleError(e) {
161
+ const error = getError(e);
162
+ MessageToast.show(error.message, {
163
+ duration: 5000
164
+ });
165
+ throw error;
166
+ },
167
+ /**
168
+ * Handles the index field whenever a specific aggregation is chosen
169
+ *
170
+ * @param specialIndexAggregation string | number
171
+ */
172
+ specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
173
+ const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
174
+ const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
175
+ if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
176
+ const controlType = this.runtimeControl.getMetadata().getName();
177
+ this.model.setProperty('/indexHandlingFlag', false);
178
+ this.model.setProperty('/specialIndexHandlingIcon', true);
179
+ this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
180
+ } else {
181
+ this.model.setProperty('/indexHandlingFlag', true);
182
+ this.model.setProperty('/specialIndexHandlingIcon', false);
183
+ this.model.setProperty('/specialIndexHandlingIconPressed', false);
184
+ }
185
+ }
186
+ });
187
+ return BaseDialog;
188
188
  });
189
189
  //# sourceMappingURL=BaseDialog.controller.js.map