VIPRUtils.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: BI Dashboard
  6. *| (C) Copyright IBM Corp. 2017, 2020
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['underscore', '../../lib/@waca/core-client/js/core-client/ui/core/Class', './VIPRData', './data/VIPRData', './VIPRSlotMapping', './VIPRConfig', 'com/ibm/vipr/VIPR', '../interactions/BinningActionsUtils', './properties/PropertiesHelper'], function (_, Class, VIPRData_Deprecated, VIPRData, VIPRSlotMapping, VIPRConfig, VIPR, BinningActionsUtils, PropertiesHelper) {
  13. 'use strict';
  14. var VIPRUtils = Class.extend({
  15. createDataSlots: function createDataSlots(viprDefinition) {
  16. var vizDef = viprDefinition.vizDef;
  17. var config = this._getConfiguration(viprDefinition.id);
  18. var result = this._addToSlots(vizDef.slots, vizDef.dataSets, config);
  19. return result;
  20. },
  21. getPropertyPrefixes: function getPropertyPrefixes(viprDefinition) {
  22. var config = this._getConfiguration(viprDefinition.id);
  23. return config ? config.propertyPrefixes : undefined;
  24. },
  25. getListenForPropChanges: function getListenForPropChanges(viprDefinition) {
  26. var config = this._getConfiguration(viprDefinition.id);
  27. return config ? config.listenForPropChanges : undefined;
  28. },
  29. getGroupedProperty: function getGroupedProperty(viprDefinition) {
  30. var config = this._getConfiguration(viprDefinition.id);
  31. return config ? config.groupedProperty : undefined;
  32. },
  33. includeAllProperties: function includeAllProperties(viprDefinition) {
  34. var config = this._getConfiguration(viprDefinition.id);
  35. return config && config.includeAllProperties ? config.includeAllProperties : false;
  36. },
  37. _addMultiMeasureAndTagsToSlots: function _addMultiMeasureAndTagsToSlots(continuousSlots, slotCanAcceptMeasureGroupCategorical) {
  38. continuousSlots[0].multiMeasure = true;
  39. //to add tags to the slot, if we have a slot that name contains color , we add to that slot, otherwise to first non continues slot.
  40. var index = slotCanAcceptMeasureGroupCategorical.findIndex(function (slot) {
  41. return slot.name.toLowerCase().indexOf('color') !== -1;
  42. });
  43. if (index !== -1) {
  44. slotCanAcceptMeasureGroupCategorical[index].tags = ['ca.dashboard.repeatHere=true'];
  45. } else {
  46. slotCanAcceptMeasureGroupCategorical[0].tags = ['ca.dashboard.repeatHere=true'];
  47. }
  48. },
  49. // custom vis will support multi measure, based on following rules:
  50. // if each dataset has only one continues slot and at least one slot that is not continues(cat, any).
  51. _addMultiMeasureAndTagsToCustomVisDataset: function _addMultiMeasureAndTagsToCustomVisDataset(dataset, config) {
  52. if (config && config.isCustomVis) {
  53. var continuousSlots = _.filter(dataset.slots, function (slot) {
  54. if (slot.segments) {
  55. return _.filter(slot.segments, function (segments) {
  56. return segments.type === 'cont';
  57. });
  58. }
  59. return slot.type === 'cont';
  60. });
  61. var slotCanAcceptMeasureGroupCategorical = _.filter(dataset.slots, function (slot) {
  62. if (slot.segments) {
  63. return _.filter(slot.segments, function (segments) {
  64. return segments.type !== 'cont' && segments.subType !== 'geospatial';
  65. });
  66. }
  67. return slot.type !== 'cont' && slot.subType !== 'geospatial';
  68. });
  69. if (continuousSlots.length == 1 && slotCanAcceptMeasureGroupCategorical.length > 0) {
  70. this._addMultiMeasureAndTagsToSlots(continuousSlots, slotCanAcceptMeasureGroupCategorical);
  71. }
  72. }
  73. },
  74. _addToSlots: function _addToSlots() {
  75. var slots = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  76. var datasets = arguments[1];
  77. var config = arguments[2];
  78. var aSlots = {};
  79. if (!_.isEmpty(datasets)) {
  80. var datasetName;
  81. _.each(datasets, function (dataset) {
  82. datasetName = dataset.name;
  83. this._addMultiMeasureAndTagsToCustomVisDataset(dataset, config);
  84. _.each(dataset.slots, function (slot) {
  85. if (!_.isEmpty(slot.segments)) {
  86. var oSlot;
  87. _.each(slot.segments, function (segment) {
  88. //VIPR confirms segment is sub class of VIPR slot
  89. oSlot = this._buildSlot(segment, config, datasetName);
  90. oSlot.group = slot.name;
  91. if (aSlots[segment.name]) {
  92. aSlots[segment.name].datasetIdList.push(datasetName);
  93. } else {
  94. aSlots[segment.name] = oSlot;
  95. }
  96. }.bind(this));
  97. } else {
  98. if (aSlots[slot.name]) {
  99. aSlots[slot.name].datasetIdList.push(datasetName);
  100. } else {
  101. aSlots[slot.name] = this._buildSlot(slot, config, datasetName);
  102. }
  103. }
  104. }.bind(this));
  105. }.bind(this));
  106. }
  107. // Keep slots in the vida order, important for shared slots like in compositev2
  108. var slotOrder = [];
  109. slots.forEach(function (slot) {
  110. if (!_.isEmpty(slot.segments)) {
  111. slot.segments.forEach(function (segment) {
  112. slotOrder.push(segment.name);
  113. });
  114. } else {
  115. slotOrder.push(slot.name);
  116. }
  117. });
  118. return slotOrder.map(function (name) {
  119. return aSlots[name];
  120. });
  121. },
  122. _buildSlot: function _buildSlot(slot, config, datasetName) {
  123. var oCurSlot = this._getSlotObject(slot, config, datasetName);
  124. return config && config.slots ? _.extend(oCurSlot, config.slots[oCurSlot.id]) : oCurSlot;
  125. },
  126. _getSlotObject: function _getSlotObject(vizDefSlot, config, datasetName) {
  127. var slotType = this._getSlotType(vizDefSlot);
  128. var slot = {
  129. id: vizDefSlot.name,
  130. caption: vizDefSlot.caption,
  131. type: slotType,
  132. role: vizDefSlot.role,
  133. maxStackItems: vizDefSlot.maxLevels,
  134. optional: vizDefSlot.optional,
  135. multiplier: this._isMultiplier(vizDefSlot),
  136. stackItems: slotType !== 'ordinal',
  137. multiItems: vizDefSlot.multiDataItem,
  138. coachMark: vizDefSlot.coachMark
  139. };
  140. if (vizDefSlot.useCategoryAsValue) {
  141. slot.useCategoryAsValue = vizDefSlot.useCategoryAsValue;
  142. }
  143. if (datasetName) {
  144. slot.datasetIdList = [datasetName];
  145. }
  146. if (vizDefSlot.multiMeasure) {
  147. slot.multiMeasure = vizDefSlot.multiMeasure;
  148. }
  149. if (vizDefSlot.tags) {
  150. slot.tags = vizDefSlot.tags;
  151. }
  152. return config && config.slots && config.slots[slot.id] ? _.extend(slot, config.slots[slot.id]) : slot;
  153. },
  154. _getSlotType: function _getSlotType(slot) {
  155. if (slot.type === 'cat') {
  156. return 'category';
  157. } else if (slot.type === 'cont') {
  158. return 'ordinal';
  159. }
  160. return slot.type;
  161. },
  162. _isMultiplier: function _isMultiplier(slot) {
  163. var multipliers = ['repeatHorizontal', 'repeatVertical'];
  164. return multipliers.indexOf(slot.name) >= 0;
  165. },
  166. /**
  167. * @param {String} visId - id of the specic vis of interest
  168. * @returns {Object} single palette prop descriptions
  169. *'singlePaletteProps': {
  170. * column_color: {
  171. * id: 'defaultPaletteIndex',
  172. * labelId: 'propColumnColor',
  173. * defaultColorIndex: 0
  174. * },
  175. * line_color: {
  176. * id: 'lineColor',
  177. * labelId: 'propLineAndSymbolColor',
  178. * defaultColorIndex: 1
  179. * }
  180. *}
  181. */
  182. getSinglePaletteProperties: function getSinglePaletteProperties(visId) {
  183. var config = this._getConfiguration(visId);
  184. return config && config.colorPalettes && config.colorPalettes.single;
  185. },
  186. getViprWidgetPropertyInstances: function getViprWidgetPropertyInstances(viprProperties, propertyIds) {
  187. var propertyInstances = [];
  188. propertyIds.forEach(function (propertyId) {
  189. var propertyInstance = viprProperties.get(propertyId);
  190. if (propertyInstance) {
  191. propertyInstances.push(propertyInstance);
  192. }
  193. });
  194. return propertyInstances;
  195. },
  196. /**
  197. * Get single palettes by checking the configuration
  198. * Preferable to check the config for single palette props, because it has properties like defaultColorIndex that arent included in the vizBundle
  199. * If no single palette config is available, check the viprProperties
  200. * @returns {Object[]} Single palette property array
  201. */
  202. getSinglePalettes: function getSinglePalettes(viprProperties, visId) {
  203. var config = this._getConfiguration(visId);
  204. var paletteIds = config && config.colorPalettes && config.colorPalettes.single && Object.keys(config.colorPalettes.single) || [];
  205. if (paletteIds.length === 0) {
  206. return this.getSinglePalettesFromWidget(viprProperties);
  207. }
  208. return this.getViprWidgetPropertyInstances(viprProperties, paletteIds);
  209. },
  210. /**
  211. * Get single palettes by checking the viprProperties itself
  212. * @returns {Object[]} Single palette property array
  213. */
  214. getSinglePalettesFromWidget: function getSinglePalettesFromWidget(viprProperties) {
  215. var paletteIds = [];
  216. viprProperties.forEach(function (prop) {
  217. if (prop.type === 'color' && prop.tags && prop.tags.indexOf('palette') !== -1) {
  218. paletteIds.push(prop.name);
  219. }
  220. });
  221. return this.getViprWidgetPropertyInstances(viprProperties, paletteIds);
  222. },
  223. /**
  224. * Get all color palettes
  225. * @returns {Object[]} Palette property array
  226. */
  227. getPalettes: function getPalettes(viprProperties, visId) {
  228. var paletteIds = [];
  229. viprProperties.forEach(function (prop) {
  230. if (prop.type === 'palette') {
  231. paletteIds.push(prop.name);
  232. }
  233. });
  234. return this.getViprWidgetPropertyInstances(viprProperties, paletteIds).concat(this.getSinglePalettes(viprProperties, visId));
  235. },
  236. /**
  237. * @returns the default value from the bundle config if defined, undefined otherwise.
  238. */
  239. getDefaultValueForProperty: function getDefaultValueForProperty(bundleId, propertyName) {
  240. var defaultValue = void 0;
  241. var config = this._getConfiguration(bundleId);
  242. // If the property is defined in the config file get it.
  243. if (config && config.properties && config.properties[propertyName]) {
  244. defaultValue = config.properties[propertyName].defaultValue;
  245. }
  246. return defaultValue;
  247. },
  248. /**
  249. * Get the overriden property description from the configuration file if there is any.
  250. * @param {String} bundleId - id of the vis bundle
  251. * @param {String} propertyName - name of the property of interest
  252. */
  253. getOverridenDefaultForProperty: function getOverridenDefaultForProperty(bundleId, propertyName) {
  254. var result = {
  255. defaultValue: null,
  256. isActive: false
  257. };
  258. var config = this._getConfiguration(bundleId);
  259. // If the property is defined in the config file get it.
  260. if (config && config.properties && config.properties[propertyName]) {
  261. result.defaultValue = config.properties[propertyName].defaultValue;
  262. result.isActive = config.properties[propertyName].active;
  263. result.isReadOnly = config.properties[propertyName].isReadOnly;
  264. result.checkForValidValue = config.properties[propertyName].checkForValidValue;
  265. }
  266. return result;
  267. },
  268. /**
  269. * @param {String} bundleId - Vis bundle id
  270. * @param {Object} property - Description of the property of interest
  271. * @param {String} propertyName - name of the property of interest. Note, we
  272. * can not just use the name in the property param as we may be using a deprecated
  273. * property which means the property would have the new prop name.
  274. */
  275. overrideProperty: function overrideProperty(bundleId, property, propertyName) {
  276. var config = this._getConfiguration(bundleId);
  277. if (config && config.properties && config.properties[propertyName]) {
  278. // override the property
  279. // Need to clone the config prop or it will change the prop in the model.
  280. var clonedProp = _.clone(config.properties[propertyName]);
  281. property = _.defaults(clonedProp, property);
  282. property.overridden = true;
  283. }
  284. return property;
  285. },
  286. isRenderWithoutCompletingMapping: function isRenderWithoutCompletingMapping(bundleId) {
  287. var config = this._getConfiguration(bundleId);
  288. return !!(config && config.renderWithoutCompletingMapping === true); //Default: false
  289. },
  290. isRecommendable: function isRecommendable(bundleId) {
  291. var config = this._getConfiguration(bundleId);
  292. return !(config && config.isRecommendable === false); //Default: true
  293. },
  294. /**
  295. * Determine whether the property name is part of the inclusion list
  296. * @param {string} bundleId visualization id
  297. * @param {string} propertyName name of the property
  298. */
  299. isPropertyIncluded: function isPropertyIncluded(bundleId, propertyName) {
  300. var configuration = this._getConfiguration(bundleId);
  301. return configuration && _.contains(configuration.config.include, propertyName);
  302. },
  303. /**
  304. * Determine whether the property name is part of the exclusion list
  305. * @param {string} bundleId visualization id
  306. * @param {string} propertyName name of the property
  307. */
  308. isPropertyExcluded: function isPropertyExcluded(bundleId, propertyName) {
  309. var configuration = this._getConfiguration(bundleId);
  310. return _.contains(configuration.config.exclude, propertyName);
  311. },
  312. noDataQuery: function noDataQuery(bundleId) {
  313. var config = this._getConfiguration(bundleId);
  314. return !!(config && config.noDataQuery === true); //Default: false
  315. },
  316. /**
  317. * @return true if the charts are configrured to use FPD response as Chart-Insights API input
  318. */
  319. useFPDAsInsightsInput: function useFPDAsInsightsInput(bundleId) {
  320. var config = this._getConfiguration(bundleId);
  321. return !!(config && config.useFPDAsInsightsInput === true); //Default: false
  322. },
  323. isDisablePan: function isDisablePan(bundleId) {
  324. var config = this._getConfiguration(bundleId);
  325. return !!(config && config.disablePan === true); //Default: false
  326. },
  327. aggregateAndSortOnClient: function aggregateAndSortOnClient(bundleId) {
  328. var config = this._getConfiguration(bundleId);
  329. return !!(config && config.aggregateAndSortOnClient === true); //Default: false
  330. },
  331. /*Discussed with VIPR, currently we still need Data Row Limit guard*/
  332. getDataRowLimit: function getDataRowLimit(bundleId) {
  333. var config = this._getConfiguration(bundleId);
  334. return config && config.dataRowLimit;
  335. },
  336. /*Data Row Limit guard for IE*/
  337. getDataRowLimitIE: function getDataRowLimitIE(bundleId) {
  338. var config = this._getConfiguration(bundleId);
  339. return config && config.dataRowLimitIE;
  340. },
  341. getVisualizationTabs: function getVisualizationTabs(bundleId) {
  342. var config = this._getConfiguration(bundleId);
  343. return config && config.tabs;
  344. },
  345. getQueryHints: function getQueryHints(bundleId) {
  346. var config = this._getConfiguration(bundleId);
  347. return config ? config.queryHints : null;
  348. },
  349. doesConfigPropertyMatchExpected: function doesConfigPropertyMatchExpected(bundleId, configObjectProperty, expectedValue) {
  350. if (bundleId) {
  351. var config = this._getConfiguration(bundleId);
  352. if (config) {
  353. return config[configObjectProperty] ? config[configObjectProperty] === expectedValue : false;
  354. }
  355. }
  356. return false;
  357. },
  358. getBinning: function getBinning(bundleId) {
  359. var config = this._getConfiguration(bundleId);
  360. return config && config.binning ? config.binning : {};
  361. },
  362. canApplyAutoBin: function canApplyAutoBin(bundleId) {
  363. var config = this.getBinning(bundleId);
  364. var doesConfigSupportAutobinning = this.doesWidgetConfigSupportAutobinning(config);
  365. return doesConfigSupportAutobinning;
  366. },
  367. doesWidgetConfigSupportAutobinning: function doesWidgetConfigSupportAutobinning(config) {
  368. return BinningActionsUtils.doesWidgetConfigSupportAutobinning(config);
  369. },
  370. _getConfiguration: function _getConfiguration(id) {
  371. return VIPRConfig.getConfig(id);
  372. },
  373. _getConfigVal: function _getConfigVal(id, key) {
  374. if (this._getConfiguration(id) && this._getConfiguration(id)[key]) {
  375. return this._getConfiguration(id)[key];
  376. }
  377. return false;
  378. },
  379. applyRequiredConfiguration: function applyRequiredConfiguration(viprDefinitionId, requiredConfig, propertyValues) {
  380. // Merge the overrides into the existing configuration
  381. var lib = this._getConfiguration(viprDefinitionId);
  382. var override = lib.config.override;
  383. if (!override) {
  384. // If there are no overrides yet, create a new object
  385. override = {};
  386. lib.config.override = override;
  387. }
  388. _.each(requiredConfig, function (property) {
  389. var value = propertyValues[property];
  390. // See if there already is an override definition for this property. Otherwise, create it.
  391. if (!override[property]) {
  392. override[property] = {};
  393. }
  394. override[property].defaultValue = value;
  395. });
  396. },
  397. //TODO: revise for properties support
  398. _applyPropertyType: function _applyPropertyType(prop, vizProp) {
  399. if (vizProp.type === 'color') {
  400. prop.type = 'ColorPicker';
  401. prop.paletteType = 'ColorPalette';
  402. } else if (vizProp.type === 'boolean') {
  403. prop.type = 'CheckBox';
  404. prop.defaultValue = vizProp.defaultValue;
  405. } else if (vizProp.type === 'number') {
  406. // TODO
  407. prop.type = 'CheckBox';
  408. } else if (vizProp.type === 'enum') {
  409. prop.type = 'DropDown';
  410. prop.options = _.map(vizProp.possibleValues, function (option) {
  411. return {
  412. label: option.caption,
  413. value: option.name
  414. };
  415. });
  416. }
  417. return prop;
  418. },
  419. /**
  420. * @deprecated
  421. * @param {Array of JSONObject} inputPayload
  422. * @return {VIPRData} A Collection of VIPRDataSet
  423. **/
  424. createData: function createData(queryResults, visualization, content) {
  425. var hideAggTypeInAxisLabels = this.doesConfigPropertyMatchExpected(visualization.getDefinition().getId(), 'hideAggTypeInAxisLabels', true);
  426. return new VIPRData_Deprecated(queryResults, visualization, hideAggTypeInAxisLabels, content);
  427. },
  428. createQueryResultData: function createQueryResultData(queryResults, visualization, content) {
  429. var hideAggTypeInAxisLabels = this.doesConfigPropertyMatchExpected(visualization.getDefinition().getId(), 'hideAggTypeInAxisLabels', true);
  430. return new VIPRData(queryResults, visualization, hideAggTypeInAxisLabels, content);
  431. },
  432. createSlotMapping: function createSlotMapping(visualization) {
  433. return new VIPRSlotMapping(visualization);
  434. },
  435. createMetaDataEntries: function createMetaDataEntries(vizDefinition) {
  436. return vizDefinition.metaDataEntries.slice();
  437. },
  438. isRequiredConfig: function isRequiredConfig(id, prop) {
  439. return this.getRequiredConfig(id) && this.getRequiredConfig(id).indexOf(prop.name) > -1;
  440. },
  441. getRequiredConfig: function getRequiredConfig(id) {
  442. return this._getConfigVal(id, 'requiredConfig');
  443. },
  444. getCursor: function getCursor(id) {
  445. return this._getConfigVal(id, 'cursor');
  446. },
  447. isGeospatial: function isGeospatial(id) {
  448. return this._getConfigVal(id, 'geo');
  449. },
  450. supportsSortAction: function supportsSortAction(id) {
  451. return !this._getConfigVal(id, 'doesNotSupportSortAction');
  452. },
  453. supportsAnnotations: function supportsAnnotations(id) {
  454. return !this._getConfigVal(id, 'doesNotSupportAnnotations');
  455. },
  456. supportsContextualTopBottomAction: function supportsContextualTopBottomAction(id) {
  457. return !this._getConfigVal(id, 'doesNotSupportTopBottomAction');
  458. },
  459. supportsNonContextualTopBottomAction: function supportsNonContextualTopBottomAction(id) {
  460. return !this._getConfigVal(id, 'doesNotSupportTopBottomAction');
  461. },
  462. supportsFormatAction: function supportsFormatAction(id) {
  463. return !this._getConfigVal(id, 'doesNotSupportFormatAction');
  464. },
  465. supportsCustomGroupAction: function supportsCustomGroupAction(id) {
  466. return !this._getConfigVal(id, 'doesNotSupportCustomGroupAction');
  467. },
  468. supportsMaintainAxisScale: function supportsMaintainAxisScale(id) {
  469. return this._getConfigVal(id, 'supportsMaintainAxisScale');
  470. },
  471. supportsCustomDataSelection: function supportsCustomDataSelection(id) {
  472. return this._getConfigVal(id, 'enableCustomDataSelection');
  473. },
  474. /**
  475. * create a vida font object
  476. * @param vidaFontValues - an array of font props values [family,size,style,weight], e.g.: ['Anton', '12px', 'italic', 'weight']
  477. * @returns {Object} return a vida font object, VIPR parse method would return null if the values don't parse
  478. * {
  479. * 'family': [],
  480. * 'size': value,
  481. * 'style': value,
  482. * 'weight': value
  483. * }
  484. */
  485. createVidaFontProperty: function createVidaFontProperty(vidaFontValues) {
  486. if (vidaFontValues) {
  487. var family = VIPR.property.Font.parseFamily(vidaFontValues[0]);
  488. var size = VIPR.property.Length.parse(vidaFontValues[1]);
  489. var style = VIPR.property.FontStyle.parse(vidaFontValues[2]);
  490. var weight = VIPR.property.FontWeight.parse(vidaFontValues[3]);
  491. return VIPR.property.Font.create(family, size, style, weight);
  492. }
  493. },
  494. /**
  495. * parse a valid string to a vida font object
  496. * @param fontPropValue - a font-style string, e.g.: 'Anton 12px italic weight' or 'font-family: Condiment-Regular; font-size: 24px;'
  497. * @returns {Object} return a vida font object,
  498. * {
  499. * 'family': [],
  500. * 'size': value,
  501. * 'style': value,
  502. * 'weight': value
  503. * }
  504. */
  505. parseVidaFontProperty: function parseVidaFontProperty(fontPropValue) {
  506. return VIPR.property.Font.parse(fontPropValue);
  507. },
  508. getViprProperiesAndGroups: function getViprProperiesAndGroups(viprDefinition, properties, groups) {
  509. var viprProperties = viprDefinition.vizDef.properties;
  510. _.forEach(viprDefinition.vizDef.configuration, function (config) {
  511. properties.push(config);
  512. });
  513. return this._getViprProperiesAndGroups(viprProperties, properties, groups);
  514. },
  515. _getViprProperiesAndGroups: function _getViprProperiesAndGroups(viprProperties, properties, groups) {
  516. var _this = this;
  517. _.forEach(viprProperties, function (viprProperty) {
  518. if (viprProperty.type === 'group') {
  519. var propertiesName = _.pluck(viprProperty.properties, 'name');
  520. groups[viprProperty.name] = propertiesName;
  521. properties.push(viprProperty);
  522. return _this._getViprProperiesAndGroups(viprProperty.properties, properties, groups);
  523. } else {
  524. return properties.push(viprProperty);
  525. }
  526. });
  527. },
  528. _getPropertiesByNames: function _getPropertiesByNames(properties, propertiesNames) {
  529. var result = [];
  530. _.forEach(propertiesNames, function (name) {
  531. var property = _.find(properties, function (property) {
  532. return property.name === name;
  533. });
  534. if (property) {
  535. result.push(property);
  536. }
  537. });
  538. return result;
  539. },
  540. _getPropertiesByType: function _getPropertiesByType(properties, type) {
  541. return _.filter(properties, function (property) {
  542. return property.type === type;
  543. });
  544. },
  545. buildVidaFontPropertiesFromParts: function buildVidaFontPropertiesFromParts(fontChanges, currentPropertyValue) {
  546. return PropertiesHelper.buildVidaFontPropertiesFromParts(this, fontChanges, currentPropertyValue);
  547. },
  548. getVidaFontPropertiesPart: function getVidaFontPropertiesPart(part, fontPropertyValue) {
  549. return PropertiesHelper.getVidaFontPropertiesPart(this, part, fontPropertyValue);
  550. }
  551. });
  552. // create a singleton instance
  553. return new VIPRUtils();
  554. });
  555. //# sourceMappingURL=VIPRUtils.js.map