@sap-ux/preview-middleware 0.17.41 → 0.17.43

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.
@@ -19,6 +19,23 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog
19
19
  constructor(context) {
20
20
  super(CREATE_TABLE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION', context, undefined, [DIALOG_ENABLEMENT_VALIDATOR]);
21
21
  }
22
+ async initialize() {
23
+ const processChild = (child, mapKey) => {
24
+ const table = this.tableMap[mapKey]?.table;
25
+ if (table) {
26
+ const headerToolbar = this.getHeaderToolbar(table);
27
+ if (!headerToolbar) {
28
+ child.enabled = false;
29
+ child.tooltip = this.context.resourceBundle.getText('NO_TABLE_HEADER_TOOLBAR');
30
+ }
31
+ }
32
+ child.children.forEach((nestedChild, idx) => processChild(nestedChild, `${mapKey}/${idx.toFixed(0)}`));
33
+ };
34
+ await super.initialize();
35
+
36
+ // disable nested actions based on conditions
37
+ this.children.forEach((nestedChild, idx) => processChild(nestedChild, `${idx.toFixed(0)}`));
38
+ }
22
39
  async execute(path) {
23
40
  const {
24
41
  table,
@@ -44,12 +61,7 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog
44
61
  if (this.iconTabBar && iconTabBarFilterKey) {
45
62
  this.iconTabBar.setSelectedKey(iconTabBarFilterKey);
46
63
  }
47
- let headerToolbar;
48
- if (isA(SMART_TABLE_TYPE, table)) {
49
- headerToolbar = table.getAggregation('items')[0].getAggregation('headerToolbar');
50
- } else if (isA(M_TABLE_TYPE, table)) {
51
- headerToolbar = table.getAggregation('headerToolbar');
52
- }
64
+ const headerToolbar = this.getHeaderToolbar(table);
53
65
 
54
66
  // open dialogBox to add, and content is selected ByDefault
55
67
  if (headerToolbar) {
@@ -61,6 +73,20 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog
61
73
  }
62
74
  return [];
63
75
  }
76
+ getHeaderToolbar(table) {
77
+ let headerToolbar;
78
+ if (isA(SMART_TABLE_TYPE, table)) {
79
+ headerToolbar = table.getAggregation('items').find(item => {
80
+ if (item.getAggregation('headerToolbar')) {
81
+ return true;
82
+ }
83
+ return isA('sap.m.OverflowToolbar', item);
84
+ });
85
+ } else if (isA(M_TABLE_TYPE, table)) {
86
+ headerToolbar = table.getAggregation('headerToolbar');
87
+ }
88
+ return headerToolbar;
89
+ }
64
90
  }
65
91
  var __exports = {
66
92
  __esModule: true
@@ -10,6 +10,8 @@ import { getControlById, isA } from '../../../utils/core';
10
10
  import { DialogFactory, DialogNames } from '../../dialog-factory';
11
11
  import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
12
12
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
13
+ import type OverflowToolbar from 'sap/m/OverflowToolbar';
14
+ import { NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
13
15
 
14
16
  export const CREATE_TABLE_ACTION = 'create-table-action';
15
17
  const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
@@ -25,6 +27,25 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
25
27
  ]);
26
28
  }
27
29
 
30
+ async initialize(): Promise<void> {
31
+ const processChild = (child: NestedQuickActionChild, mapKey: string) => {
32
+ const table = this.tableMap[mapKey]?.table;
33
+ if (table) {
34
+ const headerToolbar = this.getHeaderToolbar(table);
35
+ if (!headerToolbar) {
36
+ child.enabled = false;
37
+ child.tooltip = this.context.resourceBundle.getText('NO_TABLE_HEADER_TOOLBAR');
38
+ }
39
+ }
40
+
41
+ child.children.forEach((nestedChild, idx) => processChild(nestedChild, `${mapKey}/${idx.toFixed(0)}`));
42
+ };
43
+
44
+ await super.initialize();
45
+
46
+ // disable nested actions based on conditions
47
+ this.children.forEach((nestedChild, idx) => processChild(nestedChild, `${idx.toFixed(0)}`));
48
+ }
28
49
  async execute(path: string): Promise<FlexCommand[]> {
29
50
  const { table, iconTabBarFilterKey, sectionInfo } = this.tableMap[path];
30
51
  if (!table) {
@@ -45,12 +66,7 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
45
66
  this.iconTabBar.setSelectedKey(iconTabBarFilterKey);
46
67
  }
47
68
 
48
- let headerToolbar;
49
- if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
50
- headerToolbar = (table.getAggregation('items') as ManagedObject[])[0].getAggregation('headerToolbar');
51
- } else if (isA<Table>(M_TABLE_TYPE, table)) {
52
- headerToolbar = table.getAggregation('headerToolbar');
53
- }
69
+ const headerToolbar = this.getHeaderToolbar(table);
54
70
 
55
71
  // open dialogBox to add, and content is selected ByDefault
56
72
  if (headerToolbar) {
@@ -62,4 +78,19 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
62
78
  }
63
79
  return [];
64
80
  }
81
+
82
+ getHeaderToolbar(table: UI5Element): ManagedObject | ManagedObject[] | OverflowToolbar | null | undefined {
83
+ let headerToolbar;
84
+ if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
85
+ headerToolbar = (table.getAggregation('items') as ManagedObject[]).find((item) => {
86
+ if (item.getAggregation('headerToolbar')) {
87
+ return true;
88
+ }
89
+ return isA<OverflowToolbar>('sap.m.OverflowToolbar', item);
90
+ });
91
+ } else if (isA<Table>(M_TABLE_TYPE, table)) {
92
+ headerToolbar = table.getAggregation('headerToolbar');
93
+ }
94
+ return headerToolbar;
95
+ }
65
96
  }
@@ -50,6 +50,7 @@ EMPTY_ROW_MODE_IS_NOT_SUPPORTED=This action is disabled because empty row mode i
50
50
  VARIANT_MANAGEMENT_FOR_PAGE_CONTROLS_IS_ALREADY_ENABLED=This option has been disabled because variant management is already enabled for tables and charts
51
51
  VARIANT_MANAGEMENT_FOR_TABLE_CONTROLS_IS_ALREADY_ENABLED=This option has been disabled because variant management is already enabled for the ''{0}''
52
52
  VARIANT_MANAGEMENT_FOR_CUSTOM_TABLES_NOT_SUPPORTED=Variant management cannot be set for custom table ''{0}''
53
+ NO_TABLE_HEADER_TOOLBAR=This option has been disabled because the table does not have a header toolbar.
53
54
 
54
55
  ADD_ANNOTATION_FILE=Add Annotation File for ''{0}''
55
56
  SHOW_ANNOTATION_FILE=Show Annotation File for ''{0}''
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.17.41",
12
+ "version": "0.17.43",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.3",
30
30
  "@sap-ux/btp-utils": "1.0.1",
31
- "@sap-ux/adp-tooling": "0.12.135",
31
+ "@sap-ux/adp-tooling": "0.12.136",
32
32
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.37",
33
33
  "@sap-ux/project-access": "1.29.8"
34
34
  },
@@ -48,11 +48,11 @@
48
48
  "supertest": "6.3.3",
49
49
  "@sap-ux-private/playwright": "0.1.0",
50
50
  "dotenv": "16.3.1",
51
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.65",
51
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.66",
52
52
  "@sap-ux/axios-extension": "1.18.6",
53
- "@sap-ux/store": "1.0.0",
54
53
  "@sap-ux/ui5-info": "0.8.3",
55
- "@sap-ux/i18n": "0.2.1"
54
+ "@sap-ux/i18n": "0.2.1",
55
+ "@sap-ux/store": "1.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "express": "4"