123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Dashboard (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../lib/@waca/core-client/js/core-client/ui/core/View', 'underscore', '../widgets/livewidget/nls/StringResources', 'react', 'react-dom', 'ca-ui-toolkit'], function (View, _, stringResources, React, ReactDOM, Toolkit) {
- /* eslint react/prop-types: 0 */ // TODO: Remove once we have prop-types brought in from glass.
- var Menu = Toolkit.Menu;
- /**
- * Wrapper around the Menu ui-toolkit item that we pass the list items into and handles the onchange
- *
- */
- var CustomGroupList = function (_React$Component) {
- _inherits(CustomGroupList, _React$Component);
- function CustomGroupList(props) {
- _classCallCheck(this, CustomGroupList);
- var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
- _this.state = {
- selected: {}
- };
- _this.removeView = props.removeView;
- _this.menuContent = props.possibleItems;
- return _this;
- }
- /*
- * Call the action associated with the current item selected
- */
- CustomGroupList.prototype._onChange = function _onChange(label, action) {
- action();
- this.removeView();
- };
- CustomGroupList.prototype.render = function render() {
- return React.createElement(
- Menu,
- { onChange: this._onChange.bind(this), selected: this.state.selected },
- React.createElement(Menu.List, { content: this.menuContent, name: 'customGroupList' })
- );
- };
- return CustomGroupList;
- }(React.Component);
- /**
- * @classdesc Creates a dropdown list for custom groups with the list items passed
- *
- * @public
- *
- * @param {object} options.listItems - The items to list
- */
- var CustomGroupActionsListDialog = function (_View) {
- _inherits(CustomGroupActionsListDialog, _View);
- function CustomGroupActionsListDialog(options) {
- _classCallCheck(this, CustomGroupActionsListDialog);
- var _this2 = _possibleConstructorReturn(this, _View.call(this, options));
- _this2.possibleItems = options.possibleItems;
- return _this2;
- }
- CustomGroupActionsListDialog.prototype.remove = function remove() {
- var flyout = this.toolbar && this.toolbar.flyout;
- if (this.$el) {
- ReactDOM.unmountComponentAtNode(this.$el[0]);
- }
- this.viewState = null;
- if (flyout) {
- flyout.destroy();
- }
- _View.prototype.remove.call(this);
- };
- /**
- * @param {Object} toolbar that the dialog is being rendered from.
- */
- CustomGroupActionsListDialog.prototype.renderCallBack = function renderCallBack(toolbar) {
- this.toolbar = toolbar;
- };
- /**
- * Needed so toolbar is set in NextView and the flyout can be closed when remove the dialog
- */
- CustomGroupActionsListDialog.prototype.preload = function preload() {
- return Promise.resolve();
- };
- CustomGroupActionsListDialog.prototype.render = function render() {
- this.$el.addClass('popoverDialogContainer customGroup');
- ReactDOM.render(React.createElement(CustomGroupList, { possibleItems: this.possibleItems, removeView: this.remove.bind(this) }), this.$el[0]);
- return this;
- };
- return CustomGroupActionsListDialog;
- }(View);
- return CustomGroupActionsListDialog;
- });
- //# sourceMappingURL=CustomGroupActionsListDialog.js.map
|