@sap-ux/preview-middleware 0.11.36 → 0.12.0

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 (50) hide show
  1. package/dist/base/flp.d.ts +8 -2
  2. package/dist/base/flp.js +28 -19
  3. package/dist/client/adp/api-handler.js +141 -141
  4. package/dist/client/adp/command-executor.js +54 -41
  5. package/dist/client/adp/command-executor.ts +18 -4
  6. package/dist/client/adp/control-utils.js +44 -44
  7. package/dist/client/adp/controllers/AddFragment.controller.js +206 -203
  8. package/dist/client/adp/controllers/AddFragment.controller.ts +11 -5
  9. package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
  10. package/dist/client/adp/controllers/BaseDialog.controller.ts +8 -2
  11. package/dist/client/adp/controllers/ControllerExtension.controller.js +174 -173
  12. package/dist/client/adp/controllers/ControllerExtension.controller.ts +10 -6
  13. package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
  14. package/dist/client/adp/controllers/ExtensionPoint.controller.ts +8 -6
  15. package/dist/client/adp/init-dialogs.js +74 -73
  16. package/dist/client/adp/init-dialogs.ts +13 -8
  17. package/dist/client/adp/init.js +23 -7
  18. package/dist/client/adp/init.ts +14 -6
  19. package/dist/client/adp/ui/AddFragment.fragment.xml +69 -0
  20. package/dist/client/adp/ui/ControllerExtension.fragment.xml +51 -0
  21. package/dist/client/adp/ui/ExtensionPoint.fragment.xml +51 -0
  22. package/dist/client/adp/ui5-version-utils.js +63 -63
  23. package/dist/client/adp/utils.js +33 -33
  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 +35 -35
  27. package/dist/client/cpe/documentation.js +164 -164
  28. package/dist/client/cpe/logger.js +30 -30
  29. package/dist/client/cpe/outline/nodes.js +84 -84
  30. package/dist/client/cpe/outline/utils.js +37 -37
  31. package/dist/client/cpe/types.js +4 -4
  32. package/dist/client/cpe/ui5-utils.js +49 -49
  33. package/dist/client/cpe/utils.js +48 -48
  34. package/dist/client/flp/WorkspaceConnector.js +69 -77
  35. package/dist/client/flp/WorkspaceConnector.ts +5 -25
  36. package/dist/client/flp/common.js +30 -0
  37. package/dist/client/flp/common.ts +26 -0
  38. package/dist/client/flp/enableFakeConnector.js +79 -0
  39. package/dist/client/flp/enableFakeConnector.ts +93 -0
  40. package/dist/client/flp/init.js +212 -204
  41. package/dist/client/flp/init.ts +27 -11
  42. package/dist/client/flp/initConnectors.js +35 -0
  43. package/dist/client/flp/initConnectors.ts +30 -0
  44. package/dist/client/flp/initRta.js +180 -0
  45. package/dist/client/flp/initRta.ts +193 -0
  46. package/package.json +4 -3
  47. package/templates/flp/sandbox.html +7 -1
  48. package/dist/client/adp/ui/AddFragment.view.xml +0 -68
  49. package/dist/client/adp/ui/ControllerExtension.view.xml +0 -49
  50. package/dist/client/adp/ui/ExtensionPoint.view.xml +0 -49
@@ -1,205 +1,208 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../control-utils", "../command-executor", "../api-handler", "./BaseDialog.controller"], function (MessageToast, JSONModel, OverlayRegistry, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog) {
4
- "use strict";
5
-
6
- function _interopRequireDefault(obj) {
7
- return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
- }
9
- const ControlUtils = _interopRequireDefault(__ControlUtils);
10
- const CommandExecutor = _interopRequireDefault(__CommandExecutor);
11
- const getFragments = ___api_handler["getFragments"];
12
- const writeFragment = ___api_handler["writeFragment"];
13
- const BaseDialog = _interopRequireDefault(__BaseDialog);
14
- /**
15
- * @namespace open.ux.preview.client.adp.controllers
16
- */
17
- const AddFragment = BaseDialog.extend("open.ux.preview.client.adp.controllers.AddFragment", {
18
- constructor: function _constructor(name, overlays, rta) {
19
- BaseDialog.prototype.constructor.call(this, name);
20
- this.rta = rta;
21
- this.overlays = overlays;
22
- this.model = new JSONModel();
23
- this.commandExecutor = new CommandExecutor(this.rta);
24
- },
25
- onInit: async function _onInit() {
26
- this.dialog = this.byId('addNewFragmentDialog');
27
- this.setEscapeHandler();
28
- await this.buildDialogData();
29
- this.getView()?.setModel(this.model);
30
- this.dialog.open();
31
- },
32
- specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
33
- const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
34
- const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
35
- if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
36
- const controlType = this.runtimeControl.getMetadata().getName();
37
- this.model.setProperty('/indexHandlingFlag', false);
38
- this.model.setProperty('/specialIndexHandlingIcon', true);
39
- this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
40
- } else {
41
- this.model.setProperty('/indexHandlingFlag', true);
42
- this.model.setProperty('/specialIndexHandlingIcon', false);
43
- this.model.setProperty('/specialIndexHandlingIconPressed', false);
44
- }
45
- },
46
- onAggregationChanged: function _onAggregationChanged(event) {
47
- const source = event.getSource();
48
- const selectedKey = source.getSelectedKey();
49
- const selectedItem = source.getSelectedItem();
50
- let selectedItemText = '';
51
- if (selectedItem) {
52
- selectedItemText = selectedItem.getText();
53
- }
54
- this.model.setProperty('/selectedAggregation/key', selectedKey);
55
- this.model.setProperty('/selectedAggregation/value', selectedItemText);
56
- let newSelectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, selectedItemText));
57
- newSelectedControlChildren = newSelectedControlChildren.map(key => {
58
- return parseInt(key);
59
- });
60
- this.specialIndexHandling(selectedItemText);
61
- const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
62
- this.model.setProperty('/index', updatedIndexArray);
63
- this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
64
- },
65
- onCreateBtnPress: async function _onCreateBtnPress(event) {
66
- const source = event.getSource();
67
- source.setEnabled(false);
68
- const fragmentName = this.model.getProperty('/newFragmentName');
69
- const index = parseInt(this.model.getProperty('/selectedIndex'));
70
- const targetAggregation = this.model.getProperty('/selectedAggregation/value');
71
- const fragmentData = {
72
- index,
73
- fragmentName,
74
- targetAggregation
75
- };
76
- await this.createNewFragment(fragmentData);
77
- this.handleDialogClose();
78
- },
79
- buildDialogData: async function _buildDialogData() {
80
- const selectorId = this.overlays.getId();
81
- let controlMetadata;
82
- const overlayControl = sap.ui.getCore().byId(selectorId);
83
- if (overlayControl) {
84
- this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
85
- controlMetadata = this.runtimeControl.getMetadata();
86
- } else {
87
- throw new Error('Cannot get overlay control');
88
- }
89
- const allAggregations = Object.keys(controlMetadata.getAllAggregations());
90
- const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
91
- const targetAggregation = allAggregations.filter(item => {
92
- if (hiddenAggregations.indexOf(item) === -1) {
93
- return item;
94
- }
95
- return false;
96
- });
97
- const defaultAggregation = controlMetadata.getDefaultAggregationName();
98
- const selectedControlName = controlMetadata.getName();
99
- let selectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation));
100
- selectedControlChildren = selectedControlChildren.map(key => {
101
- return parseInt(key);
102
- });
103
- this.model.setProperty('/selectedControlName', selectedControlName);
104
- this.model.setProperty('/selectedAggregation', {});
105
- const indexArray = this.fillIndexArray(selectedControlChildren);
106
- const controlAggregation = targetAggregation.map((elem, index) => {
107
- return {
108
- key: index,
109
- value: elem
110
- };
111
- });
112
- if (defaultAggregation !== null) {
113
- controlAggregation.forEach(obj => {
114
- if (obj.value === defaultAggregation) {
115
- obj.key = 'default';
116
- this.model.setProperty('/selectedAggregation/key', obj.key);
117
- this.model.setProperty('/selectedAggregation/value', obj.value);
118
- this.specialIndexHandling(obj.value);
119
- }
120
- });
121
- } else {
122
- this.model.setProperty('/selectedAggregation/key', controlAggregation[0].key);
123
- this.model.setProperty('/selectedAggregation/value', controlAggregation[0].value);
124
- this.specialIndexHandling(controlAggregation[0].value);
125
- }
126
- try {
127
- const {
128
- fragments
129
- } = await getFragments();
130
- this.model.setProperty('/fragmentList', fragments);
131
- } catch (e) {
132
- MessageToast.show(e.message);
133
- throw new Error(e.message);
134
- }
135
- this.model.setProperty('/selectedIndex', indexArray.length - 1);
136
- this.model.setProperty('/targetAggregation', controlAggregation);
137
- this.model.setProperty('/index', indexArray);
138
- },
139
- fillIndexArray: function _fillIndexArray(selectedControlChildren) {
140
- let indexArray = [];
141
- if (selectedControlChildren.length === 0) {
142
- indexArray.push({
143
- key: 0,
144
- value: 0
145
- });
146
- } else {
147
- indexArray = selectedControlChildren.map((elem, index) => {
148
- return {
149
- key: index + 1,
150
- value: elem + 1
151
- };
152
- });
153
- indexArray.unshift({
154
- key: 0,
155
- value: 0
156
- });
157
- indexArray.push({
158
- key: selectedControlChildren.length + 1,
159
- value: selectedControlChildren.length + 1
160
- });
161
- }
162
- return indexArray;
163
- },
164
- createNewFragment: async function _createNewFragment(fragmentData) {
165
- const {
166
- fragmentName,
167
- index,
168
- targetAggregation
169
- } = fragmentData;
170
- try {
171
- await writeFragment({
172
- fragmentName
173
- });
174
- MessageToast.show(`Fragment with name '${fragmentName}' was created.`);
175
- } catch (e) {
176
- // In case of error when creating a new fragment, we should not create a change file
177
- MessageToast.show(e.message);
178
- throw new Error(e.message);
179
- }
180
- await this.createFragmentChange({
181
- fragmentName,
182
- index,
183
- targetAggregation
184
- });
185
- },
186
- createFragmentChange: async function _createFragmentChange(fragmentData) {
187
- const {
188
- fragmentName,
189
- index,
190
- targetAggregation
191
- } = fragmentData;
192
- const flexSettings = this.rta.getFlexSettings();
193
- const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
194
- const designMetadata = overlay.getDesignTimeMetadata();
195
- const modifiedValue = {
196
- fragmentPath: `fragments/${fragmentName}.fragment.xml`,
197
- index: index ?? 0,
198
- targetAggregation: targetAggregation ?? 'content'
199
- };
200
- await this.commandExecutor.generateAndExecuteCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
201
- }
202
- });
203
- return AddFragment;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../control-utils", "../command-executor", "../api-handler", "./BaseDialog.controller"], function (MessageToast, JSONModel, OverlayRegistry, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog) {
4
+ "use strict";
5
+
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
+ }
9
+ const ControlUtils = _interopRequireDefault(__ControlUtils);
10
+ const CommandExecutor = _interopRequireDefault(__CommandExecutor);
11
+ const getFragments = ___api_handler["getFragments"];
12
+ const writeFragment = ___api_handler["writeFragment"];
13
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
14
+ /**
15
+ * @namespace open.ux.preview.client.adp.controllers
16
+ */
17
+ const AddFragment = BaseDialog.extend("open.ux.preview.client.adp.controllers.AddFragment", {
18
+ constructor: function _constructor(name, overlays, rta) {
19
+ BaseDialog.prototype.constructor.call(this, name);
20
+ this.rta = rta;
21
+ this.overlays = overlays;
22
+ this.model = new JSONModel();
23
+ this.ui5Version = sap.ui.version;
24
+ this.commandExecutor = new CommandExecutor(this.rta);
25
+ },
26
+ setup: async function _setup(dialog) {
27
+ this.dialog = dialog;
28
+ this.setEscapeHandler();
29
+ await this.buildDialogData();
30
+ this.dialog.setModel(this.model);
31
+ this.dialog.open();
32
+ },
33
+ specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
34
+ const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
35
+ const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
36
+ if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
37
+ const controlType = this.runtimeControl.getMetadata().getName();
38
+ this.model.setProperty('/indexHandlingFlag', false);
39
+ this.model.setProperty('/specialIndexHandlingIcon', true);
40
+ this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
41
+ } else {
42
+ this.model.setProperty('/indexHandlingFlag', true);
43
+ this.model.setProperty('/specialIndexHandlingIcon', false);
44
+ this.model.setProperty('/specialIndexHandlingIconPressed', false);
45
+ }
46
+ },
47
+ onAggregationChanged: function _onAggregationChanged(event) {
48
+ const source = event.getSource();
49
+ const selectedKey = source.getSelectedKey();
50
+ const selectedItem = source.getSelectedItem();
51
+ let selectedItemText = '';
52
+ if (selectedItem) {
53
+ selectedItemText = selectedItem.getText();
54
+ }
55
+ this.model.setProperty('/selectedAggregation/key', selectedKey);
56
+ this.model.setProperty('/selectedAggregation/value', selectedItemText);
57
+ let newSelectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, selectedItemText));
58
+ newSelectedControlChildren = newSelectedControlChildren.map(key => {
59
+ return parseInt(key);
60
+ });
61
+ this.specialIndexHandling(selectedItemText);
62
+ const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
63
+ this.model.setProperty('/index', updatedIndexArray);
64
+ this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
65
+ },
66
+ onCreateBtnPress: async function _onCreateBtnPress(event) {
67
+ const source = event.getSource();
68
+ source.setEnabled(false);
69
+ const fragmentName = this.model.getProperty('/newFragmentName');
70
+ const index = parseInt(this.model.getProperty('/selectedIndex'));
71
+ const targetAggregation = this.model.getProperty('/selectedAggregation/value');
72
+ const fragmentData = {
73
+ index,
74
+ fragmentName,
75
+ targetAggregation
76
+ };
77
+ await this.createNewFragment(fragmentData);
78
+ this.handleDialogClose();
79
+ },
80
+ buildDialogData: async function _buildDialogData() {
81
+ const selectorId = this.overlays.getId();
82
+ let controlMetadata;
83
+ const overlayControl = sap.ui.getCore().byId(selectorId);
84
+ if (overlayControl) {
85
+ this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
86
+ controlMetadata = this.runtimeControl.getMetadata();
87
+ } else {
88
+ throw new Error('Cannot get overlay control');
89
+ }
90
+ const allAggregations = Object.keys(controlMetadata.getAllAggregations());
91
+ const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
92
+ const targetAggregation = allAggregations.filter(item => {
93
+ if (hiddenAggregations.indexOf(item) === -1) {
94
+ return item;
95
+ }
96
+ return false;
97
+ });
98
+ const defaultAggregation = controlMetadata.getDefaultAggregationName();
99
+ const selectedControlName = controlMetadata.getName();
100
+ let selectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation));
101
+ selectedControlChildren = selectedControlChildren.map(key => {
102
+ return parseInt(key);
103
+ });
104
+ this.model.setProperty('/selectedControlName', selectedControlName);
105
+ this.model.setProperty('/selectedAggregation', {});
106
+ const indexArray = this.fillIndexArray(selectedControlChildren);
107
+ const controlAggregation = targetAggregation.map((elem, index) => {
108
+ return {
109
+ key: index,
110
+ value: elem
111
+ };
112
+ });
113
+ if (defaultAggregation !== null) {
114
+ controlAggregation.forEach(obj => {
115
+ if (obj.value === defaultAggregation) {
116
+ obj.key = 'default';
117
+ this.model.setProperty('/selectedAggregation/key', obj.key);
118
+ this.model.setProperty('/selectedAggregation/value', obj.value);
119
+ this.specialIndexHandling(obj.value);
120
+ }
121
+ });
122
+ } else {
123
+ this.model.setProperty('/selectedAggregation/key', controlAggregation[0].key);
124
+ this.model.setProperty('/selectedAggregation/value', controlAggregation[0].value);
125
+ this.specialIndexHandling(controlAggregation[0].value);
126
+ }
127
+ try {
128
+ const {
129
+ fragments
130
+ } = await getFragments();
131
+ this.model.setProperty('/fragmentList', fragments);
132
+ } catch (e) {
133
+ MessageToast.show(e.message);
134
+ throw new Error(e.message);
135
+ }
136
+ this.model.setProperty('/selectedIndex', indexArray.length - 1);
137
+ this.model.setProperty('/targetAggregation', controlAggregation);
138
+ this.model.setProperty('/index', indexArray);
139
+ },
140
+ fillIndexArray: function _fillIndexArray(selectedControlChildren) {
141
+ let indexArray = [];
142
+ if (selectedControlChildren.length === 0) {
143
+ indexArray.push({
144
+ key: 0,
145
+ value: 0
146
+ });
147
+ } else {
148
+ indexArray = selectedControlChildren.map((elem, index) => {
149
+ return {
150
+ key: index + 1,
151
+ value: elem + 1
152
+ };
153
+ });
154
+ indexArray.unshift({
155
+ key: 0,
156
+ value: 0
157
+ });
158
+ indexArray.push({
159
+ key: selectedControlChildren.length + 1,
160
+ value: selectedControlChildren.length + 1
161
+ });
162
+ }
163
+ return indexArray;
164
+ },
165
+ createNewFragment: async function _createNewFragment(fragmentData) {
166
+ const {
167
+ fragmentName,
168
+ index,
169
+ targetAggregation
170
+ } = fragmentData;
171
+ try {
172
+ await writeFragment({
173
+ fragmentName
174
+ });
175
+ MessageToast.show(`Fragment with name '${fragmentName}' was created.`);
176
+ } catch (e) {
177
+ // In case of error when creating a new fragment, we should not create a change file
178
+ MessageToast.show(e.message);
179
+ throw new Error(e.message);
180
+ }
181
+ await this.createFragmentChange({
182
+ fragmentName,
183
+ index,
184
+ targetAggregation
185
+ });
186
+ },
187
+ createFragmentChange: async function _createFragmentChange(fragmentData) {
188
+ const {
189
+ fragmentName,
190
+ index,
191
+ targetAggregation
192
+ } = fragmentData;
193
+ const flexSettings = this.rta.getFlexSettings();
194
+ const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
195
+ const designMetadata = overlay.getDesignTimeMetadata();
196
+ const modifiedValue = {
197
+ fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
198
+ fragmentPath: `fragments/${fragmentName}.fragment.xml`,
199
+ index: index ?? 0,
200
+ targetAggregation: targetAggregation ?? 'content'
201
+ };
202
+ const command = await this.commandExecutor.getCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
203
+ await this.commandExecutor.pushAndExecuteCommand(command);
204
+ }
205
+ });
206
+ return AddFragment;
204
207
  });
205
208
  //# sourceMappingURL=AddFragment.controller.js.map
@@ -41,20 +41,23 @@ export default class AddFragment extends BaseDialog {
41
41
  this.rta = rta;
42
42
  this.overlays = overlays;
43
43
  this.model = new JSONModel();
44
+ this.ui5Version = sap.ui.version;
44
45
  this.commandExecutor = new CommandExecutor(this.rta);
45
46
  }
46
47
 
47
48
  /**
48
- * Initializes controller, fills model with data and opens the dialog
49
+ * Setups the Dialog and the JSON Model
50
+ *
51
+ * @param {Dialog} dialog - Dialog instance
49
52
  */
50
- async onInit() {
51
- this.dialog = this.byId('addNewFragmentDialog') as unknown as Dialog;
53
+ async setup(dialog: Dialog): Promise<void> {
54
+ this.dialog = dialog;
52
55
 
53
56
  this.setEscapeHandler();
54
57
 
55
58
  await this.buildDialogData();
56
59
 
57
- this.getView()?.setModel(this.model);
60
+ this.dialog.setModel(this.model);
58
61
 
59
62
  this.dialog.open();
60
63
  }
@@ -278,17 +281,20 @@ export default class AddFragment extends BaseDialog {
278
281
  const designMetadata = overlay.getDesignTimeMetadata();
279
282
 
280
283
  const modifiedValue = {
284
+ fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
281
285
  fragmentPath: `fragments/${fragmentName}.fragment.xml`,
282
286
  index: index ?? 0,
283
287
  targetAggregation: targetAggregation ?? 'content'
284
288
  };
285
289
 
286
- await this.commandExecutor.generateAndExecuteCommand(
290
+ const command = await this.commandExecutor.getCommand(
287
291
  this.runtimeControl,
288
292
  'addXML',
289
293
  modifiedValue,
290
294
  designMetadata,
291
295
  flexSettings
292
296
  );
297
+
298
+ await this.commandExecutor.pushAndExecuteCommand(command);
293
299
  }
294
300
  }
@@ -1,59 +1,59 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller"], function (sap_ui_core_library, Controller) {
4
- "use strict";
5
-
6
- const ValueState = sap_ui_core_library["ValueState"];
7
- /**
8
- * @namespace open.ux.preview.client.adp.controllers
9
- */
10
- const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
11
- onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
12
- const input = event.getSource();
13
- const beginBtn = this.dialog.getBeginButton();
14
- const fragmentName = input.getValue();
15
- const fragmentList = this.model.getProperty('/fragmentList');
16
- const updateDialogState = function (valueState) {
17
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
18
- input.setValueState(valueState).setValueStateText(valueStateText);
19
- beginBtn.setEnabled(valueState === ValueState.Success);
20
- };
21
- if (fragmentName.length <= 0) {
22
- updateDialogState(ValueState.None);
23
- this.model.setProperty('/newFragmentName', null);
24
- return;
25
- }
26
- const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
27
- if (fileExists) {
28
- updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
29
- return;
30
- }
31
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
32
- if (!isValidName) {
33
- updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
34
- return;
35
- }
36
- if (fragmentName.length > 64) {
37
- updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
38
- return;
39
- }
40
- updateDialogState(ValueState.Success);
41
- this.model.setProperty('/newFragmentName', fragmentName);
42
- },
43
- setEscapeHandler: function _setEscapeHandler() {
44
- this.dialog.setEscapeHandler(_ref => {
45
- let {
46
- resolve
47
- } = _ref;
48
- this.handleDialogClose();
49
- resolve();
50
- });
51
- },
52
- handleDialogClose: function _handleDialogClose() {
53
- this.dialog.close();
54
- this.getView()?.destroy();
55
- }
56
- });
57
- return BaseDialog;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller"], function (sap_ui_core_library, Controller) {
4
+ "use strict";
5
+
6
+ const ValueState = sap_ui_core_library["ValueState"];
7
+ /**
8
+ * @namespace open.ux.preview.client.adp.controllers
9
+ */
10
+ const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
11
+ onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
12
+ const input = event.getSource();
13
+ const beginBtn = this.dialog.getBeginButton();
14
+ const fragmentName = input.getValue();
15
+ const fragmentList = this.model.getProperty('/fragmentList');
16
+ const updateDialogState = function (valueState) {
17
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
18
+ input.setValueState(valueState).setValueStateText(valueStateText);
19
+ beginBtn.setEnabled(valueState === ValueState.Success);
20
+ };
21
+ if (fragmentName.length <= 0) {
22
+ updateDialogState(ValueState.None);
23
+ this.model.setProperty('/newFragmentName', null);
24
+ return;
25
+ }
26
+ const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
27
+ if (fileExists) {
28
+ updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
29
+ return;
30
+ }
31
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
32
+ if (!isValidName) {
33
+ updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
34
+ return;
35
+ }
36
+ if (fragmentName.length > 64) {
37
+ updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
38
+ return;
39
+ }
40
+ updateDialogState(ValueState.Success);
41
+ this.model.setProperty('/newFragmentName', fragmentName);
42
+ },
43
+ setEscapeHandler: function _setEscapeHandler() {
44
+ this.dialog.setEscapeHandler(_ref => {
45
+ let {
46
+ resolve
47
+ } = _ref;
48
+ this.handleDialogClose();
49
+ resolve();
50
+ });
51
+ },
52
+ handleDialogClose: function _handleDialogClose() {
53
+ this.dialog.close();
54
+ this.dialog.destroy();
55
+ }
56
+ });
57
+ return BaseDialog;
58
58
  });
59
59
  //# sourceMappingURL=BaseDialog.controller.js.map
@@ -34,11 +34,17 @@ export default abstract class BaseDialog extends Controller {
34
34
  * Dialog instance
35
35
  */
36
36
  public dialog: Dialog;
37
+ /**
38
+ * UI5 version
39
+ */
40
+ public ui5Version: string;
37
41
  /**
38
42
  * RTA Command Executor
39
43
  */
40
44
  protected commandExecutor: CommandExecutor;
41
45
 
46
+ abstract setup(dialog: Dialog): Promise<void>;
47
+
42
48
  abstract onCreateBtnPress(event: Event): Promise<void>;
43
49
 
44
50
  abstract buildDialogData(): Promise<void>;
@@ -83,7 +89,7 @@ export default abstract class BaseDialog extends Controller {
83
89
  return;
84
90
  }
85
91
 
86
- if(fragmentName.length > 64) {
92
+ if (fragmentName.length > 64) {
87
93
  updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
88
94
  return;
89
95
  }
@@ -107,6 +113,6 @@ export default abstract class BaseDialog extends Controller {
107
113
  */
108
114
  handleDialogClose() {
109
115
  this.dialog.close();
110
- this.getView()?.destroy();
116
+ this.dialog.destroy();
111
117
  }
112
118
  }