@sap-ux/preview-middleware 0.23.132 → 0.23.135

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 (23) hide show
  1. package/dist/client/adp/controllers/AddActionFragment.controller.js +1 -1
  2. package/dist/client/adp/controllers/AddActionFragment.controller.ts +1 -1
  3. package/dist/client/adp/controllers/AddCustomFragment.controller.js +111 -12
  4. package/dist/client/adp/controllers/AddCustomFragment.controller.ts +114 -12
  5. package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.js +2 -2
  6. package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.ts +9 -11
  7. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.js +142 -0
  8. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.ts +178 -0
  9. package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.js +2 -1
  10. package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.ts +2 -1
  11. package/dist/client/adp/quick-actions/fe-v4/registry.js +2 -2
  12. package/dist/client/adp/quick-actions/fe-v4/registry.ts +1 -1
  13. package/dist/client/adp/quick-actions/fe-v4/utils.js +26 -22
  14. package/dist/client/adp/quick-actions/fe-v4/utils.ts +34 -34
  15. package/dist/client/adp/quick-actions/table-quick-action-base.js +50 -6
  16. package/dist/client/adp/quick-actions/table-quick-action-base.ts +56 -5
  17. package/dist/client/adp/ui/AddCustomFragment.fragment.xml +6 -0
  18. package/dist/client/messagebundle.properties +5 -1
  19. package/dist/client/utils/fe-v4.js +12 -0
  20. package/dist/client/utils/fe-v4.ts +17 -0
  21. package/package.json +11 -11
  22. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +0 -51
  23. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.ts +0 -52
@@ -26,6 +26,7 @@ import {
26
26
  TREE_TABLE_TYPE
27
27
  } from './control-types';
28
28
  import { isVariantManagementEnabledOPPage } from './fe-v2/utils';
29
+ import { isMacroTable } from '../../utils/fe-v4';
29
30
 
30
31
  const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
31
32
  const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
@@ -59,6 +60,7 @@ export type TableQuickActionsOptions = {
59
60
  includeServiceAction?: boolean;
60
61
  areTableRowsRequired?: boolean;
61
62
  validatePageVariantManagement?: boolean;
63
+ validateTableColumns?: boolean;
62
64
  };
63
65
 
64
66
  /**
@@ -129,6 +131,36 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
129
131
  }
130
132
  }
131
133
 
134
+ /**
135
+ * Builds a map of custom tab keys to their associated table building blocks.
136
+ *
137
+ * @param iconTabBarFilterMap - A map of icon tab bar filter keys to their labels.
138
+ * @returns A map where each key is a combination of contextPath and metaPath, and the value is the corresponding custom tab key.
139
+ */
140
+ private getCustomViewTableBuildingBlocksMap(iconTabBarFilterMap: { [key: string]: string }): {
141
+ [key: string]: string;
142
+ } {
143
+ const customTabTableBuildingBlockMap: { [key: string]: string } = {};
144
+
145
+ const customTabs = Object.keys(iconTabBarFilterMap).filter((key) => /^fe::CustomTab::\d+$/.test(key));
146
+ for (const key of customTabs) {
147
+ const items = (this.iconTabBar?.getItems() ?? []) as unknown as ManagedObject[];
148
+ const filterItem = items.find(
149
+ (item) => isA<IconTabFilter>('sap.m.IconTabFilter', item) && item.getKey() === key
150
+ );
151
+ if (filterItem && isA<IconTabFilter>('sap.m.IconTabFilter', filterItem)) {
152
+ filterItem.getContent().forEach((content) => {
153
+ if (isMacroTable(content)) {
154
+ const { metaPath, contextPath } = content;
155
+ const path = metaPath.startsWith(contextPath) ? metaPath : `${contextPath}${metaPath}`;
156
+ customTabTableBuildingBlockMap[path] = key;
157
+ }
158
+ });
159
+ }
160
+ }
161
+ return customTabTableBuildingBlockMap;
162
+ }
163
+
132
164
  /**
133
165
  * Initializes action object instance
134
166
  */
@@ -139,20 +171,21 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
139
171
  this.isApplicable = false;
140
172
  return;
141
173
  }
142
- const iconTabBarfilterMap = this.buildIconTabBarFilterMap();
174
+ const iconTabBarFilterMap = this.buildIconTabBarFilterMap();
175
+ const customViewTableBuildingBlockMap = this.getCustomViewTableBuildingBlocksMap(iconTabBarFilterMap);
143
176
  for (const table of getRelevantControlFromActivePage(
144
177
  this.context.controlIndex,
145
178
  this.context.view,
146
179
  this.controlTypes
147
180
  )) {
148
- const tabKey = Object.keys(iconTabBarfilterMap).find((key) => table.getId().endsWith(key));
181
+ const tabKey = Object.keys(iconTabBarFilterMap).find((key) => table.getId().endsWith(key));
149
182
  const section = getParentContainer<ObjectPageSection>(table, 'sap.uxap.ObjectPageSection');
150
183
  if (section) {
151
184
  await this.collectChildrenInSection(section, table);
152
185
  } else if (this.iconTabBar && tabKey) {
153
- const label = `'${iconTabBarfilterMap[tabKey]}' table`;
186
+ const label = `'${iconTabBarFilterMap[tabKey]}' table`;
154
187
  const tableMapKey = this.children.length.toString();
155
- const child = this.createChild(label, table, tableMapKey);
188
+ const child = this.createChild(label, table, tableMapKey, customViewTableBuildingBlockMap);
156
189
  this.children.push(child);
157
190
  this.tableMap[tableMapKey] = {
158
191
  table,
@@ -351,13 +384,31 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
351
384
  };
352
385
  }
353
386
 
354
- createChild(label: string, table: UI5Element, path: string): NestedQuickActionChild {
387
+ createChild(
388
+ label: string,
389
+ table: UI5Element,
390
+ path: string,
391
+ customViewTableBuildingBlockMap?: {
392
+ [key: string]: string;
393
+ }
394
+ ): NestedQuickActionChild {
355
395
  const child: NestedQuickActionChild = {
356
396
  path,
357
397
  label,
358
398
  enabled: true,
359
399
  children: []
360
400
  };
401
+ const parent = table.getParent();
402
+ const macroTable = isMacroTable(parent) ? parent : undefined;
403
+ if (this.options.validateTableColumns && macroTable) {
404
+ const { metaPath, contextPath } = macroTable;
405
+ const finalPath = metaPath.startsWith(contextPath) ? metaPath : `${contextPath}${metaPath}`;
406
+ if (customViewTableBuildingBlockMap?.[finalPath]) {
407
+ child.enabled = false;
408
+ child.tooltip = this.context.resourceBundle.getText('CUSTOM_COLUMNS_NOT_SUPPORTED');
409
+ return child;
410
+ }
411
+ }
361
412
  if (this.options.validatePageVariantManagement) {
362
413
  const variantEnabledV2 = isVariantManagementEnabledOPPage(this.context, table);
363
414
  if (variantEnabledV2 === false) {
@@ -14,6 +14,12 @@
14
14
  labelSpanS="4"
15
15
  singleContainerFullSize="false">
16
16
  <f:content>
17
+ <Label visible="{/isCustomColumnFragment}" text="{i18n>ADP_ADD_CUSTOM_FRAGMENT_DIALOG_COLUMN_ID_LABEL}" required="true" />
18
+ <Input
19
+ value="{/id}"
20
+ visible="{/isCustomColumnFragment}"
21
+ liveChange="onIdInputChange">
22
+ </Input>
17
23
  <Label text="{i18n>ADP_ADD_FRAGMENT_DIALOG_FRAGMENT_NAME_LABEL}" required="true" />
18
24
  <Input
19
25
  id="bbFragmentName"
@@ -135,5 +135,9 @@ FRAGMENT_PATH=FRAGMENT PATH
135
135
  ACTION_ID_REQUIRED=Action ID is required.
136
136
  ACTION_WITH_GIVEN_ID_ALREADY_EXISTS=An action with the ''{0}'' ID is already defined. Please choose a different ID.
137
137
  ACTION_ID_CANNOT_CONTAIN_SPACES=Action ID cannot contain spaces.
138
- ACTION_ID_INVALID_FORMAT=Action ID must start with a letter or _ and may contain letters, digits, _, ., :, and -.
139
138
  BUTTON_TEXT_REQUIRED=Button Text is required.
139
+ CUSTOM_COLUMNS_NOT_SUPPORTED=Custom columns defined in the manifest.json file are not supported when using the Table building block.
140
+ ADP_ADD_CUSTOM_FRAGMENT_DIALOG_COLUMN_ID_LABEL=Column ID
141
+ ID_REQUIRED={0} ID is required.
142
+ GIVEN_ID_ALREADY_EXISTS={0} with ID ''{1}'' is already defined.
143
+ ID_INVALID_FORMAT={0} ID must start with a letter or _ and may contain letters, digits, _, ., :, and -.
@@ -141,6 +141,17 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
141
141
  }
142
142
  return result;
143
143
  }
144
+ /** * Checks if the given control is inside a table and returns the table instance.
145
+ * For UI5 version greater than 1.144 the table is 'sap.fe.macros.Table' and for lower versions it is 'sap.fe.macros.table.TableAPI'
146
+ * @param control - UI5 control instance.
147
+ * @returns Table instance if the control is inside a table, otherwise undefined.
148
+ */
149
+ function isMacroTable(table) {
150
+ if (table && (isA('sap.fe.macros.Table', table) || isA('sap.fe.macros.table.TableAPI', table))) {
151
+ return true;
152
+ }
153
+ return false;
154
+ }
144
155
  var __exports = {
145
156
  __esModule: true
146
157
  };
@@ -151,6 +162,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
151
162
  __exports.getConfigMapControlIdMap = getConfigMapControlIdMap;
152
163
  __exports.createManifestPropertyChange = createManifestPropertyChange;
153
164
  __exports.getV4ApplicationPages = getV4ApplicationPages;
165
+ __exports.isMacroTable = isMacroTable;
154
166
  return __exports;
155
167
  });
156
168
  //# sourceMappingURL=fe-v4.js.map
@@ -10,6 +10,12 @@ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
10
10
  import { getOverlay } from '../cpe/utils';
11
11
  import UI5Element from 'sap/ui/core/Element';
12
12
  import FlexCommand from 'sap/ui/rta/command/FlexCommand';
13
+ import TableAPI from 'sap/fe/macros/table/TableAPI';
14
+
15
+ export type MacroTable = TableAPI & {
16
+ metaPath: string;
17
+ contextPath: string;
18
+ };
13
19
 
14
20
  /**
15
21
  * Gets app component of a v4 project.
@@ -167,3 +173,14 @@ export function getV4ApplicationPages(manifest: Manifest): { id: string; entityS
167
173
  }
168
174
  return result;
169
175
  }
176
+ /** * Checks if the given control is inside a table and returns the table instance.
177
+ * For UI5 version greater than 1.144 the table is 'sap.fe.macros.Table' and for lower versions it is 'sap.fe.macros.table.TableAPI'
178
+ * @param control - UI5 control instance.
179
+ * @returns Table instance if the control is inside a table, otherwise undefined.
180
+ */
181
+ export function isMacroTable(table: ManagedObject | null): table is MacroTable {
182
+ if (table && (isA<MacroTable>('sap.fe.macros.Table', table) || isA<MacroTable>('sap.fe.macros.table.TableAPI', table))) {
183
+ return true;
184
+ }
185
+ return false;
186
+ }
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.23.132",
12
+ "version": "0.23.135",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,17 +27,17 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "qrcode": "1.5.4",
29
29
  "@sap/bas-sdk": "3.13.3",
30
- "@sap-ux/adp-tooling": "0.18.72",
30
+ "@sap-ux/adp-tooling": "0.18.75",
31
31
  "@sap-ux/btp-utils": "1.1.9",
32
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.13",
32
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.16",
33
33
  "@sap-ux/feature-toggle": "0.3.7",
34
34
  "@sap-ux/logger": "0.8.1",
35
- "@sap-ux/project-access": "1.35.7",
36
- "@sap-ux/system-access": "0.6.56",
37
- "@sap-ux/i18n": "0.3.7"
35
+ "@sap-ux/project-access": "1.35.9",
36
+ "@sap-ux/system-access": "0.6.57",
37
+ "@sap-ux/i18n": "0.3.9"
38
38
  },
39
39
  "devDependencies": {
40
- "@sap-ux-private/playwright": "0.2.7",
40
+ "@sap-ux-private/playwright": "0.2.8",
41
41
  "@types/connect": "^3.4.38",
42
42
  "@types/qrcode": "1.5.5",
43
43
  "@types/ejs": "3.1.2",
@@ -51,10 +51,10 @@
51
51
  "dotenv": "16.6.1",
52
52
  "express": "4.22.1",
53
53
  "nock": "13.4.0",
54
- "npm-run-all2": "6.2.0",
55
- "supertest": "7.1.4",
56
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.21",
57
- "@sap-ux/axios-extension": "1.25.15",
54
+ "npm-run-all2": "8.0.4",
55
+ "supertest": "7.2.2",
56
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.23",
57
+ "@sap-ux/axios-extension": "1.25.16",
58
58
  "@sap-ux/store": "1.5.7",
59
59
  "@sap-ux/ui5-info": "0.13.13"
60
60
  },
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../control-types", "../table-quick-action-base", "../fe-v2/create-table-custom-column", "../dialog-enablement-validator"], function (OverlayRegistry, ____dialog_factory, ___control_types, ___table_quick_action_base, ___fe_v2_create_table_custom_column, ___dialog_enablement_validator) {
4
- "use strict";
5
-
6
- const DialogFactory = ____dialog_factory["DialogFactory"];
7
- const DialogNames = ____dialog_factory["DialogNames"];
8
- const SMART_TABLE_TYPE = ___control_types["SMART_TABLE_TYPE"];
9
- const GRID_TABLE_TYPE = ___control_types["GRID_TABLE_TYPE"];
10
- const MDC_TABLE_TYPE = ___control_types["MDC_TABLE_TYPE"];
11
- const TREE_TABLE_TYPE = ___control_types["TREE_TABLE_TYPE"];
12
- const TableQuickActionDefinitionBase = ___table_quick_action_base["TableQuickActionDefinitionBase"];
13
- const preprocessActionExecution = ___fe_v2_create_table_custom_column["preprocessActionExecution"];
14
- const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
15
- const CREATE_TABLE_CUSTOM_COLUMN = 'create-table-custom-column';
16
- const CONTROL_TYPES = [SMART_TABLE_TYPE, MDC_TABLE_TYPE, TREE_TABLE_TYPE, GRID_TABLE_TYPE];
17
- class AddTableCustomColumnQuickAction extends TableQuickActionDefinitionBase {
18
- constructor(context) {
19
- super(CREATE_TABLE_CUSTOM_COLUMN, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_TABLE_COLUMN', context, undefined, [DIALOG_ENABLEMENT_VALIDATOR]);
20
- }
21
- async execute(path) {
22
- const {
23
- table,
24
- iconTabBarFilterKey,
25
- sectionInfo
26
- } = this.tableMap[path];
27
- if (!table) {
28
- return [];
29
- }
30
- preprocessActionExecution(table, sectionInfo, this.iconTabBar, iconTabBarFilterKey);
31
- this.selectOverlay(table);
32
- const overlay = OverlayRegistry.getOverlay(table);
33
- await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
34
- aggregation: 'columns',
35
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_COLUMN'
36
- }, {
37
- actionName: this.type,
38
- telemetryEventIdentifier: this.getTelemetryIdentifier()
39
- });
40
- return [];
41
- }
42
- }
43
- var __exports = {
44
- __esModule: true
45
- };
46
- __exports.CREATE_TABLE_CUSTOM_COLUMN = CREATE_TABLE_CUSTOM_COLUMN;
47
- __exports.CONTROL_TYPES = CONTROL_TYPES;
48
- __exports.AddTableCustomColumnQuickAction = AddTableCustomColumnQuickAction;
49
- return __exports;
50
- });
51
- //# sourceMappingURL=create-table-custom-column.js.map
@@ -1,52 +0,0 @@
1
- import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
2
- import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
3
-
4
- import {
5
- QuickActionContext,
6
- NestedQuickActionDefinition
7
- } from '../../../cpe/quick-actions/quick-action-definition';
8
- import { DialogFactory, DialogNames } from '../../dialog-factory';
9
- import { SMART_TABLE_TYPE, GRID_TABLE_TYPE, MDC_TABLE_TYPE, TREE_TABLE_TYPE } from '../control-types';
10
- import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
11
-
12
- import { preprocessActionExecution } from '../fe-v2/create-table-custom-column';
13
- import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
14
-
15
- export const CREATE_TABLE_CUSTOM_COLUMN = 'create-table-custom-column';
16
-
17
- export const CONTROL_TYPES = [SMART_TABLE_TYPE, MDC_TABLE_TYPE, TREE_TABLE_TYPE, GRID_TABLE_TYPE];
18
-
19
- export class AddTableCustomColumnQuickAction
20
- extends TableQuickActionDefinitionBase
21
- implements NestedQuickActionDefinition
22
- {
23
- constructor(context: QuickActionContext) {
24
- super(CREATE_TABLE_CUSTOM_COLUMN, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_TABLE_COLUMN', context, undefined, [
25
- DIALOG_ENABLEMENT_VALIDATOR
26
- ]);
27
- }
28
-
29
- async execute(path: string): Promise<FlexCommand[]> {
30
- const { table, iconTabBarFilterKey, sectionInfo } = this.tableMap[path];
31
- if (!table) {
32
- return [];
33
- }
34
-
35
- preprocessActionExecution(table, sectionInfo, this.iconTabBar, iconTabBarFilterKey);
36
- this.selectOverlay(table);
37
-
38
- const overlay = OverlayRegistry.getOverlay(table);
39
- await DialogFactory.createDialog(
40
- overlay,
41
- this.context.rta,
42
- DialogNames.ADD_FRAGMENT,
43
- undefined,
44
- {
45
- aggregation: 'columns',
46
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_COLUMN'
47
- },
48
- { actionName: this.type, telemetryEventIdentifier: this.getTelemetryIdentifier() }
49
- );
50
- return [];
51
- }
52
- }