@sap-ux/preview-middleware 0.17.42 → 0.17.44

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.
@@ -126,6 +126,10 @@ sap.ui.define([
126
126
  this.model.setProperty('/selectedIndex', indexArray.length - 1);
127
127
  this.model.setProperty('/targetAggregation', controlAggregation);
128
128
  this.model.setProperty('/index', indexArray);
129
+ const defaultIndex = Number(this.options.defaultAggregationArrayIndex);
130
+ if (defaultIndex >= 0) {
131
+ this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
132
+ }
129
133
  },
130
134
  createFragmentChange: async function _createFragmentChange(fragmentData) {
131
135
  const {fragmentName, index, targetAggregation} = fragmentData;
@@ -52,6 +52,7 @@ export type AddFragmentModel = JSONModel & {
52
52
  export interface AddFragmentOptions {
53
53
  title: string;
54
54
  aggregation?: string;
55
+ defaultAggregationArrayIndex?: number;
55
56
  }
56
57
 
57
58
  /**
@@ -203,6 +204,10 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
203
204
  this.model.setProperty('/selectedIndex', indexArray.length - 1);
204
205
  this.model.setProperty('/targetAggregation', controlAggregation);
205
206
  this.model.setProperty('/index', indexArray);
207
+ const defaultIndex = Number(this.options.defaultAggregationArrayIndex);
208
+ if (defaultIndex >= 0) {
209
+ this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
210
+ }
206
211
  }
207
212
 
208
213
  /**
@@ -54,6 +54,9 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
54
54
  ...('aggregation' in options && {
55
55
  aggregation: options.aggregation
56
56
  }),
57
+ ...('defaultAggregationArrayIndex' in options && {
58
+ defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
59
+ }),
57
60
  title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
58
61
  });
59
62
  break;
@@ -62,6 +62,9 @@ export class DialogFactory {
62
62
  case DialogNames.ADD_FRAGMENT:
63
63
  controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
64
64
  ...('aggregation' in options && { aggregation: options.aggregation }),
65
+ ...('defaultAggregationArrayIndex' in options && {
66
+ defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
67
+ }),
65
68
  title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
66
69
  });
67
70
  break;
@@ -19,11 +19,11 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../simple-q
19
19
  class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase {
20
20
  constructor(context) {
21
21
  super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context, [DIALOG_ENABLEMENT_VALIDATOR]);
22
+ this.appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
22
23
  }
23
24
  async initialize() {
24
- const appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
25
25
  const version = await getUi5Version();
26
- if (appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, {
26
+ if (this.appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, {
27
27
  major: 1,
28
28
  minor: 130
29
29
  })) {
@@ -36,7 +36,8 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../simple-q
36
36
  const overlay = OverlayRegistry.getOverlay(this.control) || [];
37
37
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
38
38
  aggregation: 'actions',
39
- title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION'
39
+ title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
40
+ defaultAggregationArrayIndex: 1
40
41
  });
41
42
  }
42
43
  return [];
@@ -4,7 +4,7 @@ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
4
4
  import { DialogFactory, DialogNames } from '../../dialog-factory';
5
5
  import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
6
6
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
7
- import { getApplicationType } from '../../../utils/application';
7
+ import { ApplicationType, getApplicationType } from '../../../utils/application';
8
8
  import { getUi5Version, isLowerThanMinimalUi5Version } from '../../../utils/version';
9
9
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
10
10
 
@@ -15,16 +15,17 @@ const CONTROL_TYPES = ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 's
15
15
  * Quick Action for adding a custom page action.
16
16
  */
17
17
  export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase implements SimpleQuickActionDefinition {
18
+ private readonly appType: ApplicationType;
18
19
  constructor(context: QuickActionContext) {
19
20
  super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context, [
20
21
  DIALOG_ENABLEMENT_VALIDATOR
21
22
  ]);
23
+ this.appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
22
24
  }
23
25
 
24
26
  async initialize(): Promise<void> {
25
- const appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
26
27
  const version = await getUi5Version();
27
- if (appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, { major: 1, minor: 130 })) {
28
+ if (this.appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, { major: 1, minor: 130 })) {
28
29
  return;
29
30
  }
30
31
  await super.initialize();
@@ -35,7 +36,8 @@ export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase im
35
36
  const overlay = OverlayRegistry.getOverlay(this.control) || [];
36
37
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
38
  aggregation: 'actions',
38
- title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION'
39
+ title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
40
+ defaultAggregationArrayIndex: 1
39
41
  });
40
42
  }
41
43
  return [];
@@ -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,23 +61,33 @@ 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) {
56
68
  const overlay = OverlayRegistry.getOverlay(headerToolbar) || [];
57
69
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
58
70
  aggregation: 'content',
59
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
71
+ title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION',
72
+ defaultAggregationArrayIndex: 1
60
73
  });
61
74
  }
62
75
  return [];
63
76
  }
77
+ getHeaderToolbar(table) {
78
+ let headerToolbar;
79
+ if (isA(SMART_TABLE_TYPE, table)) {
80
+ headerToolbar = table.getAggregation('items').find(item => {
81
+ if (item.getAggregation('headerToolbar')) {
82
+ return true;
83
+ }
84
+ return isA('sap.m.OverflowToolbar', item);
85
+ });
86
+ } else if (isA(M_TABLE_TYPE, table)) {
87
+ headerToolbar = table.getAggregation('headerToolbar');
88
+ }
89
+ return headerToolbar;
90
+ }
64
91
  }
65
92
  var __exports = {
66
93
  __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,21 +66,32 @@ 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) {
57
73
  const overlay = OverlayRegistry.getOverlay(headerToolbar as UI5Element) || [];
58
74
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
59
75
  aggregation: 'content',
60
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
76
+ title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION',
77
+ defaultAggregationArrayIndex: 1
61
78
  });
62
79
  }
63
80
  return [];
64
81
  }
82
+
83
+ getHeaderToolbar(table: UI5Element): ManagedObject | ManagedObject[] | OverflowToolbar | null | undefined {
84
+ let headerToolbar;
85
+ if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
86
+ headerToolbar = (table.getAggregation('items') as ManagedObject[]).find((item) => {
87
+ if (item.getAggregation('headerToolbar')) {
88
+ return true;
89
+ }
90
+ return isA<OverflowToolbar>('sap.m.OverflowToolbar', item);
91
+ });
92
+ } else if (isA<Table>(M_TABLE_TYPE, table)) {
93
+ headerToolbar = table.getAggregation('headerToolbar');
94
+ }
95
+ return headerToolbar;
96
+ }
65
97
  }
@@ -35,6 +35,7 @@ sap.ui.define(["sap/ui/dt/OverlayUtil", "../../../utils/core", "../../dialog-fac
35
35
  controlOverlay.setSelected(true);
36
36
  await DialogFactory.createDialog(controlOverlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
37
  aggregation: 'actions',
38
+ defaultAggregationArrayIndex: 0,
38
39
  title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
39
40
  });
40
41
  }
@@ -35,6 +35,7 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
35
35
 
36
36
  await DialogFactory.createDialog(controlOverlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
37
  aggregation: 'actions',
38
+ defaultAggregationArrayIndex: 0,
38
39
  title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
39
40
  });
40
41
  }
@@ -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.42",
12
+ "version": "0.17.44",
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.3",
30
- "@sap-ux/btp-utils": "1.0.1",
31
30
  "@sap-ux/adp-tooling": "0.12.136",
32
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.37",
32
+ "@sap-ux/btp-utils": "1.0.1",
33
33
  "@sap-ux/project-access": "1.29.8"
34
34
  },
35
35
  "devDependencies": {
@@ -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.67",
52
52
  "@sap-ux/axios-extension": "1.18.6",
53
53
  "@sap-ux/store": "1.0.0",
54
- "@sap-ux/ui5-info": "0.8.3",
55
- "@sap-ux/i18n": "0.2.1"
54
+ "@sap-ux/i18n": "0.2.1",
55
+ "@sap-ux/ui5-info": "0.8.3"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "express": "4"