"use strict"; /**  * Licensed Materials - Property of IBM  * IBM Cognos Products: Cognos Analytics  * Copyright IBM Corp. 2018  * US Government Users Restricted Rights - * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  */ define(['underscore', 'doT', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource', 'text!bi/admin/system/templates/PalettesTabTemplate.html', 'react-dom', 'react', 'bi/commons/ui/properties/PropertyUIControl', 'authoring-common'], function (_, dot, BasePane, StringResource, template, ReactDOM, React, PropertyUIControl, authoring) { 'use strict'; //NOSONAR: meant to be strict var PalettesTab = BasePane.extend({ init: function init(options) { PalettesTab.inherited('init', this, arguments); _.extend(this, options); }, _getPublicPalettes: function _getPublicPalettes() { return this.glassContext.getSvc('.Palette').then(function (svc) { return svc; }).then(function (svc) { return svc.getPublicPalettes(); }).then(function (response) { return { public: response }; }); }, _addCreatePaletteHandler: function _addCreatePaletteHandler() { var divForPaletteWidget = $("
"); divForPaletteWidget.addClass("createPaletteHook"); this.$el.append(divForPaletteWidget); this.$el.find('.bi-admin-create-global-palette').on("primaryaction", function () { this.newPaletteWidget = React.createElement(authoring.CustomPalette, { glassContext: this.glassContext, userClass: 'admin', type: 'global', removeDialog: function removeDialog() { ReactDOM.unmountComponentAtNode(divForPaletteWidget[0]); } }); ReactDOM.render(this.newPaletteWidget, this.$el.find('.createPaletteHook')[0], function () { this.openDialog(); }); }.bind(this)); }, _createChangePaletteView: function _createChangePaletteView(spec) { return new authoring.ChangePaletteView(spec); }, render: function render($body) { this.$el.html(dot.template(template)({ 'title': StringResource.get('global'), 'createGlobalPaletteLabel': StringResource.get('createGlobalPaletteLabel') })); this._addCreatePaletteHandler(); this._changePaletteView = this._createChangePaletteView({ 'el': this.$el.find('.bi-admin-palettes-content'), 'name': 'customPalettes', 'glassContext': this.glassContext, 'showHeader': false, 'useSections': false, 'getPalettes': this._getPublicPalettes, 'showRecentlyUsed': false, 'isAdminUI': true, 'menuItems': { 'public': ['edit', 'duplicate', 'delete'] } }); return this._changePaletteView.render(); } }); return PalettesTab; });