@progress/kendo-angular-pivotgrid 0.1.5 → 0.2.0-dev.202208181339

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 (45) hide show
  1. package/bundles/kendo-angular-pivotgrid.umd.js +1 -1
  2. package/configurator/configurator.component.d.ts +96 -0
  3. package/configurator/configurator.service.d.ts +17 -0
  4. package/configurator/draggable.directive.d.ts +32 -0
  5. package/configurator/drop-cue.service.d.ts +22 -0
  6. package/configurator/drop-target.directive.d.ts +32 -0
  7. package/data-binding/base-binding-directive.d.ts +27 -5
  8. package/data-binding/local-binding.directive.d.ts +8 -1
  9. package/data-binding/olap-binding.directive.d.ts +13 -1
  10. package/data-binding/pivotgrid-data.service.d.ts +13 -4
  11. package/esm2015/configurator/configurator.component.js +512 -0
  12. package/esm2015/configurator/configurator.service.js +38 -0
  13. package/esm2015/configurator/draggable.directive.js +94 -0
  14. package/esm2015/configurator/drop-cue.service.js +64 -0
  15. package/esm2015/configurator/drop-target.directive.js +82 -0
  16. package/esm2015/data-binding/base-binding-directive.js +68 -9
  17. package/esm2015/data-binding/local-binding.directive.js +20 -8
  18. package/esm2015/data-binding/olap-binding.directive.js +131 -6
  19. package/esm2015/data-binding/pivotgrid-data.service.js +26 -3
  20. package/esm2015/localization/custom-messages.component.js +41 -0
  21. package/esm2015/localization/localized-messages.directive.js +36 -0
  22. package/esm2015/localization/messages.js +71 -0
  23. package/esm2015/main.js +8 -0
  24. package/esm2015/models/configuration-change-event.js +18 -0
  25. package/esm2015/models/configurator-settings.js +14 -0
  26. package/esm2015/models/expanded-change-event.js +18 -0
  27. package/esm2015/package-metadata.js +1 -1
  28. package/esm2015/pivotgrid.component.js +350 -59
  29. package/esm2015/pivotgrid.module.js +43 -16
  30. package/esm2015/rendering/pivotgrid-cell.directive.js +6 -3
  31. package/esm2015/rendering/pivotgrid-table.component.js +38 -13
  32. package/esm2015/util.js +86 -0
  33. package/fesm2015/kendo-angular-pivotgrid.js +1744 -198
  34. package/localization/custom-messages.component.d.ts +18 -0
  35. package/localization/localized-messages.directive.d.ts +16 -0
  36. package/localization/messages.d.ts +160 -0
  37. package/main.d.ts +6 -0
  38. package/models/configuration-change-event.d.ts +36 -0
  39. package/models/configurator-settings.d.ts +32 -0
  40. package/models/expanded-change-event.d.ts +27 -0
  41. package/package.json +12 -6
  42. package/pivotgrid.component.d.ts +34 -3
  43. package/pivotgrid.module.d.ts +15 -7
  44. package/rendering/pivotgrid-table.component.d.ts +5 -3
  45. package/util.d.ts +31 -0
@@ -0,0 +1,94 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Directive, Input, Optional, HostBinding } from '@angular/core';
6
+ import { isDocumentAvailable } from '@progress/kendo-angular-common';
7
+ import { PIVOT_CONFIGURATOR_ACTION } from '@progress/kendo-pivotgrid-common';
8
+ import { Subscription } from 'rxjs';
9
+ import * as i0 from "@angular/core";
10
+ import * as i1 from "@progress/kendo-angular-common";
11
+ import * as i2 from "./configurator.service";
12
+ import * as i3 from "./drop-cue.service";
13
+ /**
14
+ * @hidden
15
+ */
16
+ export class DraggableChipDirective {
17
+ constructor(draggable, element, zone, service, cue) {
18
+ this.draggable = draggable;
19
+ this.element = element;
20
+ this.zone = zone;
21
+ this.service = service;
22
+ this.cue = cue;
23
+ this.touchActions = 'none';
24
+ this.initialX = {};
25
+ this.initialY = {};
26
+ this.subs = new Subscription();
27
+ }
28
+ get pointerEvents() {
29
+ return this.drag ? 'none' : undefined;
30
+ }
31
+ ngOnInit() {
32
+ this.zone.runOutsideAngular(() => this.subs.add(this.draggable.kendoPress
33
+ .subscribe((event) => {
34
+ if (isDocumentAvailable()) {
35
+ this.cue.create();
36
+ this.cue.attach();
37
+ this.initialX.current = event.clientX;
38
+ this.initialY.current = event.clientY;
39
+ }
40
+ })));
41
+ this.zone.runOutsideAngular(() => this.subs.add(this.draggable.kendoDrag
42
+ .subscribe((event) => {
43
+ if (isDocumentAvailable()) {
44
+ if (Math.abs(this.initialX.current - event.clientX) < 10 &&
45
+ Math.abs(this.initialY.current - event.clientY) < 10) {
46
+ return;
47
+ }
48
+ if (this.element.nativeElement) {
49
+ this.element.nativeElement.style.transform = `translate(${event.clientX - this.initialX.current}px, ${event.clientY - this.initialY.current}px)`;
50
+ }
51
+ }
52
+ this.drag = true;
53
+ this.service.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setDragItem, payload: this.item });
54
+ })));
55
+ this.zone.runOutsideAngular(() => this.subs.add(this.draggable.kendoRelease
56
+ .subscribe(() => {
57
+ this.drag = false;
58
+ if (this.service.state.dragItem) {
59
+ if (isDocumentAvailable()) {
60
+ if (this.element.nativeElement) {
61
+ this.element.nativeElement.style.transform = '';
62
+ }
63
+ this.cue.remove();
64
+ }
65
+ this.service.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.drop, payload: this.item });
66
+ this.service.state.dragItem = null;
67
+ this.service.state.dropDirection = null;
68
+ this.service.state.dropTarget = null;
69
+ this.service.state.dropZone = null;
70
+ }
71
+ })));
72
+ }
73
+ ngOnDestroy() {
74
+ this.subs.unsubscribe();
75
+ }
76
+ }
77
+ DraggableChipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DraggableChipDirective, deps: [{ token: i1.DraggableDirective, optional: true }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i2.ConfiguratorService }, { token: i3.DropCueService }], target: i0.ɵɵFactoryTarget.Directive });
78
+ DraggableChipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: DraggableChipDirective, selector: "[kendoChipDraggable]", inputs: { item: "item" }, host: { properties: { "style.pointerEvents": "this.pointerEvents", "style.touch-action": "this.touchActions" } }, ngImport: i0 });
79
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DraggableChipDirective, decorators: [{
80
+ type: Directive,
81
+ args: [{
82
+ selector: '[kendoChipDraggable]'
83
+ }]
84
+ }], ctorParameters: function () { return [{ type: i1.DraggableDirective, decorators: [{
85
+ type: Optional
86
+ }] }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i2.ConfiguratorService }, { type: i3.DropCueService }]; }, propDecorators: { pointerEvents: [{
87
+ type: HostBinding,
88
+ args: ['style.pointerEvents']
89
+ }], touchActions: [{
90
+ type: HostBinding,
91
+ args: ['style.touch-action']
92
+ }], item: [{
93
+ type: Input
94
+ }] } });
@@ -0,0 +1,64 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Injectable } from '@angular/core';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * @hidden
9
+ */
10
+ export const append = (element) => {
11
+ let appended = false;
12
+ return () => {
13
+ if (!appended) {
14
+ document.body.appendChild(element);
15
+ appended = true;
16
+ }
17
+ return element;
18
+ };
19
+ };
20
+ /**
21
+ * @hidden
22
+ */
23
+ export class DropCueService {
24
+ create() {
25
+ this.dom = document.createElement('span');
26
+ this.dom.style.position = 'absolute';
27
+ const wrapper = document.createElement('div');
28
+ wrapper.classList.add('k-drop-hint', 'k-drop-hint-v');
29
+ const hintStart = document.createElement('div');
30
+ hintStart.classList.add('k-drop-hint-start');
31
+ const hintLine = document.createElement('div');
32
+ hintLine.classList.add('k-drop-hint-line');
33
+ const hintEnd = document.createElement('div');
34
+ hintEnd.classList.add('k-drop-hint-end');
35
+ wrapper.append(hintStart, hintLine, hintEnd);
36
+ this.dom.append(wrapper);
37
+ this.hide();
38
+ }
39
+ attach() {
40
+ return append(this.dom)();
41
+ }
42
+ remove() {
43
+ if (this.dom && this.dom.parentElement) {
44
+ document.body.removeChild(this.dom);
45
+ this.dom = null;
46
+ }
47
+ }
48
+ hide() {
49
+ this.dom.style.display = "none";
50
+ }
51
+ position({ left, top, height }) {
52
+ this.dom.style.display = 'block';
53
+ this.dom.style.height = height + 'px';
54
+ this.dom.style.top = top + 'px';
55
+ this.dom.style.zIndex = '1000';
56
+ const width = this.dom.offsetWidth / 2;
57
+ this.dom.style.left = left - width + 'px';
58
+ }
59
+ }
60
+ DropCueService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropCueService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
61
+ DropCueService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropCueService });
62
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropCueService, decorators: [{
63
+ type: Injectable
64
+ }] });
@@ -0,0 +1,82 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Directive, Input } from "@angular/core";
6
+ import { PIVOT_CONFIGURATOR_ACTION } from "@progress/kendo-pivotgrid-common";
7
+ import { Subscription } from "rxjs";
8
+ import { position } from "../util";
9
+ import * as i0 from "@angular/core";
10
+ import * as i1 from "./configurator.service";
11
+ import * as i2 from "./drop-cue.service";
12
+ /**
13
+ * @hidden
14
+ */
15
+ export class DropTargetDirective {
16
+ constructor(element, configuratorService, cue, renderer, zone) {
17
+ this.element = element;
18
+ this.configuratorService = configuratorService;
19
+ this.cue = cue;
20
+ this.renderer = renderer;
21
+ this.zone = zone;
22
+ this.subs = new Subscription();
23
+ }
24
+ ngOnInit() {
25
+ const element = this.element.nativeElement;
26
+ this.elementType = element.nodeName === 'KENDO-CHIP' ? 'chip' : 'container';
27
+ this.zone.runOutsideAngular(() => {
28
+ this.subs.add(this.renderer.listen(element, 'mouseenter', this.handleMouseEnter.bind(this)));
29
+ this.subs.add(this.renderer.listen(element, 'mousemove', this.handleMouseMove.bind(this)));
30
+ this.subs.add(this.renderer.listen(element, 'mouseleave', this.handleMouseLeave.bind(this)));
31
+ });
32
+ }
33
+ ngOnDestroy() {
34
+ this.subs.unsubscribe();
35
+ }
36
+ handleMouseEnter(event) {
37
+ if (this.configuratorService.state.dragItem) {
38
+ if (this.elementType === 'chip') {
39
+ this.configuratorService.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setDropTarget, payload: this.item });
40
+ this.targetElement = event.target;
41
+ this.cue.position(position(event.target, this.configuratorService.state.dropDirection === 'before'));
42
+ }
43
+ this.configuratorService.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setDropZone, payload: this.axes });
44
+ }
45
+ }
46
+ handleMouseMove($event) {
47
+ if (this.configuratorService.state.dragItem) {
48
+ if (this.elementType !== 'chip') {
49
+ return;
50
+ }
51
+ if (this.element.nativeElement) {
52
+ const rect = this.element.nativeElement.getBoundingClientRect();
53
+ const x = $event.clientX - rect.left;
54
+ const direction = x < rect.width / 2 ? 'before' : 'after';
55
+ if ((direction !== this.configuratorService.state.dropDirection) && this.targetElement) {
56
+ this.cue.position(position(this.targetElement, direction === 'before'));
57
+ }
58
+ this.configuratorService.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setDropDirection, payload: direction });
59
+ }
60
+ }
61
+ }
62
+ handleMouseLeave() {
63
+ if (this.elementType === 'chip') {
64
+ return;
65
+ }
66
+ if (this.configuratorService.state.dragItem) {
67
+ this.configuratorService.parseConfiguratorState({ type: PIVOT_CONFIGURATOR_ACTION.setDropZone, payload: null });
68
+ }
69
+ }
70
+ }
71
+ DropTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropTargetDirective, deps: [{ token: i0.ElementRef }, { token: i1.ConfiguratorService }, { token: i2.DropCueService }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
72
+ DropTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: DropTargetDirective, selector: "[kendoDropTarget]", inputs: { item: "item", axes: "axes" }, ngImport: i0 });
73
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropTargetDirective, decorators: [{
74
+ type: Directive,
75
+ args: [{
76
+ selector: '[kendoDropTarget]'
77
+ }]
78
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.ConfiguratorService }, { type: i2.DropCueService }, { type: i0.Renderer2 }, { type: i0.NgZone }]; }, propDecorators: { item: [{
79
+ type: Input
80
+ }], axes: [{
81
+ type: Input
82
+ }] } });
@@ -2,9 +2,13 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { Directive, Input } from '@angular/core';
5
+ import { Directive, EventEmitter, Input, Output } from '@angular/core';
6
6
  import { headersReducer, HEADERS_ACTION, toTree } from '@progress/kendo-pivotgrid-common';
7
7
  import { Subscription } from 'rxjs';
8
+ import { PivotGridState } from '../models/configurator-settings';
9
+ import { ExpandChangeEvent } from '../models/expanded-change-event';
10
+ import { hasObservers } from '@progress/kendo-angular-common';
11
+ import { ConfigurationChangeEvent } from '../models/configuration-change-event';
8
12
  import * as i0 from "@angular/core";
9
13
  import * as i1 from "./pivotgrid-data.service";
10
14
  /**
@@ -27,11 +31,28 @@ export class PivotBaseBindingDirective {
27
31
  * Represents the measure axes configuration of the PivotGrid.
28
32
  */
29
33
  this.measureAxes = [];
30
- this.expandedStateSub = new Subscription();
34
+ /**
35
+ * Fires each time a row or column header gets expanded or collapsed by the end user. The event is preventable.
36
+ * If you prevent the event, the PivotGrid will not be rerendered with the new state, resulting from the end user interaction.
37
+ */
38
+ this.expandChange = new EventEmitter();
39
+ /**
40
+ * Fires when the Configurator Apply button is pressed. The event is preventable.
41
+ * If you prevent the event, the PivotGrid will not be rerendered with the new state, resulting from the configuration changes, applied through the configurator interface.
42
+ */
43
+ this.configurationChange = new EventEmitter();
44
+ this.subs = new Subscription();
45
+ }
46
+ /**
47
+ * @hidden
48
+ */
49
+ get state() {
50
+ return new PivotGridState(this.columnAxes, this.rowAxes, this.measureAxes);
31
51
  }
32
52
  ngOnInit() {
33
- this.loadData();
34
- this.expandedStateSub = this.dataService.expandedStateChange.subscribe((state) => {
53
+ this.loadData(this.state);
54
+ this.loadFields();
55
+ this.subs.add(this.dataService.expandedStateChange.subscribe((state) => {
35
56
  this.zone.run(() => {
36
57
  const isCol = state.tableType === 'columnHeader';
37
58
  const axes = isCol ? 'columnAxes' : 'rowAxes';
@@ -39,10 +60,28 @@ export class PivotBaseBindingDirective {
39
60
  const tree = toTree((isCol ? this.dataService.columns : this.dataService.rows || []).slice());
40
61
  this.updateHeaders(axes, tree, state.cell.path);
41
62
  });
42
- });
63
+ }));
64
+ this.subs.add(this.dataService.configuratorFieldChange.subscribe((state) => {
65
+ this.zone.run(() => {
66
+ if (hasObservers(this.configurationChange)) {
67
+ const event = new ConfigurationChangeEvent(state);
68
+ this.configurationChange.emit(event);
69
+ if (event.isDefaultPrevented()) {
70
+ return;
71
+ }
72
+ }
73
+ this.dataService.configuredFields.next({
74
+ columnAxes: state.columnAxes,
75
+ rowAxes: state.rowAxes,
76
+ measureAxes: state.measureAxes
77
+ });
78
+ this.loadData(state);
79
+ });
80
+ }));
81
+ this.dataService.directive = this;
43
82
  }
44
83
  ngOnDestroy() {
45
- this.expandedStateSub.unsubscribe();
84
+ this.subs.unsubscribe();
46
85
  }
47
86
  updateDataServiceFields() {
48
87
  this.dataService.normalizedData = this.dataState.data;
@@ -50,6 +89,14 @@ export class PivotBaseBindingDirective {
50
89
  this.dataService.columns = this.dataState.columns;
51
90
  this.dataService.updateRowsAndCols();
52
91
  }
92
+ updateConfiguratorFields() {
93
+ this.dataService.fields.next(this.configuratorFields);
94
+ this.dataService.configuredFields.next({
95
+ columnAxes: this.columnAxes,
96
+ rowAxes: this.rowAxes,
97
+ measureAxes: this.measureAxes
98
+ });
99
+ }
53
100
  updateHeaders(axes, tree, path) {
54
101
  // Action to determine expand/collapse state
55
102
  const action = {
@@ -58,15 +105,23 @@ export class PivotBaseBindingDirective {
58
105
  };
59
106
  // The `headersReducer` method is responsible for udpating
60
107
  // the expanded state based on the toggle action (expand/collapse)
61
- const newHeaders = headersReducer(this[axes].slice(), Object.assign(Object.assign({}, action), { tree }));
62
108
  // Update axes and reload data
109
+ const newHeaders = headersReducer(this[axes].slice(), Object.assign(Object.assign({}, action), { tree }));
110
+ if (hasObservers(this.expandChange)) {
111
+ const newState = Object.assign(Object.assign({}, this.state), { [axes]: newHeaders });
112
+ const event = new ExpandChangeEvent(newState);
113
+ this.expandChange.emit(event);
114
+ if (event.isDefaultPrevented()) {
115
+ return;
116
+ }
117
+ }
63
118
  this[axes] = newHeaders;
64
- this.loadData();
119
+ this.loadData(this.state);
65
120
  }
66
121
  ;
67
122
  }
68
123
  PivotBaseBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotBaseBindingDirective, deps: [{ token: i1.PivotGridDataService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
69
- PivotBaseBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotBaseBindingDirective, selector: "kendo-base-binding-directive", inputs: { columnAxes: "columnAxes", rowAxes: "rowAxes", measureAxes: "measureAxes" }, ngImport: i0 });
124
+ PivotBaseBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotBaseBindingDirective, selector: "kendo-base-binding-directive", inputs: { columnAxes: "columnAxes", rowAxes: "rowAxes", measureAxes: "measureAxes" }, outputs: { expandChange: "expandChange", configurationChange: "configurationChange" }, ngImport: i0 });
70
125
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotBaseBindingDirective, decorators: [{
71
126
  type: Directive,
72
127
  args: [{
@@ -78,4 +133,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
78
133
  type: Input
79
134
  }], measureAxes: [{
80
135
  type: Input
136
+ }], expandChange: [{
137
+ type: Output
138
+ }], configurationChange: [{
139
+ type: Output
81
140
  }] } });
@@ -3,7 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { Directive, Input } from '@angular/core';
6
- import { createDataTree, createLocalDataState, rootFields } from '@progress/kendo-pivotgrid-common';
6
+ import { createDataTree, createFlatSchemaDimensions, createLocalDataState, rootFields } from '@progress/kendo-pivotgrid-common';
7
7
  import { anyChanged } from '@progress/kendo-angular-common';
8
8
  import { PivotBaseBindingDirective } from './base-binding-directive';
9
9
  import * as i0 from "@angular/core";
@@ -18,26 +18,38 @@ const stringSeparator = '&';
18
18
  export class PivotLocalBindingDirective extends PivotBaseBindingDirective {
19
19
  constructor(dataService, zone) {
20
20
  super(dataService, zone);
21
+ this.type = 'local';
21
22
  this.createAxisSettings = (key) => (Object.assign({ key }, this.dimensions[key]));
22
23
  }
23
24
  ngOnChanges(changes) {
24
25
  if (anyChanged(['data', 'dimensions', 'columnAxes', 'rowAxes', 'measureAxes', 'measures'], changes)) {
25
- this.loadData();
26
+ this.loadData(this.state);
26
27
  }
27
28
  }
28
- loadData() {
29
- const rootColumnAxes = this.getRootAxes(this.columnAxes);
30
- const rootRowAxes = this.getRootAxes(this.rowAxes);
29
+ /**
30
+ * @hidden
31
+ */
32
+ fetchChildren(node) {
33
+ return node.children;
34
+ }
35
+ loadFields() {
36
+ this.configuratorFields = createFlatSchemaDimensions(this.dimensions, this.measures);
37
+ this.updateConfiguratorFields();
38
+ }
39
+ loadData(state) {
40
+ const { columnAxes, rowAxes, measureAxes } = state;
41
+ const rootColumnAxes = this.getRootAxes(columnAxes);
42
+ const rootRowAxes = this.getRootAxes(rowAxes);
31
43
  const columnSettings = rootColumnAxes.split(stringSeparator).map(this.createAxisSettings);
32
44
  const rowSettings = rootRowAxes.split(stringSeparator).map(this.createAxisSettings);
33
- const measuresSettings = this.measureAxes.map(m => this.measures.find(meas => String(meas.name) === String(m.name))).filter(Boolean);
45
+ const measuresSettings = measureAxes.map(m => this.measures.find(meas => String(meas.name) === String(m.name))).filter(Boolean);
34
46
  const dataTree = createDataTree(this.data, rowSettings, columnSettings, measuresSettings, bindingFields);
35
47
  this.dataState = createLocalDataState({
36
48
  dataTree,
37
49
  rowSettings,
38
50
  columnSettings,
39
- rowAxes: this.rowAxes,
40
- columnAxes: this.columnAxes,
51
+ rowAxes: rowAxes,
52
+ columnAxes: columnAxes,
41
53
  measures: measuresSettings,
42
54
  sort: [],
43
55
  fields: bindingFields
@@ -2,8 +2,9 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
+ import { __awaiter } from "tslib";
5
6
  import { Directive, Input } from '@angular/core';
6
- import { createDataState, fetchData } from '@progress/kendo-pivotgrid-common';
7
+ import { addKPI, buildKPIMeasures, createDataState, fetchData, fetchDiscover } from '@progress/kendo-pivotgrid-common';
7
8
  import { anyChanged } from '@progress/kendo-angular-common';
8
9
  import { PivotBaseBindingDirective } from './base-binding-directive';
9
10
  import * as i0 from "@angular/core";
@@ -14,22 +15,25 @@ import * as i1 from "./pivotgrid-data.service";
14
15
  export class PivotOLAPBindingDirective extends PivotBaseBindingDirective {
15
16
  constructor(dataService, zone) {
16
17
  super(dataService, zone);
18
+ this.type = 'olap';
17
19
  }
18
20
  ngOnChanges(changes) {
19
21
  if (anyChanged(['url', 'cube', 'catalog', 'columnAxes', 'rowAxes', 'measureAxes'], changes)) {
20
- this.loadData();
22
+ this.loadData(this.state);
23
+ this.loadFields();
21
24
  }
22
25
  }
23
- loadData() {
26
+ loadData(state) {
27
+ const { columnAxes, rowAxes, measureAxes } = state;
24
28
  this.dataService.loading.next(true);
25
29
  const options = {
26
30
  connection: {
27
31
  catalog: this.catalog,
28
32
  cube: this.cube
29
33
  },
30
- columnAxes: this.columnAxes,
31
- rowAxes: this.rowAxes,
32
- measureAxes: this.measureAxes
34
+ columnAxes: columnAxes,
35
+ rowAxes: rowAxes,
36
+ measureAxes: measureAxes
33
37
  };
34
38
  fetchData({ url: this.url }, JSON.parse(JSON.stringify(options)))
35
39
  .then(createDataState)
@@ -39,6 +43,127 @@ export class PivotOLAPBindingDirective extends PivotBaseBindingDirective {
39
43
  this.dataService.loading.next(false);
40
44
  });
41
45
  }
46
+ loadFields() {
47
+ const options = {
48
+ connection: {
49
+ catalog: this.catalog,
50
+ cube: this.cube
51
+ },
52
+ restrictions: {
53
+ catalogName: this.catalog,
54
+ cubeName: this.cube
55
+ },
56
+ command: 'schemaDimensions'
57
+ };
58
+ fetchDiscover({ url: this.url }, options)
59
+ .then((newFields) => {
60
+ addKPI(newFields);
61
+ this.configuratorFields = newFields;
62
+ this.updateConfiguratorFields();
63
+ });
64
+ }
65
+ updateFields(event, fields) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const newFields = fields.slice();
68
+ const field = this.getField(newFields, event);
69
+ if (field && field.uniqueName === '[KPIs]') {
70
+ const KPIs = this.normalizeKPIs(yield this.loadKPIs());
71
+ field.children = KPIs;
72
+ }
73
+ else if (field && field.type === 'kpi') {
74
+ field.children = buildKPIMeasures(field);
75
+ }
76
+ else if (field && !field.children) {
77
+ const additionalFields = yield this.loadAvailableFields(field);
78
+ field.children = additionalFields;
79
+ }
80
+ return field === null || field === void 0 ? void 0 : field.children;
81
+ });
82
+ }
83
+ /**
84
+ * @hidden
85
+ */
86
+ fetchChildren(event, fields) {
87
+ return this.updateFields(event, fields);
88
+ }
89
+ normalizeKPIs(data) {
90
+ for (let idx = 0, length = data.length; idx < length; idx++) {
91
+ data[idx].uniqueName = data[idx].name;
92
+ data[idx].type = 'kpi';
93
+ }
94
+ return data;
95
+ }
96
+ ;
97
+ getField(nodes = [], target) {
98
+ for (let i = 0; i < nodes.length; i++) {
99
+ const node = nodes[i];
100
+ if (node.uniqueName === target.uniqueName) {
101
+ return node;
102
+ }
103
+ let result = this.getField(node.children, target);
104
+ if (result !== null) {
105
+ return result;
106
+ }
107
+ }
108
+ return null;
109
+ }
110
+ ;
111
+ loadKPIs() {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const options = {
114
+ connection: {
115
+ catalog: this.catalog,
116
+ cube: this.cube
117
+ },
118
+ restrictions: {
119
+ catalogName: this.catalog,
120
+ cubeName: this.cube
121
+ },
122
+ command: 'schemaKPIs'
123
+ };
124
+ return fetchDiscover({ url: this.url }, options);
125
+ });
126
+ }
127
+ ;
128
+ loadAvailableFields(field) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ let command;
131
+ let dimensionUniqueName;
132
+ let hierarchyUniqueName;
133
+ let levelUniqueName;
134
+ let memberUniqueName;
135
+ let treeOp;
136
+ if (field.type === 2) {
137
+ command = 'schemaMeasures';
138
+ }
139
+ else if (field.dimensionUniqueName) {
140
+ command = 'schemaLevels';
141
+ hierarchyUniqueName = field.uniqueName;
142
+ }
143
+ else {
144
+ command = 'schemaHierarchies';
145
+ dimensionUniqueName = field.uniqueName;
146
+ }
147
+ const options = {
148
+ connection: {
149
+ catalog: this.catalog,
150
+ cube: this.cube
151
+ },
152
+ restrictions: {
153
+ catalogName: this.catalog,
154
+ cubeName: this.cube,
155
+ hierarchyUniqueName,
156
+ dimensionUniqueName,
157
+ levelUniqueName,
158
+ memberUniqueName,
159
+ treeOp
160
+ },
161
+ command
162
+ };
163
+ return fetchDiscover({ url: this.url }, options);
164
+ });
165
+ }
166
+ ;
42
167
  }
43
168
  PivotOLAPBindingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotOLAPBindingDirective, deps: [{ token: i1.PivotGridDataService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
44
169
  PivotOLAPBindingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PivotOLAPBindingDirective, selector: "[kendoPivotOLAPBinding]", inputs: { url: "url", cube: "cube", catalog: "catalog" }, exportAs: ["kendoPivotOLAPBinding"], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
@@ -3,21 +3,33 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { EventEmitter, Injectable, Output } from '@angular/core';
6
+ import { isDocumentAvailable } from '@progress/kendo-angular-common';
6
7
  import { toColumns, toData, toRows, toTree } from '@progress/kendo-pivotgrid-common';
8
+ import { matchAriaAttributes } from '../util';
7
9
  import { BehaviorSubject } from 'rxjs';
8
10
  import * as i0 from "@angular/core";
11
+ /**
12
+ * @hidden
13
+ */
14
+ let nextPivotGridId = 0;
9
15
  /**
10
16
  * @hidden
11
17
  */
12
18
  export class PivotGridDataService {
13
- constructor() {
19
+ constructor(ngZone) {
20
+ this.ngZone = ngZone;
14
21
  this.expandedStateChange = new EventEmitter();
22
+ this.configuratorFieldChange = new EventEmitter();
23
+ this.expandedFieldChange = new EventEmitter();
15
24
  this.columnHeaderRows = new BehaviorSubject([]);
16
25
  this.columnHeaderCols = new BehaviorSubject([]);
17
26
  this.rowHeaderCols = new BehaviorSubject([]);
18
27
  this.rowHeaderRows = new BehaviorSubject([]);
19
28
  this.valuesRows = new BehaviorSubject([]);
20
29
  this.loading = new BehaviorSubject(false);
30
+ this.fields = new BehaviorSubject([]);
31
+ this.configuredFields = new BehaviorSubject([]);
32
+ this.pivotGridId = nextPivotGridId++;
21
33
  }
22
34
  updateRowsAndCols() {
23
35
  const rowsTree = toTree((this.rows || []).slice());
@@ -31,12 +43,23 @@ export class PivotGridDataService {
31
43
  this.rowHeaderCols.next(new Array(rowHeaderBreadth).fill({}));
32
44
  this.rowHeaderRows.next(rowHeaderRows);
33
45
  this.valuesRows.next(toData((this.normalizedData || []).slice(), columnHeaderLeaves, rowHeaderLeaves, columnHeaderBreadth, rowHeaderDepth));
46
+ if (isDocumentAvailable()) {
47
+ this.ngZone.runOutsideAngular(() => {
48
+ // needed because all tables need to be rendered in accordance with the new settings
49
+ // before applying the required DOM attributes
50
+ setTimeout(() => matchAriaAttributes(this.wrapper));
51
+ });
52
+ }
34
53
  }
35
54
  }
36
- PivotGridDataService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
55
+ PivotGridDataService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
37
56
  PivotGridDataService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService });
38
57
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PivotGridDataService, decorators: [{
39
58
  type: Injectable
40
- }], propDecorators: { expandedStateChange: [{
59
+ }], ctorParameters: function () { return [{ type: i0.NgZone }]; }, propDecorators: { expandedStateChange: [{
60
+ type: Output
61
+ }], configuratorFieldChange: [{
62
+ type: Output
63
+ }], expandedFieldChange: [{
41
64
  type: Output
42
65
  }] } });