123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2021
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../../../lib/@waca/dashboard-common/dist/ui/dialogs/CommonSelectItemsDialog', './SelectItemsNavigationDialog', 'jquery', 'underscore', 'text!../templates/MultipleColumnNavigation.html', '../../../lib/@waca/dashboard-common/dist/ui/NextView', '../nls/StringResources', 'doT'], function (View, SelectItemsDialog, $, _, MultipleColumnNavigation, NextView, stringResources, dot) {
- var MultipleColumnsNavigationDialog = View.extend({
- events: {
- 'primaryaction .itemRow': '_selectItem',
- 'keydown .itemRow': '_moveFocus'
- },
- _possibleItems: [],
- _eventHandler: null,
- _currentIndex: null,
- _currentElementSelected: null,
- _selectedDrillGroup: null,
- _nextView: null,
- _templateArray: [],
- init: function init(options) {
- MultipleColumnsNavigationDialog.inherited('init', this, arguments);
- this._possibleItems = options.state.possibleItems;
- this._templateArray = [];
- this._eventHandler = options.state.eventHandler;
- },
- render: function render() {
- this._renderDataItems();
- this.dotTemplate = dot.template(MultipleColumnNavigation);
- var sHtml = this.dotTemplate({ array: this._templateArray });
- this.$el.html(sHtml);
- this._setFocus();
- },
- _renderDataItems: function _renderDataItems() {
- var dataItemIds = _.keys(this._possibleItems);
- for (var i = 0; i < dataItemIds.length; i++) {
- this._templateArray.push({ columnId: dataItemIds[i], label: this._possibleItems[dataItemIds[i]][0].dataItem.getLabel() });
- }
- },
- _selectItem: function _selectItem(evt) {
- this._currentElementSelected = $(evt.currentTarget);
- var currentSelectedItem = $(evt.currentTarget).attr('data');
- var selectedItemInfo = this._possibleItems[currentSelectedItem];
- var selectViewOptions = {
- state: {
- possibleItems: selectedItemInfo,
- eventHandler: this._eventHandler,
- currentSelectedItem: currentSelectedItem
- }
- };
- var selectItems = new SelectItemsDialog(selectViewOptions);
- selectItems = selectItems.render();
- var nextViewOptions = {
- previousView: this.$el.closest('.toolbarPopoverContent'),
- nextView: selectItems,
- title: stringResources.get('navigateTitle')
- };
- this._nextView = new NextView(nextViewOptions);
- this._nextView = this._nextView.render();
- var contianer = this.$el.closest('.popover-content');
- contianer.append(this._nextView.$el);
- },
- _setFocus: function _setFocus() {
- this.$el.find('.itemRow').attr('tabindex', '-1');
- this.$el.find('.itemRow:first').attr('tabindex', '0');
- },
- handleSelection: function handleSelection(selectedItem) {
- var item = $('<div></div>').addClass('itemRow').attr('data', selectedItem[0].id);
- $('<div></div>').addClass('text').text(selectedItem[0].label).appendTo(item);
- $('<div class="rightArrow"><span class="wfg_rightarrow"></span></div>').appendTo(item);
- this._currentElementSelected.replaceWith(item);
- this._possibleItems[this._currentIndex].dataItemId = selectedItem[0].id;
- this._eventHandler.handleSelection(selectedItem);
- },
- changeDrillGroup: function changeDrillGroup(drillGroupId, dataItemId) {
- this._selectedDrillGroup = drillGroupId;
- this._eventHandler.changeDrillGroup(drillGroupId, dataItemId);
- },
- remove: function remove() {
- MultipleColumnsNavigationDialog.inherited('remove', this, arguments);
- if (this._nextView) {
- this._nextView.remove();
- }
- }
- });
- return MultipleColumnsNavigationDialog;
- });
- //# sourceMappingURL=MultipleColumnsNavigationDialog.js.map
|