Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/marionette/modules/RepresentationModule/RepresentationModule.02-DynamicDerivedConfigDataProvider.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 "use strict"; | |
2 | |
3 App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) { | |
4 | |
5 // Define private variables | |
6 var logger = null; | |
7 | |
8 /** | |
9 * Module initializer | |
10 * | |
11 */ | |
12 RepresentationModule.addInitializer(function(){ | |
13 | |
14 logger = Logger.get("App.RepresentationModule"); | |
15 | |
16 RepresentationModule.DynanicDerivedConfigDataProvider = Marionette.Object.extend({ | |
17 initialize: function() { | |
18 this._dynamicDerivedConfigDataByConfigClientId = {}; | |
19 this._kindByConfigClientId = {}; | |
20 }, | |
21 | |
22 get: function(config) { | |
23 if (!config) { | |
24 return null; | |
25 } | |
26 var configClientId = config.getClientId(); | |
27 | |
28 var configKind = config.getParameterValue("kind"); | |
29 if (this._kindByConfigClientId[configClientId] !== configKind) { | |
30 this.retire(configClientId); | |
31 this._kindByConfigClientId[configClientId] = configKind; | |
32 } | |
33 if (!this._dynamicDerivedConfigDataByConfigClientId[configClientId]) { | |
34 var master = App.RepresentationModule.getMasterForConfig(config); | |
35 var configGrid = this.options.configGridsByType[config.getConfigGridType()]; | |
36 this._dynamicDerivedConfigDataByConfigClientId[configClientId] = master.generateDynamicDerivedConfigData(config, configGrid); | |
37 } | |
38 | |
39 return this._dynamicDerivedConfigDataByConfigClientId[configClientId]; | |
40 }, | |
41 | |
42 retire: function (configClientId) { | |
43 var dynamicDerivedDataToRetire = this._dynamicDerivedConfigDataByConfigClientId[configClientId]; | |
44 if (dynamicDerivedDataToRetire) { | |
45 dynamicDerivedDataToRetire.destroy(); | |
46 } | |
47 delete this._dynamicDerivedConfigDataByConfigClientId[configClientId]; | |
48 delete this._kindByConfigClientId[configClientId]; | |
49 }, | |
50 | |
51 }); | |
52 }); | |
53 }, Logger); |