@sap-ux/preview-middleware 0.23.48 → 0.23.50

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 (36) hide show
  1. package/dist/client/adp/command-executor.js +99 -66
  2. package/dist/client/adp/controllers/AddCustomFragment.controller.js +120 -102
  3. package/dist/client/adp/controllers/AddFragment.controller.js +189 -163
  4. package/dist/client/adp/controllers/AddSubpage.controller.js +146 -137
  5. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +230 -188
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +187 -164
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +329 -253
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +158 -114
  9. package/dist/client/adp/extension-point.js +81 -60
  10. package/dist/client/adp/init.js +100 -99
  11. package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +165 -147
  12. package/dist/client/adp/quick-actions/enablement-validator.js +0 -4
  13. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +105 -100
  14. package/dist/client/adp/quick-actions/simple-quick-action-base.js +44 -40
  15. package/dist/client/adp/quick-actions/table-quick-action-base.js +309 -266
  16. package/dist/client/adp/sync-views-utils.js +119 -83
  17. package/dist/client/cpe/changes/flex-change.js +64 -48
  18. package/dist/client/cpe/changes/service.js +492 -367
  19. package/dist/client/cpe/communication-service.js +41 -29
  20. package/dist/client/cpe/connector-service.js +87 -64
  21. package/dist/client/cpe/context-menu-service.js +87 -74
  22. package/dist/client/cpe/control-data.js +353 -263
  23. package/dist/client/cpe/documentation.js +183 -126
  24. package/dist/client/cpe/init.js +69 -75
  25. package/dist/client/cpe/outline/service.js +60 -45
  26. package/dist/client/cpe/quick-actions/quick-action-definition.js +0 -4
  27. package/dist/client/cpe/quick-actions/quick-action-service.js +154 -129
  28. package/dist/client/cpe/rta-service.js +91 -69
  29. package/dist/client/cpe/selection.js +239 -187
  30. package/dist/client/cpe/types.js +0 -4
  31. package/dist/client/flp/init.js +403 -296
  32. package/dist/client/manifest.json +7 -4
  33. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +444 -370
  34. package/dist/client/utils/info-center-message.js +59 -31
  35. package/dist/client/utils/version.js +128 -72
  36. package/package.json +4 -4
@@ -1,134 +1,191 @@
1
- 'use strict';
2
- sap.ui.define([
3
- './utils',
4
- 'sap/base/Log',
5
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
6
- '../utils/info-center-message',
7
- '../utils/error'
8
- ], function (___utils, Log, ___sap_ux_private_control_property_editor_common, ___utils_info_center_message, ___utils_error) {
9
- 'use strict';
10
- const getLibrary = ___utils['getLibrary'];
11
- const MessageBarType = ___sap_ux_private_control_property_editor_common['MessageBarType'];
12
- const sendInfoCenterMessage = ___utils_info_center_message['sendInfoCenterMessage'];
13
- const FetchError = ___utils_error['FetchError'];
14
- async function getUi5ApiDtMetadata(libName) {
15
- const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
16
- const response = await fetch(libUrl);
17
- if (!response.ok) {
18
- throw new FetchError(response);
19
- }
20
- return response.json();
21
- }
22
- const ui5ApiDtMetadata = new Map();
23
- function loadDefaultLibraries() {
24
- const allData = Promise.all([
25
- getUi5ApiDtMetadata('sap.m'),
26
- getUi5ApiDtMetadata('sap.ui.comp'),
27
- getUi5ApiDtMetadata('sap.ui.core'),
28
- getUi5ApiDtMetadata('sap.f')
29
- ]);
30
- allData.then(res => {
31
- res.forEach(api => {
32
- if (api.library) {
33
- ui5ApiDtMetadata.set(api.library, api);
34
- }
35
- });
36
- }).catch(reason => {
37
- Log.error('Loading Library Failed: ' + reason);
38
- });
1
+ "use strict";
2
+
3
+ sap.ui.define(["./utils", "sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "../utils/info-center-message", "../utils/error"], function (___utils, Log, ___sap_ux_private_control_property_editor_common, ___utils_info_center_message, ___utils_error) {
4
+ "use strict";
5
+
6
+ const getLibrary = ___utils["getLibrary"];
7
+ const MessageBarType = ___sap_ux_private_control_property_editor_common["MessageBarType"];
8
+ const sendInfoCenterMessage = ___utils_info_center_message["sendInfoCenterMessage"];
9
+ const FetchError = ___utils_error["FetchError"];
10
+ /**
11
+ * Get ui5 metadata of given library name.
12
+ *
13
+ * @param libName library name for eg: sap.m
14
+ * @returns Promise<SchemaForApiJsonFiles>
15
+ */
16
+ async function getUi5ApiDtMetadata(libName) {
17
+ const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
18
+ const response = await fetch(libUrl);
19
+ if (!response.ok) {
20
+ throw new FetchError(response);
39
21
  }
40
- function formatHtmlText(sHtml) {
41
- const parts = (sHtml || '').split('<');
42
- let result = '';
43
- for (const part of parts) {
44
- if (!result) {
45
- result = part;
46
- } else {
47
- const indexClosingBracket = part.indexOf('>');
48
- result += indexClosingBracket >= 0 ? part.substring(indexClosingBracket + 1) : `<${ part }`;
49
- }
22
+ return response.json();
23
+ }
24
+
25
+ /**
26
+ * load ui5 controls design time metadata api.json for following libraries
27
+ * sap.m, sap.ui.comp, sap.f, sap.ui.core
28
+ * loading libraries(more in file size) in parallel during initialization.
29
+ * Others (less in file size) are loaded dynamically in getControlMetadata method
30
+ */
31
+ const ui5ApiDtMetadata = new Map();
32
+ function loadDefaultLibraries() {
33
+ const allData = Promise.all([getUi5ApiDtMetadata('sap.m'), getUi5ApiDtMetadata('sap.ui.comp'), getUi5ApiDtMetadata('sap.ui.core'), getUi5ApiDtMetadata('sap.f')]);
34
+ allData.then(res => {
35
+ res.forEach(api => {
36
+ if (api.library) {
37
+ ui5ApiDtMetadata.set(api.library, api);
50
38
  }
51
- return result;
39
+ });
40
+ }).catch(reason => {
41
+ Log.error('Loading Library Failed: ' + reason);
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Format html text.
47
+ *
48
+ * @param sHtml - html string
49
+ * @returns string
50
+ */
51
+ function formatHtmlText(sHtml) {
52
+ // replaced "sHtml.replace(new RegExp('<[^>]*>', 'g')" due to regex runtime vulnerability
53
+ const parts = (sHtml || '').split('<');
54
+ let result = '';
55
+ for (const part of parts) {
56
+ if (!result) {
57
+ result = part;
58
+ } else {
59
+ const indexClosingBracket = part.indexOf('>');
60
+ result += indexClosingBracket >= 0 ? part.substring(indexClosingBracket + 1) : `<${part}`;
61
+ }
52
62
  }
53
- function parseControlMetaModel(controlLibMetadata, controlName) {
54
- const controlInfo = {
55
- baseType: '',
56
- doc: '',
57
- properties: {}
58
- };
59
- const selectedControlMetadata = (controlLibMetadata.symbols ?? []).find(control => control.name === controlName);
60
- if (selectedControlMetadata) {
61
- controlInfo.baseType = selectedControlMetadata.extends;
62
- controlInfo.doc = selectedControlMetadata.description ?? '';
63
- const properties = selectedControlMetadata['ui5-metadata'].properties;
64
- if (properties) {
65
- properties.forEach(prop => {
66
- prop.description = formatHtmlText(prop.description || '');
67
- prop.propertyName = prop.name;
68
- prop.propertyType = prop.type;
69
- if (prop.defaultValue === null || prop.defaultValue === '') {
70
- prop.defaultValue = '-';
71
- }
72
- controlInfo.properties[prop.name] = { ...prop };
73
- });
74
- }
75
- }
76
- return controlInfo;
63
+ return result;
64
+ }
65
+
66
+ /**
67
+ * Method to parse ui5 control metadata.
68
+ *
69
+ * @param controlLibMetadata control library metadata
70
+ * @param controlName name of the control
71
+ * @returns ControlMetadata
72
+ */
73
+ function parseControlMetaModel(controlLibMetadata, controlName) {
74
+ const controlInfo = {
75
+ baseType: '',
76
+ doc: '',
77
+ properties: {}
78
+ };
79
+ const selectedControlMetadata = (controlLibMetadata.symbols ?? []).find(control => control.name === controlName);
80
+ if (selectedControlMetadata) {
81
+ // base type info of control is available on property 'extends'
82
+ controlInfo.baseType = selectedControlMetadata.extends;
83
+ controlInfo.doc = selectedControlMetadata.description ?? '';
84
+ const properties = selectedControlMetadata['ui5-metadata'].properties;
85
+ if (properties) {
86
+ properties.forEach(prop => {
87
+ prop.description = formatHtmlText(prop.description || '');
88
+ prop.propertyName = prop.name;
89
+ prop.propertyType = prop.type;
90
+ if (prop.defaultValue === null || prop.defaultValue === '') {
91
+ prop.defaultValue = '-';
92
+ }
93
+ controlInfo.properties[prop.name] = {
94
+ ...prop
95
+ };
96
+ });
97
+ }
77
98
  }
78
- async function getControlMetadata(controlName, contLibName) {
79
- let result;
80
- let controlLibMetadata = ui5ApiDtMetadata.get(contLibName);
81
- if (controlLibMetadata) {
82
- result = parseControlMetaModel(controlLibMetadata, controlName);
83
- } else {
84
- controlLibMetadata = await getUi5ApiDtMetadata(contLibName);
85
- ui5ApiDtMetadata.set(contLibName, controlLibMetadata);
86
- result = parseControlMetaModel(controlLibMetadata, controlName);
87
- }
88
- return result;
99
+ return controlInfo;
100
+ }
101
+
102
+ /**
103
+ * Get control metadata for a given control.
104
+ *
105
+ * @param controlName name of the control
106
+ * @param contLibName library name of the control
107
+ * @returns Promise<ControlMetadata | undefined>
108
+ */
109
+ async function getControlMetadata(controlName, contLibName) {
110
+ let result;
111
+ let controlLibMetadata = ui5ApiDtMetadata.get(contLibName);
112
+ if (controlLibMetadata) {
113
+ result = parseControlMetaModel(controlLibMetadata, controlName);
114
+ } else {
115
+ controlLibMetadata = await getUi5ApiDtMetadata(contLibName);
116
+ ui5ApiDtMetadata.set(contLibName, controlLibMetadata);
117
+ result = parseControlMetaModel(controlLibMetadata, controlName);
89
118
  }
90
- async function getControlPropertyDocumentation(controlName, contLibName) {
91
- const doc = await getControlMetadata(controlName, contLibName);
92
- if (doc) {
93
- const baseControlType = doc.baseType;
94
- if (baseControlType) {
95
- const baseContLibName = await getLibrary(baseControlType);
96
- if (baseContLibName) {
97
- const baseControlProps = await getControlPropertyDocumentation(baseControlType, baseContLibName);
98
- return {
99
- ...baseControlProps,
100
- ...doc.properties
101
- };
102
- }
103
- }
104
- return { ...doc.properties };
105
- } else {
106
- return undefined;
119
+ return result;
120
+ }
121
+
122
+ /**
123
+ * Get Control Property Documentation for a give control name and control library.
124
+ *
125
+ * @param controlName name of the control
126
+ * @param contLibName library name of the control
127
+ * @returns Promise<Properties | undefined>
128
+ */
129
+ async function getControlPropertyDocumentation(controlName, contLibName) {
130
+ const doc = await getControlMetadata(controlName, contLibName);
131
+ if (doc) {
132
+ const baseControlType = doc.baseType;
133
+ if (baseControlType) {
134
+ const baseContLibName = await getLibrary(baseControlType);
135
+ if (baseContLibName) {
136
+ const baseControlProps = await getControlPropertyDocumentation(baseControlType, baseContLibName);
137
+ return {
138
+ ...baseControlProps,
139
+ ...doc.properties
140
+ };
107
141
  }
142
+ }
143
+ return {
144
+ ...doc.properties
145
+ };
146
+ } else {
147
+ return undefined;
108
148
  }
109
- async function getDocumentation(controlName, contLibName) {
110
- let doc;
111
- try {
112
- doc = await getControlPropertyDocumentation(controlName, contLibName);
113
- } catch (error) {
114
- Log.error(`Error in getting documentation for ${ contLibName }`);
115
- if (error instanceof FetchError && error.status === 404) {
116
- return undefined;
117
- }
118
- await sendInfoCenterMessage({
119
- title: { key: 'DOCUMENTATION_ERROR_TITLE' },
120
- description: {
121
- key: 'DOCUMENTATION_ERROR_DESCRIPTION',
122
- params: [contLibName]
123
- },
124
- type: MessageBarType.error
125
- });
126
- }
127
- return doc;
149
+ }
150
+
151
+ /**
152
+ * Get documentation of a given control of a ui5 library.
153
+ *
154
+ * @param controlName name of the control.
155
+ * @param contLibName library name of the control
156
+ * @returns Promise<Properties | undefined>
157
+ */
158
+ async function getDocumentation(controlName, contLibName) {
159
+ let doc;
160
+ try {
161
+ doc = await getControlPropertyDocumentation(controlName, contLibName);
162
+ } catch (error) {
163
+ Log.error(`Error in getting documentation for ${contLibName}`);
164
+ // For some UI5 components we do not have an api.json provided instead 404, not found,
165
+ // response is retuned from the server. For such components we do not want to
166
+ // flood the info center with errors.
167
+ if (error instanceof FetchError && error.status === 404) {
168
+ return undefined;
169
+ }
170
+ await sendInfoCenterMessage({
171
+ title: {
172
+ key: 'DOCUMENTATION_ERROR_TITLE'
173
+ },
174
+ description: {
175
+ key: 'DOCUMENTATION_ERROR_DESCRIPTION',
176
+ params: [contLibName]
177
+ },
178
+ type: MessageBarType.error
179
+ });
128
180
  }
129
- var __exports = { __esModule: true };
130
- __exports.getUi5ApiDtMetadata = getUi5ApiDtMetadata;
131
- __exports.loadDefaultLibraries = loadDefaultLibraries;
132
- __exports.getDocumentation = getDocumentation;
133
- return __exports;
134
- });
181
+ return doc;
182
+ }
183
+ var __exports = {
184
+ __esModule: true
185
+ };
186
+ __exports.getUi5ApiDtMetadata = getUi5ApiDtMetadata;
187
+ __exports.loadDefaultLibraries = loadDefaultLibraries;
188
+ __exports.getDocumentation = getDocumentation;
189
+ return __exports;
190
+ });
191
+ //# sourceMappingURL=documentation.js.map
@@ -1,76 +1,70 @@
1
- 'use strict';
2
- sap.ui.define([
3
- 'sap/base/Log',
4
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
- '../utils/error',
6
- './changes/service',
7
- './communication-service',
8
- './connector-service',
9
- './context-menu-service',
10
- './documentation',
11
- './outline/service',
12
- './quick-actions/quick-action-service',
13
- './rta-service',
14
- './selection',
15
- './ui5-utils'
16
- ], function (Log, ___sap_ux_private_control_property_editor_common, ___utils_error, ___changes_service, ___communication_service, ___connector_service, ___context_menu_service, ___documentation, ___outline_service, ___quick_actions_quick_action_service, ___rta_service, ___selection, ___ui5_utils) {
17
- 'use strict';
18
- const appLoaded = ___sap_ux_private_control_property_editor_common['appLoaded'];
19
- const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
20
- const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
21
- const getError = ___utils_error['getError'];
22
- const ChangeService = ___changes_service['ChangeService'];
23
- const CommunicationService = ___communication_service['CommunicationService'];
24
- const WorkspaceConnectorService = ___connector_service['WorkspaceConnectorService'];
25
- const ContextMenuService = ___context_menu_service['ContextMenuService'];
26
- const loadDefaultLibraries = ___documentation['loadDefaultLibraries'];
27
- const OutlineService = ___outline_service['OutlineService'];
28
- const QuickActionService = ___quick_actions_quick_action_service['QuickActionService'];
29
- const RtaService = ___rta_service['RtaService'];
30
- const SelectionService = ___selection['SelectionService'];
31
- const getIcons = ___ui5_utils['getIcons'];
32
- function init(rta) {
33
- let registries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
34
- Log.info('Initializing Control Property Editor');
35
- const flexSettings = rta.getFlexSettings();
36
- if (flexSettings.telemetry === true) {
37
- enableTelemetry();
38
- }
39
- function subscribe(handler) {
40
- CommunicationService.subscribe(handler);
41
- }
42
- const rtaService = new RtaService(rta);
43
- const changesService = new ChangeService({ rta });
44
- const selectionService = new SelectionService(rta, changesService);
45
- const connectorService = new WorkspaceConnectorService();
46
- const contextMenuService = new ContextMenuService(rta);
47
- const outlineService = new OutlineService(rta, changesService);
48
- const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
49
- const services = [
50
- connectorService,
51
- selectionService,
52
- changesService,
53
- contextMenuService,
54
- outlineService,
55
- rtaService,
56
- quickActionService
57
- ];
58
- try {
59
- loadDefaultLibraries();
60
- const allPromises = services.map(service => {
61
- return service.init(CommunicationService.sendAction, subscribe)?.catch(error => {
62
- Log.error('Service Initialization Failed: ', getError(error));
63
- });
64
- });
65
- Promise.all(allPromises).then(() => {
66
- CommunicationService.sendAction(appLoaded());
67
- }).catch(Log.error);
68
- const icons = getIcons();
69
- CommunicationService.sendAction(iconsLoaded(icons));
70
- } catch (error) {
71
- Log.error('Error during initialization of Control Property Editor', getError(error));
72
- }
73
- return Promise.resolve();
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "../utils/error", "./changes/service", "./communication-service", "./connector-service", "./context-menu-service", "./documentation", "./outline/service", "./quick-actions/quick-action-service", "./rta-service", "./selection", "./ui5-utils"], function (Log, ___sap_ux_private_control_property_editor_common, ___utils_error, ___changes_service, ___communication_service, ___connector_service, ___context_menu_service, ___documentation, ___outline_service, ___quick_actions_quick_action_service, ___rta_service, ___selection, ___ui5_utils) {
4
+ "use strict";
5
+
6
+ const appLoaded = ___sap_ux_private_control_property_editor_common["appLoaded"];
7
+ const enableTelemetry = ___sap_ux_private_control_property_editor_common["enableTelemetry"];
8
+ const iconsLoaded = ___sap_ux_private_control_property_editor_common["iconsLoaded"];
9
+ const getError = ___utils_error["getError"];
10
+ const ChangeService = ___changes_service["ChangeService"];
11
+ const CommunicationService = ___communication_service["CommunicationService"];
12
+ const WorkspaceConnectorService = ___connector_service["WorkspaceConnectorService"];
13
+ const ContextMenuService = ___context_menu_service["ContextMenuService"];
14
+ const loadDefaultLibraries = ___documentation["loadDefaultLibraries"];
15
+ const OutlineService = ___outline_service["OutlineService"];
16
+ const QuickActionService = ___quick_actions_quick_action_service["QuickActionService"];
17
+ const RtaService = ___rta_service["RtaService"];
18
+ const SelectionService = ___selection["SelectionService"];
19
+ const getIcons = ___ui5_utils["getIcons"];
20
+ function init(rta) {
21
+ let registries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
22
+ Log.info('Initializing Control Property Editor');
23
+
24
+ // enable telemetry if requested
25
+ const flexSettings = rta.getFlexSettings();
26
+ if (flexSettings.telemetry === true) {
27
+ enableTelemetry();
74
28
  }
75
- return init;
76
- });
29
+
30
+ /**
31
+ *
32
+ * @param handler action handler
33
+ */
34
+ function subscribe(handler) {
35
+ CommunicationService.subscribe(handler);
36
+ }
37
+ const rtaService = new RtaService(rta);
38
+ const changesService = new ChangeService({
39
+ rta
40
+ });
41
+ const selectionService = new SelectionService(rta, changesService);
42
+ const connectorService = new WorkspaceConnectorService();
43
+ const contextMenuService = new ContextMenuService(rta);
44
+ const outlineService = new OutlineService(rta, changesService);
45
+ const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
46
+ const services = [connectorService, selectionService, changesService, contextMenuService, outlineService, rtaService, quickActionService];
47
+ try {
48
+ loadDefaultLibraries();
49
+ const allPromises = services.map(service => {
50
+ return service.init(CommunicationService.sendAction, subscribe)?.catch(error => {
51
+ Log.error('Service Initialization Failed: ', getError(error));
52
+ });
53
+ });
54
+ Promise.all(allPromises).then(() => {
55
+ CommunicationService.sendAction(appLoaded());
56
+ })
57
+ // eslint-disable-next-line @typescript-eslint/unbound-method
58
+ .catch(Log.error);
59
+ const icons = getIcons();
60
+ CommunicationService.sendAction(iconsLoaded(icons));
61
+ } catch (error) {
62
+ Log.error('Error during initialization of Control Property Editor', getError(error));
63
+ }
64
+
65
+ // * This is returned immediately to avoid promise deadlock, preventing services from waiting indefinitely.
66
+ return Promise.resolve();
67
+ }
68
+ return init;
69
+ });
70
+ //# sourceMappingURL=init.js.map
@@ -1,47 +1,62 @@
1
- 'use strict';
2
- sap.ui.define([
3
- 'sap/base/Log',
4
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
- '../../utils/error',
6
- './nodes'
7
- ], function (Log, ___sap_ux_private_control_property_editor_common, ____utils_error, ___nodes) {
8
- 'use strict';
9
- const outlineChanged = ___sap_ux_private_control_property_editor_common['outlineChanged'];
10
- const getError = ____utils_error['getError'];
11
- const transformNodes = ___nodes['transformNodes'];
12
- const OUTLINE_CHANGE_EVENT = 'OUTLINE_CHANGED';
13
- class OutlineService extends EventTarget {
14
- constructor(rta, changeService) {
15
- super();
16
- this.rta = rta;
17
- this.changeService = changeService;
18
- }
19
- async init(sendAction) {
20
- const outline = await this.rta.getService('outline');
21
- const {scenario} = this.rta.getFlexSettings();
22
- const syncOutline = async () => {
23
- try {
24
- const viewNodes = await outline.get();
25
- const controlIndex = {};
26
- const configPropertyIdMap = new Map();
27
- const outlineNodes = await transformNodes(viewNodes, scenario, controlIndex, this.changeService, configPropertyIdMap);
28
- const event = new CustomEvent(OUTLINE_CHANGE_EVENT, { detail: { controlIndex } });
29
- this.dispatchEvent(event);
30
- sendAction(outlineChanged(outlineNodes));
31
- await this.changeService.updateConfigurationProps(configPropertyIdMap);
32
- } catch (error) {
33
- Log.error('Outline sync failed!', getError(error));
34
- }
35
- };
36
- await syncOutline();
37
- outline.attachEvent('update', syncOutline);
38
- }
39
- onOutlineChange(handler) {
40
- this.addEventListener(OUTLINE_CHANGE_EVENT, handler);
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "../../utils/error", "./nodes"], function (Log, ___sap_ux_private_control_property_editor_common, ____utils_error, ___nodes) {
4
+ "use strict";
5
+
6
+ const outlineChanged = ___sap_ux_private_control_property_editor_common["outlineChanged"];
7
+ const getError = ____utils_error["getError"];
8
+ const transformNodes = ___nodes["transformNodes"];
9
+ const OUTLINE_CHANGE_EVENT = 'OUTLINE_CHANGED';
10
+ /**
11
+ * A Class of WorkspaceConnectorService
12
+ */
13
+ class OutlineService extends EventTarget {
14
+ constructor(rta, changeService) {
15
+ super();
16
+ this.rta = rta;
17
+ this.changeService = changeService;
18
+ }
19
+
20
+ /**
21
+ * Initializes connector service.
22
+ *
23
+ * @param sendAction action sender function
24
+ */
25
+ async init(sendAction) {
26
+ const outline = await this.rta.getService('outline');
27
+ const {
28
+ scenario
29
+ } = this.rta.getFlexSettings();
30
+ const syncOutline = async () => {
31
+ try {
32
+ const viewNodes = await outline.get();
33
+ const controlIndex = {};
34
+ const configPropertyIdMap = new Map();
35
+ const outlineNodes = await transformNodes(viewNodes, scenario, controlIndex, this.changeService, configPropertyIdMap);
36
+ const event = new CustomEvent(OUTLINE_CHANGE_EVENT, {
37
+ detail: {
38
+ controlIndex
39
+ }
40
+ });
41
+ this.dispatchEvent(event);
42
+ sendAction(outlineChanged(outlineNodes));
43
+ await this.changeService.updateConfigurationProps(configPropertyIdMap);
44
+ } catch (error) {
45
+ Log.error('Outline sync failed!', getError(error));
41
46
  }
47
+ };
48
+ await syncOutline();
49
+ outline.attachEvent('update', syncOutline);
50
+ }
51
+ onOutlineChange(handler) {
52
+ this.addEventListener(OUTLINE_CHANGE_EVENT, handler);
42
53
  }
43
- var __exports = { __esModule: true };
44
- __exports.OUTLINE_CHANGE_EVENT = OUTLINE_CHANGE_EVENT;
45
- __exports.OutlineService = OutlineService;
46
- return __exports;
47
- });
54
+ }
55
+ var __exports = {
56
+ __esModule: true
57
+ };
58
+ __exports.OUTLINE_CHANGE_EVENT = OUTLINE_CHANGE_EVENT;
59
+ __exports.OutlineService = OutlineService;
60
+ return __exports;
61
+ });
62
+ //# sourceMappingURL=service.js.map
@@ -1,6 +1,2 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
2
  //# sourceMappingURL=quick-action-definition.js.map