@sap-ux/preview-middleware 0.13.27 → 0.13.28

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.
@@ -23,6 +23,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
23
23
  this.ui5Version = sap.ui.version;
24
24
  this.commandExecutor = new CommandExecutor(this.rta);
25
25
  },
26
+ /**
27
+ * Setups the Dialog and the JSON Model
28
+ *
29
+ * @param {Dialog} dialog - Dialog instance
30
+ */
26
31
  setup: async function _setup(dialog) {
27
32
  this.dialog = dialog;
28
33
  this.setEscapeHandler();
@@ -30,6 +35,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
30
35
  this.dialog.setModel(this.model);
31
36
  this.dialog.open();
32
37
  },
38
+ /**
39
+ * Handles the index field whenever a specific aggregation is chosen
40
+ *
41
+ * @param specialIndexAggregation string | number
42
+ */
33
43
  specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
34
44
  const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
35
45
  const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
@@ -44,6 +54,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
44
54
  this.model.setProperty('/specialIndexHandlingIconPressed', false);
45
55
  }
46
56
  },
57
+ /**
58
+ * Handles the change in aggregations
59
+ *
60
+ * @param event Event
61
+ */
47
62
  onAggregationChanged: function _onAggregationChanged(event) {
48
63
  const source = event.getSource();
49
64
  const selectedKey = source.getSelectedKey();
@@ -63,6 +78,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
63
78
  this.model.setProperty('/index', updatedIndexArray);
64
79
  this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
65
80
  },
81
+ /**
82
+ * Handles create button press
83
+ *
84
+ * @param event Event
85
+ */
66
86
  onCreateBtnPress: async function _onCreateBtnPress(event) {
67
87
  const source = event.getSource();
68
88
  source.setEnabled(false);
@@ -78,6 +98,9 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
78
98
  notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
79
99
  this.handleDialogClose();
80
100
  },
101
+ /**
102
+ * Builds data that is used in the dialog
103
+ */
81
104
  buildDialogData: async function _buildDialogData() {
82
105
  const selectorId = this.overlays.getId();
83
106
  let controlMetadata;
@@ -138,6 +161,12 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
138
161
  this.model.setProperty('/targetAggregation', controlAggregation);
139
162
  this.model.setProperty('/index', indexArray);
140
163
  },
164
+ /**
165
+ * Fills indexArray from selected control children
166
+ *
167
+ * @param selectedControlChildren Array of numbers
168
+ * @returns Array of key value pairs
169
+ */
141
170
  fillIndexArray: function _fillIndexArray(selectedControlChildren) {
142
171
  let indexArray = [];
143
172
  if (selectedControlChildren.length === 0) {
@@ -163,6 +192,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
163
192
  }
164
193
  return indexArray;
165
194
  },
195
+ /**
196
+ * Creates an addXML fragment command and pushes it to the command stack
197
+ *
198
+ * @param fragmentData Fragment Data
199
+ */
166
200
  createFragmentChange: async function _createFragmentChange(fragmentData) {
167
201
  const {
168
202
  fragmentName,
@@ -9,6 +9,11 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"],
9
9
  * @namespace open.ux.preview.client.adp.controllers
10
10
  */
11
11
  const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
12
+ /**
13
+ * Handles fragment name input change
14
+ *
15
+ * @param event Event
16
+ */
12
17
  onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
13
18
  const input = event.getSource();
14
19
  const beginBtn = this.dialog.getBeginButton();
@@ -46,6 +51,12 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"],
46
51
  updateDialogState(ValueState.Success);
47
52
  this.model.setProperty('/newFragmentName', fragmentName);
48
53
  },
54
+ /**
55
+ * Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
56
+ *
57
+ * @param {string} fragmentName - The name of the fragment to check for existing changes.
58
+ * @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
59
+ */
49
60
  checkForExistingChange: function _checkForExistingChange(fragmentName) {
50
61
  const allCommands = this.rta.getCommandStack().getCommands();
51
62
  return allCommands.some(command => {
@@ -57,6 +68,9 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"],
57
68
  }
58
69
  });
59
70
  },
71
+ /**
72
+ * Sets custom function that fires when user presses escape key.
73
+ */
60
74
  setEscapeHandler: function _setEscapeHandler() {
61
75
  this.dialog.setEscapeHandler(_ref => {
62
76
  let {
@@ -66,6 +80,9 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"],
66
80
  resolve();
67
81
  });
68
82
  },
83
+ /**
84
+ * Handles the dialog closing and destruction of it.
85
+ */
69
86
  handleDialogClose: function _handleDialogClose() {
70
87
  this.dialog.close();
71
88
  this.dialog.destroy();
@@ -25,6 +25,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
25
25
  this.overlays = overlays;
26
26
  this.model = new JSONModel();
27
27
  },
28
+ /**
29
+ * Setups the Dialog and the JSON Model
30
+ *
31
+ * @param {Dialog} dialog - Dialog instance
32
+ */
28
33
  setup: async function _setup(dialog) {
29
34
  this.dialog = dialog;
30
35
  this.setEscapeHandler();
@@ -32,6 +37,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
32
37
  this.dialog.setModel(this.model);
33
38
  this.dialog.open();
34
39
  },
40
+ /**
41
+ * Handles fragment name input change
42
+ *
43
+ * @param event Event
44
+ */
35
45
  onControllerNameInputChange: function _onControllerNameInputChange(event) {
36
46
  const input = event.getSource();
37
47
  const beginBtn = this.dialog.getBeginButton();
@@ -64,6 +74,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
64
74
  updateDialogState(ValueState.Success);
65
75
  this.model.setProperty('/newControllerName', controllerName);
66
76
  },
77
+ /**
78
+ * Handles create button press
79
+ *
80
+ * @param event Event
81
+ */
67
82
  onCreateBtnPress: async function _onCreateBtnPress(event) {
68
83
  const source = event.getSource();
69
84
  const controllerExists = this.model.getProperty('/controllerExists');
@@ -78,6 +93,9 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
78
93
  }
79
94
  this.handleDialogClose();
80
95
  },
96
+ /**
97
+ * Builds data that is used in the dialog.
98
+ */
81
99
  buildDialogData: async function _buildDialogData() {
82
100
  const selectorId = this.overlays.getId();
83
101
  const overlayControl = sap.ui.getCore().byId(selectorId);
@@ -98,6 +116,12 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
98
116
  await this.getControllers();
99
117
  }
100
118
  },
119
+ /**
120
+ * Gets controller name and view ID for the given overlay control.
121
+ *
122
+ * @param overlayControl The overlay control.
123
+ * @returns The controller name and view ID.
124
+ */
101
125
  getControllerInfo: function _getControllerInfo(overlayControl) {
102
126
  const control = overlayControl.getElement();
103
127
  const view = Utils.getViewForControl(control);
@@ -108,6 +132,14 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
108
132
  viewId
109
133
  };
110
134
  },
135
+ /**
136
+ * Updates the model properties for an existing controller.
137
+ *
138
+ * @param {boolean} controllerExists - Whether the controller exists.
139
+ * @param {string} controllerPath - The controller path.
140
+ * @param {string} controllerPathFromRoot - The controller path from the project root.
141
+ * @param {boolean} isRunningInBAS - Whether the environment is BAS or VS Code.
142
+ */
111
143
  updateModelForExistingController: function _updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS) {
112
144
  this.model.setProperty('/controllerExists', controllerExists);
113
145
  this.model.setProperty('/controllerPath', controllerPath);
@@ -124,9 +156,20 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
124
156
  }
125
157
  this.dialog.getEndButton().setText('Close');
126
158
  },
159
+ /**
160
+ * Updates the model property for a new controller.
161
+ *
162
+ * @param viewId The view ID
163
+ */
127
164
  updateModelForNewController: function _updateModelForNewController(viewId) {
128
165
  this.model.setProperty('/viewId', viewId);
129
166
  },
167
+ /**
168
+ * Retrieves existing controller data if found in the project's workspace.
169
+ *
170
+ * @param controllerName Controller name that exists in the view
171
+ * @returns Returnsexisting controller data
172
+ */
130
173
  getExistingController: async function _getExistingController(controllerName) {
131
174
  try {
132
175
  const data = await getExistingController(controllerName);
@@ -138,6 +181,9 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
138
181
  throw new Error(e.message);
139
182
  }
140
183
  },
184
+ /**
185
+ * Retrieves controller files and fills the model with data
186
+ */
141
187
  getControllers: async function _getControllers() {
142
188
  try {
143
189
  const {
@@ -151,6 +197,12 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
151
197
  throw new Error(e.message);
152
198
  }
153
199
  },
200
+ /**
201
+ * Creates a new fragment for the specified control
202
+ *
203
+ * @param controllerName Controller Name
204
+ * @param viewId View Id
205
+ */
154
206
  createNewController: async function _createNewController(controllerName, viewId) {
155
207
  try {
156
208
  const manifest = await getManifestAppdescr();
@@ -19,6 +19,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
19
19
  this.data = data;
20
20
  this.rta = rta;
21
21
  },
22
+ /**
23
+ * Setups the Dialog and the JSON Model
24
+ *
25
+ * @param {Dialog} dialog - Dialog instance
26
+ */
22
27
  setup: async function _setup(dialog) {
23
28
  this.dialog = dialog;
24
29
  this.setEscapeHandler();
@@ -26,6 +31,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
26
31
  this.dialog.setModel(this.model);
27
32
  this.dialog.open();
28
33
  },
34
+ /**
35
+ * Handles create button press
36
+ *
37
+ * @param event Event
38
+ */
29
39
  onCreateBtnPress: function _onCreateBtnPress(event) {
30
40
  const source = event.getSource();
31
41
  source.setEnabled(false);
@@ -34,6 +44,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
34
44
  notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
35
45
  this.handleDialogClose();
36
46
  },
47
+ /**
48
+ * Handler for extension point select control
49
+ *
50
+ * @param event Select control change event
51
+ */
37
52
  onExtensionPointHandler: function _onExtensionPointHandler(event) {
38
53
  const source = event.getSource();
39
54
  const selectedItem = source.getSelectedItem();
@@ -43,6 +58,9 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
43
58
  }
44
59
  this.model.setProperty('/extensionPointName', extensionPointName);
45
60
  },
61
+ /**
62
+ * Builds data that is used in the dialog
63
+ */
46
64
  buildDialogData: async function _buildDialogData() {
47
65
  const name = this.data?.name;
48
66
  if (name) {
@@ -71,12 +89,25 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
71
89
  throw new Error(e.message);
72
90
  }
73
91
  },
92
+ /**
93
+ * Updates the Select control according to provided values
94
+ *
95
+ * @param name Extension point name
96
+ * @param key Selected extension point key
97
+ * @param list All of the extension points that are under a view
98
+ * @param enabled Enables the select control
99
+ */
74
100
  updateModel: function _updateModel(name, key, list, enabled) {
75
101
  this.model.setProperty('/extensionPointName', name);
76
102
  this.model.setProperty('/extensionPointKey', key);
77
103
  this.model.setProperty('/extensionPointList', list);
78
104
  this.model.setProperty('/extensionListEnabled', enabled);
79
105
  },
106
+ /**
107
+ * Creates add xml at extension point changes
108
+ *
109
+ * @param fragmentName Fragment name
110
+ */
80
111
  createExtensionPointFragmentChange: function _createExtensionPointFragmentChange(fragmentName) {
81
112
  const extensionPointName = this.model.getProperty('/extensionPointName');
82
113
  const modifiedValue = {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.13.27",
12
+ "version": "0.13.28",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.5.1",
29
29
  "@sap-ux/btp-utils": "0.14.4",
30
- "@sap-ux/adp-tooling": "0.9.26",
30
+ "@sap-ux/adp-tooling": "0.9.27",
31
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.19",
32
32
  "@sap-ux/project-access": "1.19.14"
33
33
  },
@@ -46,7 +46,7 @@
46
46
  "@sap-ux-private/playwright": "0.0.3",
47
47
  "dotenv": "16.3.1",
48
48
  "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.8",
49
- "@sap-ux/axios-extension": "1.11.9",
49
+ "@sap-ux/axios-extension": "1.12.0",
50
50
  "@sap-ux/store": "0.5.0",
51
51
  "@sap-ux/i18n": "0.0.6"
52
52
  },