123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- '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 Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../lib/@waca/dashboard-common/dist/api/PropertiesProviderAPI', '../../../util/TransactionUtil'], function (_, APIFactory, PropertiesProviderAPI, TransactionUtil) {
- var VisPropertyProvider = function () {
- function VisPropertyProvider(options) {
- _classCallCheck(this, VisPropertyProvider);
- this.content = options.content;
- this.dashboard = options.dashboardAPI;
- var Properties = options.features.Properties;
- Properties.registerProvider(this.getAPI());
- this.model = this.content.getFeature('Models.internal').getWidgetModel();
- this.content.on('change:visualization:type', this.onVisualizationTypeChange, this);
- }
- VisPropertyProvider.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [PropertiesProviderAPI]);
- }
- return this._api;
- };
- VisPropertyProvider.prototype.destroy = function destroy() {
- this.content.off('change:visualization:type', this.onVisualizationTypeChange, this);
- this.content = null;
- };
- VisPropertyProvider.prototype.onVisualizationTypeChange = function onVisualizationTypeChange() {
- this._propertyList = null;
- this._propertyLayoutList = null;
- };
- VisPropertyProvider.prototype.getWidget = function getWidget() {
- return this.content;
- };
- VisPropertyProvider.prototype._getPropertyFromRawDefinition = function _getPropertyFromRawDefinition(name) {
- var definition = this.content.getFeature('Visualization').getDefinition();
- var rawProp = definition && definition.getProperty(name);
- if (rawProp) {
- return JSON.parse(JSON.stringify(rawProp));
- }
- };
- /**
- * todo: we dont need this after we use new api events.
- * @param {*} property
- * @param {*} widget
- */
- VisPropertyProvider.prototype.modifyPropertyWithSetterAndGetter = function modifyPropertyWithSetterAndGetter(property, widget) {
- var _this = this;
- // [livewidget-cleanup] todo: removed the dependenty from widget
- var propertySupport = widget.visModelManager.propertySupport;
- _.extend(property, {
- getPropertyValue: function getPropertyValue() {
- return propertySupport.getPropertyValue(property.id);
- },
- setPropertyValue: function setPropertyValue(value, transactionToken) {
- _this.updateProperty({
- id: property.id,
- value: value
- }, transactionToken);
- }
- });
- };
- /**
- * @returns true if the property is not a 'general' property (i.e. is a
- * visualization property that can be overriden by a user)
- */
- VisPropertyProvider.prototype.isAnOverridableVisProperty = function isAnOverridableVisProperty(property) {
- var commonProps = {
- 'fillColor': true,
- 'borderColor': true,
- 'transparency': true,
- 'showTitle': true,
- 'saveTitle': true,
- 'queryRefresh': true,
- 'datagrid.viewOption': true, // managed by the content props
- 'value.graphic.content': true, // managed by the content props
- 'value.graphic.currentScaleOption': true, // managed by the content props
- 'value.graphic.fillColor': true, // managed by the content props
- 'value.graphic.borderColor': true // managed by the content props
- };
- return !commonProps[property];
- };
- VisPropertyProvider.prototype.updateProperty = function updateProperty(property, transactionToken) {
- if (this.isAnOverridableVisProperty(property.id)) {
- var boardModel = this.dashboard.getFeature('internal').getBoardModel();
- var options = TransactionUtil.transactionTokenToOptions(transactionToken);
- var extendedOptions = _.extend({}, options, boardModel.getLanguageModelOptions(true));
- if (!extendedOptions.payloadData) {
- extendedOptions.payloadData = {};
- }
- extendedOptions.payloadData.skipUndoRedo = true;
- var widgetModel = this.content.getFeature('Models.internal').getWidgetModel();
- // Update the properties on the vismodel
- widgetModel.properties.set(property, _.extend({
- merge: true,
- remove: false
- }, extendedOptions));
- }
- };
- VisPropertyProvider.prototype._getWidget = function _getWidget() {
- return this.content.getFeature('livewidget.internal').getWidget();
- };
- VisPropertyProvider.prototype.getPropertyList = function getPropertyList() {
- var _this2 = this;
- if (!this._propertyList) {
- var propertyListFromDefinition = this._getPropertyFromRawDefinition('propertyList');
- if (propertyListFromDefinition && propertyListFromDefinition.length > 0) {
- propertyListFromDefinition.forEach(function (property) {
- if (_this2.isAnOverridableVisProperty(property.id)) {
- _this2.modifyPropertyWithSetterAndGetter(property, _this2._getWidget());
- if (property.editor && property.editor.uiControl && property.editor.uiControl.multilingual) {
- var translationService = _this2.dashboard.getFeature('TranslationService');
- if (translationService) {
- var _ref = _this2.model.getMultilingualAttribute(property.id) || {},
- multilingualProperty = _ref.multilingualProperty;
- translationService.processMultilingualProperty(property, multilingualProperty);
- }
- }
- }
- });
- } else {
- propertyListFromDefinition = [];
- }
- this._propertyList = propertyListFromDefinition;
- }
- // TODO: The following if section need to be removed once the feature flag is not used
- // when remove the feature flag,
- // 1. remove the property with id "condColorPalette" from BAcrosstab.json and BAGrid.json potentially
- // 2. remove the following if section
- if (this._isNewConditionalFormatFeature() && (this._isCrosstab() || this._isTable())) {
- this._propertyList = this._propertyList.filter(function (element) {
- return !(element.editor && element.editor.sectionId === 'visualization.colorPalette');
- });
- }
- return this._propertyList;
- };
- VisPropertyProvider.prototype.getPropertyLayoutList = function getPropertyLayoutList() {
- if (!this._propertyLayoutList) {
- var rawPropertyLayoutList = this._getPropertyFromRawDefinition('propertyLayoutList');
- this._propertyLayoutList = rawPropertyLayoutList ? rawPropertyLayoutList : [];
- }
- // TODO: The following if section need to be removed once the feature flag is not used
- // when remove the feature flag,
- // 1. remove the property layout definition of colorPalette at line 713 - 718 in BACrosstab.json and potentially BAGrid.json
- // 2. remove the following if section
- if (this._isNewConditionalFormatFeature() && (this._isCrosstab() || this._isTable())) {
- this._propertyLayoutList = this._propertyLayoutList.filter(function (element) {
- return element.id !== 'colorPalette';
- });
- }
- return this._propertyLayoutList;
- };
- VisPropertyProvider.prototype._isNewConditionalFormatFeature = function _isNewConditionalFormatFeature() {
- return !this.dashboard.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'xtabcondFormat', 'disabled');
- };
- VisPropertyProvider.prototype._isCrosstab = function _isCrosstab() {
- return this.content.getFeature('Visualization').getType() === 'Crosstab';
- };
- VisPropertyProvider.prototype._isTable = function _isTable() {
- return this.content.getFeature('Visualization').getType() === 'List';
- };
- return VisPropertyProvider;
- }();
- return VisPropertyProvider;
- });
- //# sourceMappingURL=VisPropertyProvider.js.map
|