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 gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
20 | var expressionService_1 = require("../valueService/expressionService");
|
21 | var ValueFormatterService = (function () {
|
22 | function ValueFormatterService() {
|
23 | }
|
24 | ValueFormatterService.prototype.formatValue = function (column, rowNode, $scope, value) {
|
25 | var formatter;
|
26 | var colDef = column.getColDef();
|
27 |
|
28 | if (rowNode && rowNode.rowPinned) {
|
29 | formatter = colDef.pinnedRowValueFormatter ? colDef.pinnedRowValueFormatter : colDef.valueFormatter;
|
30 | }
|
31 | else {
|
32 | formatter = colDef.valueFormatter;
|
33 | }
|
34 | var result = null;
|
35 | if (formatter) {
|
36 | var params = {
|
37 | value: value,
|
38 | node: rowNode,
|
39 | data: rowNode ? rowNode.data : null,
|
40 | colDef: column.getColDef(),
|
41 | column: column,
|
42 | api: this.gridOptionsWrapper.getApi(),
|
43 | columnApi: this.gridOptionsWrapper.getColumnApi(),
|
44 | context: this.gridOptionsWrapper.getContext()
|
45 | };
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | params.$scope = $scope;
|
52 | result = this.expressionService.evaluate(formatter, params);
|
53 | }
|
54 | else if (colDef.refData) {
|
55 | return colDef.refData[value];
|
56 | }
|
57 |
|
58 | if ((result === null || result === undefined) && Array.isArray(value)) {
|
59 | result = value.join(', ');
|
60 | }
|
61 | return result;
|
62 | };
|
63 | __decorate([
|
64 | context_1.Autowired('gridOptionsWrapper'),
|
65 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
66 | ], ValueFormatterService.prototype, "gridOptionsWrapper", void 0);
|
67 | __decorate([
|
68 | context_1.Autowired('expressionService'),
|
69 | __metadata("design:type", expressionService_1.ExpressionService)
|
70 | ], ValueFormatterService.prototype, "expressionService", void 0);
|
71 | ValueFormatterService = __decorate([
|
72 | context_1.Bean('valueFormatterService')
|
73 | ], ValueFormatterService);
|
74 | return ValueFormatterService;
|
75 | }());
|
76 | exports.ValueFormatterService = ValueFormatterService;
|