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 componentMetadataProvider_1 = require("./componentMetadataProvider");
|
20 | var utils_1 = require("../../utils");
|
21 | var AgComponentUtils = (function () {
|
22 | function AgComponentUtils() {
|
23 | }
|
24 | AgComponentUtils.prototype.adaptFunction = function (propertyName, hardcodedJsFunction, type, source) {
|
25 | if (hardcodedJsFunction == null)
|
26 | return {
|
27 | component: null,
|
28 | type: type,
|
29 | source: source,
|
30 | dynamicParams: null
|
31 | };
|
32 | var metadata = this.componentMetadataProvider.retrieve(propertyName);
|
33 | if (metadata && metadata.functionAdapter) {
|
34 | return {
|
35 | type: type,
|
36 | component: metadata.functionAdapter(hardcodedJsFunction),
|
37 | source: source,
|
38 | dynamicParams: null
|
39 | };
|
40 | }
|
41 | return null;
|
42 | };
|
43 | AgComponentUtils.prototype.adaptCellRendererFunction = function (callback) {
|
44 | var Adapter = (function () {
|
45 | function Adapter() {
|
46 | }
|
47 | Adapter.prototype.refresh = function (params) {
|
48 | return false;
|
49 | };
|
50 | Adapter.prototype.getGui = function () {
|
51 | var callbackResult = callback(this.params);
|
52 | var type = typeof callbackResult;
|
53 | if (type === 'string' || type === 'number' || type === 'boolean') {
|
54 | return utils_1._.loadTemplate('<span>' + callbackResult + '</span>');
|
55 | }
|
56 | else {
|
57 | return callbackResult;
|
58 | }
|
59 | };
|
60 | Adapter.prototype.init = function (params) {
|
61 | this.params = params;
|
62 | };
|
63 | return Adapter;
|
64 | }());
|
65 | return Adapter;
|
66 | };
|
67 | AgComponentUtils.prototype.doesImplementIComponent = function (candidate) {
|
68 | if (!candidate)
|
69 | return false;
|
70 | return candidate.prototype && 'getGui' in candidate.prototype;
|
71 | };
|
72 | __decorate([
|
73 | context_1.Autowired("componentMetadataProvider"),
|
74 | __metadata("design:type", componentMetadataProvider_1.ComponentMetadataProvider)
|
75 | ], AgComponentUtils.prototype, "componentMetadataProvider", void 0);
|
76 | AgComponentUtils = __decorate([
|
77 | context_1.Bean("agComponentUtils")
|
78 | ], AgComponentUtils);
|
79 | return AgComponentUtils;
|
80 | }());
|
81 | exports.AgComponentUtils = AgComponentUtils;
|