Daniel@0: "use strict"; Daniel@0: Daniel@0: App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) { Daniel@0: Daniel@0: // Define private variables Daniel@0: var logger = null; Daniel@0: Daniel@0: /** Daniel@0: * Module initializer Daniel@0: * Daniel@0: */ Daniel@0: RepresentationModule.addInitializer(function(){ Daniel@0: Daniel@0: logger = Logger.get("App.RepresentationModule"); Daniel@0: Daniel@0: RepresentationModule.DynanicDerivedConfigDataProvider = Marionette.Object.extend({ Daniel@0: initialize: function() { Daniel@0: this._dynamicDerivedConfigDataByConfigClientId = {}; Daniel@0: this._kindByConfigClientId = {}; Daniel@0: }, Daniel@0: Daniel@0: get: function(config) { Daniel@0: if (!config) { Daniel@0: return null; Daniel@0: } Daniel@0: var configClientId = config.getClientId(); Daniel@0: Daniel@0: var configKind = config.getParameterValue("kind"); Daniel@0: if (this._kindByConfigClientId[configClientId] !== configKind) { Daniel@0: this.retire(configClientId); Daniel@0: this._kindByConfigClientId[configClientId] = configKind; Daniel@0: } Daniel@0: if (!this._dynamicDerivedConfigDataByConfigClientId[configClientId]) { Daniel@0: var master = App.RepresentationModule.getMasterForConfig(config); Daniel@0: var configGrid = this.options.configGridsByType[config.getConfigGridType()]; Daniel@0: this._dynamicDerivedConfigDataByConfigClientId[configClientId] = master.generateDynamicDerivedConfigData(config, configGrid); Daniel@0: } Daniel@0: Daniel@0: return this._dynamicDerivedConfigDataByConfigClientId[configClientId]; Daniel@0: }, Daniel@0: Daniel@0: retire: function (configClientId) { Daniel@0: var dynamicDerivedDataToRetire = this._dynamicDerivedConfigDataByConfigClientId[configClientId]; Daniel@0: if (dynamicDerivedDataToRetire) { Daniel@0: dynamicDerivedDataToRetire.destroy(); Daniel@0: } Daniel@0: delete this._dynamicDerivedConfigDataByConfigClientId[configClientId]; Daniel@0: delete this._kindByConfigClientId[configClientId]; Daniel@0: }, Daniel@0: Daniel@0: }); Daniel@0: }); Daniel@0: }, Logger);