'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. 2014, 2020
*|
*| US Government Users Restricted Rights - Use, duplication or disclosure
*| restricted by GSA ADP Schedule Contract with IBM Corp.
*+------------------------------------------------------------------------+
*/
// this Class should be removed completely when the focus mode epic 276983 is completed
define(['../../../widgets/livewidget/nls/StringResources', '../visSwitcher/VisChangerView', '../../../DynamicFileLoader', '../../../visualizations/vipr/VIPRLibraries', '../../../widgets/livewidget/util/VisUtil', '../../../lib/@waca/dashboard-common/dist/api/Error', 'jquery', 'underscore'], function (resources, VisChangerView, DynamicFileLoader, VIPRLibraries, VisUtil, APIError, $, _) {
/**
* INTENT: VisExpandMode should be used as the entry point to expand mode (also known as focus mode) processing.
* //TODO: This function is just roughed in to partition code out of the widget.
* //TODO: In the general widget code, it is known as expandview so perhaps this should be renamed to match...but in some respects this is more of a controller
*/
return function () {
function VisExpandMode() {
_classCallCheck(this, VisExpandMode);
var options = arguments.length <= 0 ? undefined : arguments[0];
this.dashboard = options.dashboardApi;
this.visualization = options.visualization;
this.widgetApi = options.widgetApi;
this.iconsFeature = this.dashboard.getFeature('Icons');
this.ownerWidget = options.ownerWidget;
this.$el = options.$el;
this.$parent = this.$el.parent();
this.visualization.on('change:type', this._updateVizTypeTitle, this);
}
VisExpandMode.prototype.destroy = function destroy() {
if (this.dataSlotsView) {
this.dataSlotsView.remove();
this.dataSlotsView = null;
}
if (this.visChangeView) {
this.visChangeView.remove();
this.visChangeView = null;
}
this.visualization.off('change:Type', this._updateVizTypeTitle, this);
};
VisExpandMode.prototype.onDrop = function onDrop(dragObject) {
if (this.dataSlotsView && this.dataSlotsView.isSlotSelected()) {
if (this.dataSlotsView.isSelectedSlotLocalFilters()) {
this.dataSlotsView.onDropContext(dragObject);
} else {
this.dataSlotsView.onDrop(dragObject, this.dataSlotsView.getFocusSlot());
}
return true; //expand mode processed the drop
}
return false; //this isn't expand mode.
};
VisExpandMode.prototype.onRestore = function onRestore() {
this.$parent.prepend(this.$header);
if (this.dataSlotsView) {
this.dataSlotsView.remove();
this.dataSlotsView = null;
}
if (this.ownerWidget._currVis) {
this.ownerWidget._currVis.onRestore();
}
};
VisExpandMode.prototype.renderSlotsView = function renderSlotsView() {
return this.dataSlotsView && this.dataSlotsView.render();
};
VisExpandMode.prototype.getExpandModeContent = function getExpandModeContent($container) {
var _this = this;
this.ownerWidget.trigger('expandedView:visible');
$container.addClass('widgetExpanded');
// close the conditional histogram
if (this.ownerWidget._currVis) {
this.ownerWidget._currVis.setInExpandedMode();
}
var boardFillColor = this.ownerWidget.boardModel.layout.fillColor;
var boardBackgroundColorClass = boardFillColor ? this.ownerWidget.getThemeColorClassName(boardFillColor, 'fill') : '';
this.$parent = this.$el.parent();
this.$header = this.$parent.find('.widgetHeader');
this.$previewMessage = this.$parent.find('.customVisPreviewMessage');
var changeVisIcon = this.iconsFeature.getIcon('visualizations-changeVisualization');
var chevronLeftIcon = this.iconsFeature.getIcon('common-chevron_left');
var resizePanel = this.iconsFeature.getIcon('resizePanel');
var $content = $('
');
//Chart region
var $preview = $('');
var visualisationBtnDescriptionId = _.uniqueId('VisExpandModeVisualisationBtnDesc_');
var $visualisationBtn = $('