UNPKG

6.34 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12 return c > 3 && r && Object.defineProperty(target, key, r), r;
13};
14var __metadata = (this && this.__metadata) || function (k, v) {
15 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16};
17Object.defineProperty(exports, "__esModule", { value: true });
18var dragAndDropService_1 = require("../dragAndDrop/dragAndDropService");
19var context_1 = require("../context/context");
20var moveColumnController_1 = require("./moveColumnController");
21var column_1 = require("../entities/column");
22var bodyDropPivotTarget_1 = require("./bodyDropPivotTarget");
23var columnController_1 = require("../columnController/columnController");
24var DropType;
25(function (DropType) {
26 DropType[DropType["ColumnMove"] = 0] = "ColumnMove";
27 DropType[DropType["Pivot"] = 1] = "Pivot";
28})(DropType || (DropType = {}));
29var BodyDropTarget = (function () {
30 function BodyDropTarget(pinned, eContainer) {
31 this.dropListeners = {};
32 this.pinned = pinned;
33 this.eContainer = eContainer;
34 }
35 BodyDropTarget.prototype.registerGridComp = function (gridPanel) {
36 this.gridPanel = gridPanel;
37 this.moveColumnController.registerGridComp(gridPanel);
38 switch (this.pinned) {
39 case column_1.Column.PINNED_LEFT:
40 this.eSecondaryContainers = this.gridPanel.getDropTargetLeftContainers();
41 break;
42 case column_1.Column.PINNED_RIGHT:
43 this.eSecondaryContainers = this.gridPanel.getDropTargetRightContainers();
44 break;
45 default:
46 this.eSecondaryContainers = this.gridPanel.getDropTargetBodyContainers();
47 break;
48 }
49 };
50 BodyDropTarget.prototype.isInterestedIn = function (type) {
51 // not interested in row drags
52 return type === dragAndDropService_1.DragSourceType.HeaderCell || type === dragAndDropService_1.DragSourceType.ToolPanel;
53 };
54 BodyDropTarget.prototype.getSecondaryContainers = function () {
55 return this.eSecondaryContainers;
56 };
57 BodyDropTarget.prototype.getContainer = function () {
58 return this.eContainer;
59 };
60 BodyDropTarget.prototype.init = function () {
61 this.moveColumnController = new moveColumnController_1.MoveColumnController(this.pinned, this.eContainer);
62 this.context.wireBean(this.moveColumnController);
63 var bodyDropPivotTarget = new bodyDropPivotTarget_1.BodyDropPivotTarget(this.pinned);
64 this.context.wireBean(bodyDropPivotTarget);
65 this.dropListeners[DropType.ColumnMove] = this.moveColumnController;
66 this.dropListeners[DropType.Pivot] = bodyDropPivotTarget;
67 this.dragAndDropService.addDropTarget(this);
68 };
69 BodyDropTarget.prototype.getIconName = function () {
70 return this.currentDropListener.getIconName();
71 };
72 // we want to use the bodyPivotTarget if the user is dragging columns in from the toolPanel
73 // and we are in pivot mode, as it has to logic to set pivot/value/group on the columns when
74 // dropped into the grid's body.
75 BodyDropTarget.prototype.getDropType = function (draggingEvent) {
76 if (this.columnController.isPivotMode()) {
77 // in pivot mode, then if moving a column (ie didn't come from toolpanel) then it's
78 // a standard column move, however if it came from teh toolpanel, then we are introducing
79 // dimensions or values to the grid
80 if (draggingEvent.dragSource.type === dragAndDropService_1.DragSourceType.ToolPanel) {
81 return DropType.Pivot;
82 }
83 else {
84 return DropType.ColumnMove;
85 }
86 }
87 else {
88 // it's a column, and not pivot mode, so always moving
89 return DropType.ColumnMove;
90 }
91 };
92 BodyDropTarget.prototype.onDragEnter = function (draggingEvent) {
93 // we pick the drop listener depending on whether we are in pivot mode are not. if we are
94 // in pivot mode, then dropping cols changes the row group, pivot, value stats. otherwise
95 // we change visibility state and position.
96 // if (this.columnController.isPivotMode()) {
97 var dropType = this.getDropType(draggingEvent);
98 this.currentDropListener = this.dropListeners[dropType];
99 this.currentDropListener.onDragEnter(draggingEvent);
100 };
101 BodyDropTarget.prototype.onDragLeave = function (params) {
102 this.currentDropListener.onDragLeave(params);
103 };
104 BodyDropTarget.prototype.onDragging = function (params) {
105 this.currentDropListener.onDragging(params);
106 };
107 BodyDropTarget.prototype.onDragStop = function (params) {
108 this.currentDropListener.onDragStop(params);
109 };
110 __decorate([
111 context_1.Autowired('context'),
112 __metadata("design:type", context_1.Context)
113 ], BodyDropTarget.prototype, "context", void 0);
114 __decorate([
115 context_1.Autowired('dragAndDropService'),
116 __metadata("design:type", dragAndDropService_1.DragAndDropService)
117 ], BodyDropTarget.prototype, "dragAndDropService", void 0);
118 __decorate([
119 context_1.Autowired('columnController'),
120 __metadata("design:type", columnController_1.ColumnController)
121 ], BodyDropTarget.prototype, "columnController", void 0);
122 __decorate([
123 context_1.PostConstruct,
124 __metadata("design:type", Function),
125 __metadata("design:paramtypes", []),
126 __metadata("design:returntype", void 0)
127 ], BodyDropTarget.prototype, "init", null);
128 return BodyDropTarget;
129}());
130exports.BodyDropTarget = BodyDropTarget;