1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __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 | };
|
14 | var __metadata = (this && this.__metadata) || function (k, v) {
|
15 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
16 | };
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | var context_1 = require("../context/context");
|
19 | var utils_1 = require("../utils");
|
20 | var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
21 | var SelectableService = (function () {
|
22 | function SelectableService() {
|
23 | }
|
24 | SelectableService.prototype.init = function () {
|
25 | this.groupSelectsChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
|
26 | this.isRowSelectableFunc = this.gridOptionsWrapper.getIsRowSelectableFunc();
|
27 | };
|
28 | SelectableService.prototype.updateSelectableAfterGrouping = function (rowNode) {
|
29 | if (this.isRowSelectableFunc) {
|
30 | var nextChildrenFunc = function (rowNode) { return rowNode.childrenAfterGroup; };
|
31 | this.recurseDown(rowNode.childrenAfterGroup, nextChildrenFunc);
|
32 | }
|
33 | };
|
34 | SelectableService.prototype.updateSelectableAfterFiltering = function (rowNode) {
|
35 | if (this.isRowSelectableFunc) {
|
36 | var nextChildrenFunc = function (rowNode) { return rowNode.childrenAfterFilter; };
|
37 | this.recurseDown(rowNode.childrenAfterGroup, nextChildrenFunc);
|
38 | }
|
39 | };
|
40 | SelectableService.prototype.recurseDown = function (children, nextChildrenFunc) {
|
41 | var _this = this;
|
42 | children.forEach(function (child) {
|
43 | if (!child.group) {
|
44 | return;
|
45 | }
|
46 | if (child.hasChildren()) {
|
47 | _this.recurseDown(nextChildrenFunc(child), nextChildrenFunc);
|
48 | }
|
49 | var rowSelectable;
|
50 | if (_this.groupSelectsChildren) {
|
51 |
|
52 | var firstSelectable = utils_1._.find(nextChildrenFunc(child), 'selectable', true);
|
53 | rowSelectable = utils_1._.exists(firstSelectable);
|
54 | }
|
55 | else {
|
56 |
|
57 | rowSelectable = _this.isRowSelectableFunc(child);
|
58 | }
|
59 | child.setRowSelectable(rowSelectable);
|
60 | });
|
61 | };
|
62 | __decorate([
|
63 | context_1.Autowired('gridOptionsWrapper'),
|
64 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
65 | ], SelectableService.prototype, "gridOptionsWrapper", void 0);
|
66 | __decorate([
|
67 | context_1.PostConstruct,
|
68 | __metadata("design:type", Function),
|
69 | __metadata("design:paramtypes", []),
|
70 | __metadata("design:returntype", void 0)
|
71 | ], SelectableService.prototype, "init", null);
|
72 | SelectableService = __decorate([
|
73 | context_1.Bean('selectableService')
|
74 | ], SelectableService);
|
75 | return SelectableService;
|
76 | }());
|
77 | exports.SelectableService = SelectableService;
|