123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * VisDefinitions
- */
- define(['underscore', '../../lib/@waca/core-client/js/core-client/ui/core/Class'], function (_, Class) {
- var VisDefinitions = null;
- VisDefinitions = Class.extend({
- init: function init(params) {
- VisDefinitions.inherited('init', this, arguments);
- this.mapDefinitionsById = {};
- this.jsonDefinitions = {};
- if (params) {
- this.jsonDefinitions = params.jsonDefinitions;
- for (var i = 0; i < params.jsonDefinitions.length; i++) {
- var def = params.jsonDefinitions[i];
- this.mapDefinitionsById[def.id] = def;
- }
- }
- },
- getDefinitionById: function getDefinitionById(id) {
- return this.mapDefinitionsById[id];
- },
- // return an array of all available definitions
- getDefinitions: function getDefinitions() {
- return this.jsonDefinitions;
- },
- removeObsoleteCachedVisDefinitions: function removeObsoleteCachedVisDefinitions() {
- var _this = this;
- var cachedDefIds = Object.keys(this.mapDefinitionsById);
- var allIds = this.jsonDefinitions.map(function (def) {
- return def.id;
- });
- var idsNoLongerExist = _.difference(cachedDefIds, allIds);
- idsNoLongerExist.forEach(function (id) {
- delete _this.mapDefinitionsById[id];
- });
- }
- });
- return VisDefinitions;
- });
- //# sourceMappingURL=VisDefinitions.js.map
|