@sap-ux/preview-middleware 0.16.125 → 0.16.127

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.
@@ -9,7 +9,8 @@ sap.ui.define(["../../../cpe/feature-service", "../../../cpe/quick-actions/utils
9
9
  const executeToggleAction = ___utils["executeToggleAction"];
10
10
  const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
11
11
  const ENABLE_SEMANTIC_DATE_RANGE = 'enable-semantic-date-range';
12
- const PROPERTY_PATH = 'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/useSemanticDateRange';
12
+ const PROPERTY_NAME = 'useSemanticDateRange';
13
+ const PROPERTY_PATH = `controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/${PROPERTY_NAME}`;
13
14
  const CONTROL_TYPE = 'sap.fe.macros.controls.FilterBar';
14
15
  const boolMap = {
15
16
  'true': true,
@@ -34,7 +35,8 @@ sap.ui.define(["../../../cpe/feature-service", "../../../cpe/quick-actions/utils
34
35
  const filterBar = getControlById(control.controlId);
35
36
  if (isActionApplicable && filterBar) {
36
37
  this.control = filterBar;
37
- this.isUseDateRangeTypeEnabled = boolMap[this.control.data('useSemanticDateRange')];
38
+ const value = this.context.changeService.getConfigurationPropertyValue(control.controlId, PROPERTY_NAME);
39
+ this.isUseDateRangeTypeEnabled = value === undefined ? boolMap[this.control.data('useSemanticDateRange')] : value;
38
40
  }
39
41
  }
40
42
  }
@@ -9,7 +9,8 @@ import { executeToggleAction } from './utils';
9
9
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
10
10
 
11
11
  export const ENABLE_SEMANTIC_DATE_RANGE = 'enable-semantic-date-range';
12
- const PROPERTY_PATH = 'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/useSemanticDateRange';
12
+ const PROPERTY_NAME = 'useSemanticDateRange';
13
+ const PROPERTY_PATH = `controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/${PROPERTY_NAME}`;
13
14
  const CONTROL_TYPE = 'sap.fe.macros.controls.FilterBar';
14
15
  const boolMap: { [key: string]: boolean } = {
15
16
  'true': true,
@@ -38,7 +39,12 @@ export class ToggleSemanticDateRangeFilterBar
38
39
  const filterBar = getControlById<FilterBar>(control.controlId);
39
40
  if (isActionApplicable && filterBar) {
40
41
  this.control = filterBar;
41
- this.isUseDateRangeTypeEnabled = boolMap[this.control.data('useSemanticDateRange')];
42
+ const value = this.context.changeService.getConfigurationPropertyValue(
43
+ control.controlId,
44
+ PROPERTY_NAME
45
+ );
46
+ this.isUseDateRangeTypeEnabled =
47
+ value === undefined ? boolMap[this.control.data('useSemanticDateRange')] : (value as boolean);
42
48
  }
43
49
  }
44
50
  }
@@ -8,7 +8,8 @@ sap.ui.define(["../../../cpe/quick-actions/utils", "../../../utils/core", "./uti
8
8
  const executeToggleAction = ___utils["executeToggleAction"];
9
9
  const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
10
10
  const ENABLE_CLEAR_FILTER_BAR_TYPE = 'enable-clear-filter-bar';
11
- const PROPERTY_PATH = 'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/showClearButton';
11
+ const PROPERTY_NAME = 'showClearButton';
12
+ const PROPERTY_PATH = `controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/${PROPERTY_NAME}`;
12
13
  const CONTROL_TYPE = 'sap.fe.macros.controls.FilterBar';
13
14
 
14
15
  /**
@@ -27,7 +28,8 @@ sap.ui.define(["../../../cpe/quick-actions/utils", "../../../utils/core", "./uti
27
28
  const filterBar = getControlById(control.controlId);
28
29
  if (isActionApplicable && filterBar) {
29
30
  this.control = filterBar;
30
- this.isClearButtonEnabled = filterBar.getShowClearButton();
31
+ const value = this.context.changeService.getConfigurationPropertyValue(control.controlId, PROPERTY_NAME);
32
+ this.isClearButtonEnabled = value === undefined ? filterBar.getShowClearButton() : value;
31
33
  }
32
34
  }
33
35
  }
@@ -8,7 +8,8 @@ import { executeToggleAction } from './utils';
8
8
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
9
9
 
10
10
  export const ENABLE_CLEAR_FILTER_BAR_TYPE = 'enable-clear-filter-bar';
11
- const PROPERTY_PATH = 'controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/showClearButton';
11
+ const PROPERTY_NAME = 'showClearButton';
12
+ const PROPERTY_PATH = `controlConfiguration/@com.sap.vocabularies.UI.v1.SelectionFields/${PROPERTY_NAME}`;
12
13
  const CONTROL_TYPE = 'sap.fe.macros.controls.FilterBar';
13
14
 
14
15
  /**
@@ -31,7 +32,11 @@ export class ToggleClearFilterBarQuickAction
31
32
  const filterBar = getControlById<FilterBar>(control.controlId);
32
33
  if (isActionApplicable && filterBar) {
33
34
  this.control = filterBar;
34
- this.isClearButtonEnabled = filterBar.getShowClearButton();
35
+ const value = this.context.changeService.getConfigurationPropertyValue(
36
+ control.controlId,
37
+ PROPERTY_NAME
38
+ );
39
+ this.isClearButtonEnabled = value === undefined ? filterBar.getShowClearButton() : (value as boolean);
35
40
  }
36
41
  }
37
42
  }
@@ -42,7 +42,7 @@ sap.ui.define([
42
42
  const selectionService = new SelectionService(rta, changesService);
43
43
  const connectorService = new WorkspaceConnectorService();
44
44
  const outlineService = new OutlineService(rta, changesService);
45
- const quickActionService = new QuickActionService(rta, outlineService, registries);
45
+ const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
46
46
  const services = [
47
47
  connectorService,
48
48
  selectionService,
@@ -53,12 +53,16 @@ sap.ui.define([
53
53
  ];
54
54
  try {
55
55
  loadDefaultLibraries();
56
- for (const service of services) {
57
- service.init(CommunicationService.sendAction, subscribe)?.catch(reason => Log.error('Service Initialization Failed: ', getError(reason)));
58
- }
56
+ const allPromises = services.map(service => {
57
+ return service.init(CommunicationService.sendAction, subscribe)?.catch(error => {
58
+ Log.error('Service Initialization Failed: ', getError(error));
59
+ });
60
+ });
61
+ Promise.all(allPromises).then(() => {
62
+ CommunicationService.sendAction(appLoaded());
63
+ }).catch(Log.error);
59
64
  const icons = getIcons();
60
65
  CommunicationService.sendAction(iconsLoaded(icons));
61
- CommunicationService.sendAction(appLoaded());
62
66
  } catch (error) {
63
67
  Log.error('Error during initialization of Control Property Editor', getError(error));
64
68
  }
@@ -43,7 +43,7 @@ export default function init(
43
43
 
44
44
  const connectorService = new WorkspaceConnectorService();
45
45
  const outlineService = new OutlineService(rta, changesService);
46
- const quickActionService = new QuickActionService(rta, outlineService, registries);
46
+ const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
47
47
  const services: Service[] = [
48
48
  connectorService,
49
49
  selectionService,
@@ -52,22 +52,25 @@ export default function init(
52
52
  rtaService,
53
53
  quickActionService
54
54
  ];
55
-
56
55
  try {
57
56
  loadDefaultLibraries();
58
-
59
- for (const service of services) {
60
- service
61
- .init(CommunicationService.sendAction, subscribe)
62
- ?.catch((reason) => Log.error('Service Initialization Failed: ', getError(reason)));
63
- }
64
-
57
+ const allPromises = services.map((service) => {
58
+ return service.init(CommunicationService.sendAction, subscribe)?.catch((error) => {
59
+ Log.error('Service Initialization Failed: ', getError(error));
60
+ });
61
+ });
62
+ Promise.all(allPromises)
63
+ .then(() => {
64
+ CommunicationService.sendAction(appLoaded());
65
+ })
66
+ // eslint-disable-next-line @typescript-eslint/unbound-method
67
+ .catch(Log.error);
65
68
  const icons = getIcons();
66
-
67
69
  CommunicationService.sendAction(iconsLoaded(icons));
68
- CommunicationService.sendAction(appLoaded());
69
70
  } catch (error) {
70
71
  Log.error('Error during initialization of Control Property Editor', getError(error));
71
72
  }
73
+
74
+ // * This is returned immediately to avoid promise deadlock, preventing services from waiting indefinitely.
72
75
  return Promise.resolve();
73
76
  }
@@ -13,6 +13,7 @@ import type {
13
13
 
14
14
  import type { TextBundle } from '../../i18n';
15
15
  import type { ControlTreeIndex } from '../types';
16
+ import { ChangeService } from '../changes';
16
17
 
17
18
  export interface QuickActionActivationContext {
18
19
  controlIndex: ControlTreeIndex;
@@ -38,6 +39,7 @@ export interface QuickActionContext {
38
39
  rta: RuntimeAuthoring;
39
40
  flexSettings: FlexSettings;
40
41
  manifest: Manifest;
42
+ changeService: ChangeService;
41
43
  }
42
44
 
43
45
  export type QuickActionActivationData = {
@@ -15,10 +15,11 @@ sap.ui.define([
15
15
  sendAction = () => {
16
16
  };
17
17
  actions = [];
18
- constructor(rta, outlineService, registries) {
18
+ constructor(rta, outlineService, registries, changeService) {
19
19
  this.rta = rta;
20
20
  this.outlineService = outlineService;
21
21
  this.registries = registries;
22
+ this.changeService = changeService;
22
23
  }
23
24
  async init(sendAction, subscribe) {
24
25
  this.sendAction = sendAction;
@@ -40,8 +41,12 @@ sap.ui.define([
40
41
  }
41
42
  });
42
43
  this.outlineService.onOutlineChange(async event => {
44
+ this.controlTreeIndex = event.detail.controlIndex;
43
45
  await this.reloadQuickActions(event.detail.controlIndex);
44
46
  });
47
+ this.changeService.onStackChange(async () => {
48
+ await this.reloadQuickActions(this.controlTreeIndex);
49
+ });
45
50
  }
46
51
  async reloadQuickActions(controlIndex) {
47
52
  const context = {
@@ -62,7 +67,8 @@ sap.ui.define([
62
67
  key,
63
68
  rta: this.rta,
64
69
  flexSettings: this.rta.getFlexSettings(),
65
- resourceBundle: this.texts
70
+ resourceBundle: this.texts,
71
+ changeService: this.changeService
66
72
  };
67
73
  for (const Definition of definitions) {
68
74
  try {
@@ -19,6 +19,7 @@ import { QuickActionActivationContext, QuickActionContext, QuickActionDefinition
19
19
  import { QuickActionDefinitionRegistry } from './registry';
20
20
  import { OutlineService } from '../outline/service';
21
21
  import { getTextBundle, TextBundle } from '../../i18n';
22
+ import { ChangeService } from '../changes';
22
23
 
23
24
  /**
24
25
  * Service providing Quick Actions.
@@ -26,13 +27,14 @@ import { getTextBundle, TextBundle } from '../../i18n';
26
27
  export class QuickActionService implements Service {
27
28
  private sendAction: ActionSenderFunction = () => {};
28
29
  private actions: QuickActionDefinition[] = [];
30
+ private controlTreeIndex: ControlTreeIndex;
29
31
 
30
32
  private actionService: ActionService;
31
33
  private texts: TextBundle;
32
34
 
33
35
  /**
34
36
  * Qucik action service constructor.zrf
35
- *
37
+ *
36
38
  * @param rta - RTA object.
37
39
  * @param outlineService - Outline service instance.
38
40
  * @param registries - Quick action registries.
@@ -40,7 +42,8 @@ export class QuickActionService implements Service {
40
42
  constructor(
41
43
  private readonly rta: RuntimeAuthoring,
42
44
  private readonly outlineService: OutlineService,
43
- private readonly registries: QuickActionDefinitionRegistry<string>[]
45
+ private readonly registries: QuickActionDefinitionRegistry<string>[],
46
+ private readonly changeService: ChangeService
44
47
  ) {}
45
48
 
46
49
  /**
@@ -75,13 +78,18 @@ export class QuickActionService implements Service {
75
78
  });
76
79
 
77
80
  this.outlineService.onOutlineChange(async (event) => {
81
+ this.controlTreeIndex = event.detail.controlIndex;
78
82
  await this.reloadQuickActions(event.detail.controlIndex);
79
83
  });
84
+
85
+ this.changeService.onStackChange(async () => {
86
+ await this.reloadQuickActions(this.controlTreeIndex);
87
+ });
80
88
  }
81
89
 
82
90
  /**
83
91
  * Prepares a list of currently applicable Quick Actions and sends them to the UI.
84
- *
92
+ *
85
93
  * @param controlIndex - Control tree index.
86
94
  */
87
95
  public async reloadQuickActions(controlIndex: ControlTreeIndex): Promise<void> {
@@ -104,7 +112,8 @@ export class QuickActionService implements Service {
104
112
  key,
105
113
  rta: this.rta,
106
114
  flexSettings: this.rta.getFlexSettings(),
107
- resourceBundle: this.texts
115
+ resourceBundle: this.texts,
116
+ changeService: this.changeService
108
117
  };
109
118
  for (const Definition of definitions) {
110
119
  try {
@@ -13,33 +13,37 @@ sap.ui.define(['open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
13
13
  constructor(rta) {
14
14
  this.rta = rta;
15
15
  }
16
- init(sendAction, subscribe) {
17
- sendAction(applicationModeChanged(this.rta.getMode()));
18
- subscribe(async action => {
19
- if (setAppMode.match(action)) {
20
- this.rta.setMode(action.payload);
21
- }
22
- if (undo.match(action)) {
23
- this.rta.undo();
24
- }
25
- if (redo.match(action)) {
26
- this.rta.redo();
27
- }
28
- if (reloadApplication.match(action)) {
29
- if (action.payload.save === true) {
16
+ async init(sendAction, subscribe) {
17
+ return new Promise(resolve => {
18
+ sendAction(applicationModeChanged(this.rta.getMode()));
19
+ subscribe(async action => {
20
+ if (setAppMode.match(action)) {
21
+ this.rta.setMode(action.payload);
22
+ }
23
+ if (undo.match(action)) {
24
+ this.rta.undo();
25
+ }
26
+ if (redo.match(action)) {
27
+ this.rta.redo();
28
+ }
29
+ if (reloadApplication.match(action)) {
30
+ if (action.payload.save === true) {
31
+ await this.save();
32
+ }
33
+ await this.rta.stop(false, true);
34
+ }
35
+ if (save.match(action)) {
30
36
  await this.save();
31
37
  }
32
- await this.rta.stop(false, true);
33
- }
34
- if (save.match(action)) {
35
- await this.save();
36
- }
37
- return Promise.resolve();
38
- });
39
- this.rta.attachStop(() => {
40
- location.reload();
38
+ });
39
+ this.rta.attachStop(() => {
40
+ location.reload();
41
+ });
42
+ this.rta.attachStart(() => {
43
+ resolve();
44
+ });
45
+ this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
41
46
  });
42
- this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
43
47
  }
44
48
  save() {
45
49
  if (this.rta.save) {
@@ -28,36 +28,40 @@ export class RtaService {
28
28
  * @param sendAction action sender function
29
29
  * @param subscribe subscriber function
30
30
  */
31
- public init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void {
32
- sendAction(applicationModeChanged(this.rta.getMode()));
33
- subscribe(async (action): Promise<void> => {
34
- if (setAppMode.match(action)) {
35
- this.rta.setMode(action.payload);
36
- }
37
- if (undo.match(action)) {
38
- this.rta.undo();
39
- }
40
- if (redo.match(action)) {
41
- this.rta.redo();
42
- }
43
- if (reloadApplication.match(action)) {
44
- if (action.payload.save === true) {
45
- await this.save();
31
+ public async init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): Promise<void> {
32
+ return new Promise((resolve) => {
33
+ sendAction(applicationModeChanged(this.rta.getMode()));
34
+ subscribe(async (action): Promise<void> => {
35
+ if (setAppMode.match(action)) {
36
+ this.rta.setMode(action.payload);
37
+ }
38
+ if (undo.match(action)) {
39
+ this.rta.undo();
40
+ }
41
+ if (redo.match(action)) {
42
+ this.rta.redo();
43
+ }
44
+ if (reloadApplication.match(action)) {
45
+ if (action.payload.save === true) {
46
+ await this.save();
47
+ }
48
+ await this.rta.stop(false, true);
46
49
  }
47
- await this.rta.stop(false, true);
48
- }
49
50
 
50
- if (save.match(action)) {
51
- await this.save();
52
- }
53
- return Promise.resolve();
54
- });
51
+ if (save.match(action)) {
52
+ await this.save();
53
+ }
54
+ });
55
55
 
56
- this.rta.attachStop(() => {
57
- // eslint-disable-next-line fiori-custom/sap-no-location-reload
58
- location.reload();
56
+ this.rta.attachStop(() => {
57
+ // eslint-disable-next-line fiori-custom/sap-no-location-reload
58
+ location.reload();
59
+ });
60
+ this.rta.attachStart(() => {
61
+ resolve();
62
+ });
63
+ this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
59
64
  });
60
- this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
61
65
  }
62
66
 
63
67
  private save(): Promise<void> {
@@ -22,6 +22,7 @@ sap.ui.define([
22
22
  const getRuntimeControl = ___utils['getRuntimeControl'];
23
23
  const getDocumentation = ___documentation['getDocumentation'];
24
24
  const getComponent = ___utils_core['getComponent'];
25
+ const getControlById = ___utils_core['getControlById'];
25
26
  const getError = ___utils_error['getError'];
26
27
  function propertyChangeId(controlId, propertyName) {
27
28
  return [
@@ -73,7 +74,7 @@ sap.ui.define([
73
74
  this.applyControlPropertyChange(action.payload.controlId, action.payload.propertyName);
74
75
  } else if (selectControl.match(action)) {
75
76
  const id = action.payload;
76
- const control = sap.ui.getCore().byId(id);
77
+ const control = getControlById(id);
77
78
  if (!control) {
78
79
  const component = getComponent(id);
79
80
  if (component) {
@@ -127,6 +128,7 @@ sap.ui.define([
127
128
  const overlayControl = sap.ui.getCore().byId(selection[0].getId());
128
129
  if (overlayControl) {
129
130
  const runtimeControl = getRuntimeControl(overlayControl);
131
+ this.currentSelection = runtimeControl;
130
132
  const controlName = runtimeControl.getMetadata().getName();
131
133
  this.handlePropertyChanges(runtimeControl, sendAction);
132
134
  try {
@@ -21,10 +21,9 @@ import Log from 'sap/base/Log';
21
21
  import { getDocumentation } from './documentation';
22
22
  import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
23
23
  import OverlayUtil from 'sap/ui/dt/OverlayUtil';
24
- import { getComponent } from '../utils/core';
24
+ import { getComponent, getControlById } from '../utils/core';
25
25
  import { getError } from '../utils/error';
26
26
  import { ChangeService } from './changes';
27
- import UI5Element from 'sap/ui/core/Element';
28
27
 
29
28
  export interface PropertyChangeParams {
30
29
  name: string;
@@ -95,7 +94,7 @@ async function addDocumentationForProperties(control: ManagedObject, controlData
95
94
  export class SelectionService implements Service {
96
95
  private appliedChangeCache = new Map<string, number>();
97
96
  private activeChangeHandlers = new Set<() => void>();
98
- private currentSelection: UI5Element;
97
+ private currentSelection: ManagedObject;
99
98
  /**
100
99
  *
101
100
  * @param rta - rta object.
@@ -120,7 +119,7 @@ export class SelectionService implements Service {
120
119
  this.applyControlPropertyChange(action.payload.controlId, action.payload.propertyName);
121
120
  } else if (selectControl.match(action)) {
122
121
  const id = action.payload;
123
- const control = sap.ui.getCore().byId(id);
122
+ const control = getControlById(id);
124
123
  if (!control) {
125
124
  const component = getComponent(id);
126
125
  if (component) {
@@ -201,6 +200,7 @@ export class SelectionService implements Service {
201
200
  const overlayControl = sap.ui.getCore().byId(selection[0].getId()) as ElementOverlay;
202
201
  if (overlayControl) {
203
202
  const runtimeControl = getRuntimeControl(overlayControl);
203
+ this.currentSelection = runtimeControl;
204
204
  const controlName = runtimeControl.getMetadata().getName();
205
205
  this.handlePropertyChanges(runtimeControl, sendAction);
206
206
  try {
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.16.125",
12
+ "version": "0.16.127",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,9 +27,9 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.2",
30
- "@sap-ux/adp-tooling": "0.12.81",
31
30
  "@sap-ux/btp-utils": "0.17.0",
32
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.26",
31
+ "@sap-ux/adp-tooling": "0.12.82",
32
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.27",
33
33
  "@sap-ux/project-access": "1.28.7"
34
34
  },
35
35
  "devDependencies": {
@@ -46,10 +46,10 @@
46
46
  "supertest": "6.3.3",
47
47
  "@sap-ux-private/playwright": "0.1.0",
48
48
  "dotenv": "16.3.1",
49
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.34",
49
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.35",
50
50
  "@sap-ux/axios-extension": "1.17.4",
51
- "@sap-ux/ui5-info": "0.8.3",
52
51
  "@sap-ux/store": "0.9.3",
52
+ "@sap-ux/ui5-info": "0.8.3",
53
53
  "@sap-ux/i18n": "0.2.0"
54
54
  },
55
55
  "peerDependencies": {