1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Licensed Materials - Property of IBM
- * IBM Business Analytics (C) Copyright IBM Corp. 2018, 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./nls/StringResources'], function (ServiceabilityStringResources) {
- var ServiceabilityDataMapping = function () {
- function ServiceabilityDataMapping(visualizationAPI) {
- _classCallCheck(this, ServiceabilityDataMapping);
- this._visualizationAPI = visualizationAPI;
- }
- /**
- * @returns {object} The result of this result should be an object which will
- * be stringfied later.
- * @description this method will fetch the data mapping info of a live widget
- * through the APIs.
- */
- ServiceabilityDataMapping.prototype.toJSON = function toJSON() {
- var slotAPIs = this._visualizationAPI.getSlots().getSlotList();
- var jsonResult = slotAPIs.map(function (slotAPI) {
- var _ref;
- var slotDefinitionAPI = slotAPI.getDefinition();
- var dataItemAPIs = slotAPI.getDataItemList();
- return _ref = {}, _ref[slotDefinitionAPI.getId()] = {
- 'caption': slotDefinitionAPI.getCaption(),
- 'mandatory': !(slotDefinitionAPI.isOptional() === true),
- 'mapping': dataItemAPIs.map(function (dataItemAPI) {
- return dataItemAPI.getColumnId();
- })
- }, _ref;
- });
- return jsonResult;
- };
- /**
- * @description this method will fetch the data mapping info and construct a UI spec which defined
- * how the Data Mapping section will be displayed
- * @returns {object} The UI spec which will be consumed by ContentInfoAPI
- */
- ServiceabilityDataMapping.prototype.toUIJSON = function toUIJSON() {
- var headerData = {
- 0: ServiceabilityStringResources.get('slotDataMapping'),
- 1: ServiceabilityStringResources.get('slotID'),
- 2: ServiceabilityStringResources.get('slotCaption'),
- 3: ServiceabilityStringResources.get('slotMandatory')
- };
- var info = this.toJSON();
- var cellData = info.map(function (mappingSpec) {
- var id = Object.keys(mappingSpec)[0];
- return [mappingSpec[id].mapping.join(', '), id, mappingSpec[id].caption, mappingSpec[id].mandatory ? ServiceabilityStringResources.get('slotIsMandatory') : ServiceabilityStringResources.get('slotIsNotMandatory')];
- });
- return [{
- fieldName: ServiceabilityStringResources.get('slotMappingField'),
- fieldValue: {
- headerValue: function headerValue(col) {
- return headerData[col];
- },
- cellValue: function cellValue(row, col) {
- return cellData[row][col];
- },
- columnLength: 4,
- rowLength: info.length
- },
- type: 'SimpleTable'
- }];
- };
- return ServiceabilityDataMapping;
- }();
- return ServiceabilityDataMapping;
- });
- //# sourceMappingURL=ServiceabilityDataMapping.js.map
|