123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- '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: Dashboard (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/api/PropertiesProviderAPI', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../lib/@waca/core-client/js/core-client/utils/ClassFactory', '../../../app/nls/StringResources'], function (_, PropertiesProviderAPI, APIFactory, ClassFactory, StringResources) {
- var DashboardPropertiesProvider = function () {
- function DashboardPropertiesProvider(options) {
- _classCallCheck(this, DashboardPropertiesProvider);
- this._api = APIFactory.createAPI(this, [PropertiesProviderAPI]);
- this._properties = options.features.Properties;
- this._internal = options.features.internal;
- // TODO - we should not depend on the dashboard API in here
- this.dashboard = options.features.API;
- }
- DashboardPropertiesProvider.prototype.getAPI = function getAPI() {
- return this._api;
- };
- DashboardPropertiesProvider.prototype.initialize = function initialize() {
- // register self as a properties provider contributing align properties
- this._properties.registerProvider(this._api);
- return this._fetchThemes();
- };
- DashboardPropertiesProvider.prototype.destroy = function destroy() {
- if (this._properties) {
- this._properties.deregisterProvider(this._api);
- }
- };
- DashboardPropertiesProvider.prototype.getPropertyLayoutList = function getPropertyLayoutList() {
- return [{
- 'value': StringResources.get('dashboardProperties'),
- 'id': 'banner',
- 'type': 'Banner',
- 'editable': false
- }, {
- id: 'general',
- type: 'Group',
- label: StringResources.get('tabName_general')
- }, {
- id: 'colorsAndTheme',
- type: 'Section',
- label: StringResources.get('sectionName_colorsAndThemes'),
- position: 3
- }];
- };
- DashboardPropertiesProvider.prototype.getPropertyList = function getPropertyList() {
- var _this = this;
- var internalApi = this._internal;
- var boardModel = internalApi.getBoardModel();
- var propertiesModel = boardModel.properties;
- return [{
- id: 'theme',
- setPropertyValue: function setPropertyValue(value) {
- boardModel.set({ 'theme': value });
- },
- getPropertyValue: function getPropertyValue() {
- return boardModel.get('theme');
- },
- editor: {
- sectionId: 'general.colorsAndTheme',
- position: 1,
- uiControl: {
- type: 'DropDown',
- label: StringResources.get('propTheme'),
- getOptions: function getOptions() {
- return _this._themeListing;
- }
- }
- }
- }, {
- id: 'dashboardColorSet',
- setPropertyValue: function setPropertyValue(value) {
- propertiesModel.set({ 'dashboardColorSet': value });
- },
- getPropertyValue: function getPropertyValue() {
- return propertiesModel.get('dashboardColorSet') || 'userPaletteColor';
- },
- editor: {
- sectionId: 'general.colorsAndTheme',
- position: 1,
- uiControl: {
- type: 'NewPalette',
- paletteType: 'ColorPalette',
- sectionLabel: StringResources.get('propDashboardColorPalette'),
- newPaletteLabel: StringResources.get('propNewDashboardPaletteLabel'),
- linkLabel: StringResources.get('propDashboardChangePaletteLink'),
- ariaLabel: StringResources.get('propDashboardColorPalette'),
- includeUserColorPalette: true,
- onChange: function onChange(propertyName, propertyValue) {
- _this.setPropertyValue(propertyName, propertyValue);
- _this.dashboard.triggerDashboardEvent('properties:refreshPane', {
- sender: propertiesModel.id
- });
- }
- }
- }
- }, {
- id: 'fredIsRed',
- setPropertyValue: function setPropertyValue(value) {
- propertiesModel.set({ 'fredIsRed': value });
- },
- getPropertyValue: function getPropertyValue() {
- return propertiesModel.get('fredIsRed');
- },
- validatePropertyValue: function validatePropertyValue(value) {
- return {
- isValid: typeof value === 'boolean',
- message: 'fredIsRed property must be of type boolean.'
- };
- },
- editor: {
- sectionId: 'general.advanced',
- position: 1,
- uiControl: {
- type: 'ToggleButton',
- label: StringResources.get('propFredIsRed')
- }
- }
- }, {
- id: 'dataCache',
- setPropertyValue: function setPropertyValue(value) {
- var modelledValue = value === 'automatic' ? undefined : value;
- propertiesModel.set({
- 'localCache': modelledValue
- });
- },
- getPropertyValue: function getPropertyValue() {
- return propertiesModel.get('localCache') || 'automatic';
- },
- editor: {
- sectionId: 'general.advanced',
- position: 2,
- uiControl: {
- type: 'DropDown',
- label: StringResources.get('dataCache'),
- options: [{
- label: StringResources.get('dataCache_auto'),
- value: 'automatic'
- }, {
- label: StringResources.get('dataCache_on'),
- value: 'yes'
- }, {
- label: StringResources.get('dataCache_off'),
- value: 'no'
- }]
- }
- }
- }];
- };
- DashboardPropertiesProvider.prototype._fetchThemes = function _fetchThemes() {
- var _this2 = this;
- if (!this._themeListing) {
- this._themeListing = [];
- return ClassFactory.loadModule('text!dashboard-core/js/lib/@waca/dashboard-common/dist/themes/themeListing.json').then(function (themeListing) {
- var themesInfo = JSON.parse(themeListing);
- _.each(themesInfo.themes, function (theme) {
- _this2._themeListing.push({
- label: StringResources.get(theme.name + 'Label'),
- value: theme.name
- });
- });
- return _this2._themeListing;
- }, function () {
- _this2._themeListing = [];
- return _this2._themeListing;
- });
- } else {
- return Promise.resolve(this._themeListing);
- }
- };
- return DashboardPropertiesProvider;
- }();
- return DashboardPropertiesProvider;
- });
- //# sourceMappingURL=DashboardPropertiesProvider.js.map
|