@adaptabletools/adaptable-plugin-master-detail-aggrid 16.2.4 → 17.0.0-canary.1

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.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # AdapTable Master Detail AgGrid Plugin Read Me
2
+
3
+ Version 7 of AdapTable introduced support for using Master-Detail grids in AG Grid.
4
+
5
+ It allows you to create a definition for the Detail grid which will apply for all detail grids.
6
+
7
+ This means that if you create a Format Column in Predefined Config it will apply in each detail grid.
8
+
9
+ ## How It Works
10
+
11
+ The `masterDetailAgGridPlugin` has 2 properties:
12
+
13
+ - *detailAdaptableOptions* - an `AdaptableOptions` object to be used for **every** Detail grid
14
+
15
+ - *onDetailInit: (api: AdaptableApi) => void* - an optional function which will be called whenever a Detail grid is opened (essentially initialised), providing you with the AdaptableApi instance for full programmatic access to all Adaptable features.
16
+
17
+ ### Example
18
+
19
+ We have set up a Master-Detail grid in AG Grid and the Adaptable Options object for the Master grid in the normal way.
20
+
21
+ And we have supplied the detail grid Adaptable Options in the plugins section. Here we create a Format Column in Predefined Config to be used in all Detail grids.
22
+
23
+ ```ts
24
+ // typical AG Grid GridOptions object but popuplated for use in a Master-Detail grid
25
+ // for more information see: https://www.ag-grid.com/javascript-grid-master-detail/
26
+ const gridOptions: GridOptions = {
27
+ columnDefs,
28
+ rowData,
29
+ masterDetail: true,
30
+ detailCellRendererParams: {
31
+ detailGridOptions: {
32
+ columnDefs: detailColumnDefs,
33
+ },
34
+ getDetailRowData: function(params: any) {
35
+ params.successCallback(params.data.squad);
36
+ },
37
+ },
38
+ isRowMaster: function(dataItem) {
39
+ return dataItem ? dataItem.squad.length > 0 : false;
40
+ },
41
+ .......
42
+ };
43
+
44
+ const adaptableOptions: AdaptableOptions = {
45
+ primaryKey: 'name',
46
+ userName: 'Demo User',
47
+ adaptableId: 'Master Detail Demo - Master Grid',
48
+ predefinedConfig: demoConfig,
49
+ gridOptions: { ...gridOptions, modules: AllEnterpriseModules },
50
+ plugins: [
51
+ masterDetailAgGridPlugin({
52
+ detailAdaptableOptions: {
53
+ primaryKey: 'name',
54
+ adaptableId: 'Master Detail Demo - Detail Grid',
55
+ predefinedConfig: {
56
+ FormatColumn: {
57
+ FormatColumns: [
58
+ {
59
+ Scope: {
60
+ ColumnIds: ['age'],
61
+ },
62
+ Style: {
63
+ BackColor: '#ffffe0',
64
+ },
65
+ Rule: { BooleanExpression: '[age]> 30'}
66
+ },
67
+ ],
68
+ },
69
+ },
70
+ },
71
+ }),
72
+ ],
73
+ };
74
+ adaptableApi = await Adaptable.init(adaptableOptions);
75
+ ```
76
+
77
+ ## Requirements
78
+
79
+ This plugin depends on the AG Grid `@ag-grid-enterprise/master-detail` Module (or `@ag-grid-enterprise/all-modules`) being present.
80
+
81
+
82
+ ## Help
83
+
84
+ Developers can learn how to access AdapTable programmatically at [AdapTable Documentation](https://docs.adaptabletools.com).
85
+
86
+ ## More Information
87
+
88
+ General information about Adaptable Tools is available at our [Website](http://www.adaptabletools.com)
89
+
90
+ ## Support
91
+
92
+ For all support enquiries please email [`support@adaptabletools.com`](mailto:support@adaptabletools.com) or [raise a Support Ticket](https://adaptabletools.zendesk.com/hc/en-us/requests/new).
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-plugin-master-detail-aggrid",
3
- "version": "16.2.4",
3
+ "version": "17.0.0-canary.1",
4
4
  "description": "",
5
5
  "homepage": "http://www.adaptabletools.com/",
6
6
  "author": {
7
7
  "name": "Jonny Wolfson",
8
8
  "email": "jonny.wolfson@adaptabletools.com"
9
9
  },
10
- "main": "src/index.js",
11
10
  "typings": "src/index.d.ts",
12
11
  "dependencies": {
13
12
  "tslib": "^2.3.0",
14
- "@adaptabletools/adaptable": "16.2.4"
13
+ "@adaptabletools/adaptable": "17.0.0-canary.1"
15
14
  },
16
15
  "peerDependencies": {
17
16
  "@ag-grid-enterprise/master-detail": ">=30.2.0"
17
+ },
18
+ "type": "module",
19
+ "exports": {
20
+ ".": "./src/index.js"
18
21
  }
19
22
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DetailCellRenderer = void 0;
4
- const detailCellRenderer_1 = require("@ag-grid-enterprise/master-detail/dist/cjs/es6/masterDetail/detailCellRenderer");
5
- const Adaptable_1 = require("@adaptabletools/adaptable/src/agGrid/Adaptable");
6
- const attachAddaptableColumnTypes_1 = require("@adaptabletools/adaptable/src/agGrid/attachAddaptableColumnTypes");
7
- const attachDetailCellRenderer_1 = require("./attachDetailCellRenderer");
1
+ import { DetailCellRenderer as BaseDetailCellRenderer } from '@ag-grid-enterprise/master-detail/dist/cjs/es6/masterDetail/detailCellRenderer';
2
+ import { Adaptable } from '@adaptabletools/adaptable/src/agGrid/Adaptable';
3
+ import { attachColumnTypes } from '@adaptabletools/adaptable/src/agGrid/attachAddaptableColumnTypes';
4
+ import { attachDetailCellRenderer } from './attachDetailCellRenderer';
8
5
  // @ts-ignore because we override the private setDetailGrid() method
9
- class DetailCellRenderer extends detailCellRenderer_1.DetailCellRenderer {
6
+ export class DetailCellRenderer extends BaseDetailCellRenderer {
10
7
  constructor() {
11
8
  super(...arguments);
12
9
  this.adaptableDestroyed = false;
@@ -17,8 +14,8 @@ class DetailCellRenderer extends detailCellRenderer_1.DetailCellRenderer {
17
14
  /**
18
15
  * This needs to be done here, as soon as possible for level 3 to work.
19
16
  */
20
- (0, attachDetailCellRenderer_1.attachDetailCellRenderer)(gridOptions);
21
- (0, attachAddaptableColumnTypes_1.attachColumnTypes)(gridOptions);
17
+ attachDetailCellRenderer(gridOptions);
18
+ attachColumnTypes(gridOptions);
22
19
  this._detailGridOptions = gridOptions;
23
20
  // @ts-ignore because method is private
24
21
  super.setDetailGrid(gridOptions);
@@ -48,7 +45,7 @@ class DetailCellRenderer extends detailCellRenderer_1.DetailCellRenderer {
48
45
  : detailAdaptableOptions.predefinedConfig;
49
46
  // AG Grid modules are already registered
50
47
  const agGridModules = masterAdaptable.getAgGridRegisteredModules();
51
- this.adaptableApi = await Adaptable_1.Adaptable.init(Object.assign(Object.assign({ adaptableId: `${masterAdaptable.adaptableOptions.adaptableId} Detail` }, detailAdaptableOptions), { predefinedConfig: Object.assign(Object.assign({}, predefinedConfig), { Dashboard: Object.assign({ IsCollapsed: true }, predefinedConfig.Dashboard) }), containerOptions: Object.assign(Object.assign({}, detailAdaptableOptions.containerOptions), { adaptableContainer: adaptableContainerId, agGridContainer: eDetailGrid }) }), { modules: agGridModules, gridOptions: detailGridOptions });
48
+ this.adaptableApi = await Adaptable.init(Object.assign(Object.assign({ adaptableId: `${masterAdaptable.adaptableOptions.adaptableId} Detail` }, detailAdaptableOptions), { predefinedConfig: Object.assign(Object.assign({}, predefinedConfig), { Dashboard: Object.assign({ IsCollapsed: true }, predefinedConfig.Dashboard) }), containerOptions: Object.assign(Object.assign({}, detailAdaptableOptions.containerOptions), { adaptableContainer: adaptableContainerId, agGridContainer: eDetailGrid }) }), { modules: agGridModules, gridOptions: detailGridOptions });
52
49
  // This is needed because setting data with resetGridData later the style from format column is not applied
53
50
  this.adaptableApi.internalApi.getAdaptableInstance().setupColumns();
54
51
  if (onDetailInit) {
@@ -74,4 +71,3 @@ class DetailCellRenderer extends detailCellRenderer_1.DetailCellRenderer {
74
71
  super.destroy();
75
72
  }
76
73
  }
77
- exports.DetailCellRenderer = DetailCellRenderer;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachDetailCellRenderer = void 0;
4
- const DetailCellRenderer_1 = require("./DetailCellRenderer");
5
- const attachDetailCellRenderer = (gridOptions) => {
1
+ import { DetailCellRenderer } from './DetailCellRenderer';
2
+ export const attachDetailCellRenderer = (gridOptions) => {
6
3
  gridOptions.detailCellRenderer = 'adaptableDetailCellRenderer';
7
4
  gridOptions.components = gridOptions.components || {};
8
- gridOptions.components.adaptableDetailCellRenderer = DetailCellRenderer_1.DetailCellRenderer;
5
+ gridOptions.components.adaptableDetailCellRenderer = DetailCellRenderer;
9
6
  };
10
- exports.attachDetailCellRenderer = attachDetailCellRenderer;
package/src/index.js CHANGED
@@ -1,25 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const types_1 = require("@adaptabletools/adaptable/types");
5
- const package_json_1 = require("../package.json");
6
- const version_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable/version"));
7
- const attachDetailCellRenderer_1 = require("./attachDetailCellRenderer");
8
- if (package_json_1.version !== version_1.default) {
1
+ import { AdaptablePlugin } from '@adaptabletools/adaptable/types';
2
+ import { version, name } from '../package.json';
3
+ import { version as coreVersion } from '@adaptabletools/adaptable/package.json';
4
+ import { attachDetailCellRenderer } from './attachDetailCellRenderer';
5
+ const suffix = name.endsWith('-cjs') ? '-cjs' : '';
6
+ if (version !== coreVersion) {
9
7
  console.warn(`
10
8
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
- !!!!!!! "@adaptabletools/adaptable-plugin-master-detail-aggrid" (v @${package_json_1.version}) and "@adaptabletools/adaptable" (v @${version_1.default}) have different versions - they should have the exact same version.
9
+ !!!!!!! "@adaptabletools/adaptable-plugin-master-detail-aggrid${suffix}" (v @${version}) and "@adaptabletools/adaptable${suffix}" (v @${coreVersion}) have different versions - they should have the exact same version.
12
10
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
11
  `);
14
12
  }
15
- class MasterDetailPlugin extends types_1.AdaptablePlugin {
13
+ class MasterDetailPlugin extends AdaptablePlugin {
16
14
  constructor(pluginOptions) {
17
15
  super(pluginOptions);
18
16
  this.pluginId = 'master-detail-aggrid';
19
17
  this.pluginOptions = pluginOptions;
20
18
  }
21
19
  beforeInit(adaptableOptions, agGridOptions) {
22
- (0, attachDetailCellRenderer_1.attachDetailCellRenderer)(agGridOptions.gridOptions);
20
+ attachDetailCellRenderer(agGridOptions.gridOptions);
23
21
  }
24
22
  }
25
- exports.default = (pluginOptions) => new MasterDetailPlugin(pluginOptions);
23
+ export default (pluginOptions) => new MasterDetailPlugin(pluginOptions);