"use strict"; /** * Licensed Materials - Property of IBM * IBM Cognos Products: Cognos Analytics * Copyright IBM Corp. 2017, 2018 * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['bi/admin/nls/StringResource', 'bacontentnav/common/ContentListPageView', 'bi/commons/ui/properties/PropertyUIControl', 'bi/admin/system/services/TopicsListController', 'bi/commons/utils/Downloader', 'underscore'], function (StringResource, View, PropertyUIControl, TopicsListController, Downloader, _) { 'use strict'; //NOSONAR: meant to be strict var BuiltinTopicTab = View.extend({ loggingConfigUrl: 'v1/glug/config/logging', builtinTopicUrl: 'v1/glug/topics/builtin', customTopicUrl: 'v1/glug/topics/custom', favouriteTopicList: ['AAA', 'CM', 'MOSER', 'DISP', 'POGO_MSGS', 'DEFAULT', 'RSVP'], getContextMenuId: function getContextMenuId() { return "com.ibm.bi.admin.loggingTopicListViewMenu"; }, currentBuiltinSelection: { topicName: '', topicType: 'BUILTIN' }, currentTopic: { topicName: '', topicType: '' }, init: function init(options) { BuiltinTopicTab.inherited('init', this, arguments); this.showTitle = true; _.extend(this, options); this.topicsController = new TopicsListController({ glassContext: this.glassContext }); if (this.currentHomeValue.topicType === 'BUILTIN') { this.currentBuiltinSelection = this.currentHomeValue; } }, renderContent: function renderContent() { var aControls = []; this.$el.addClass("adminContentListView"); this.$el.addClass("builtInTopicList"); aControls.push({ 'type': 'CheckBox', 'name': 'showAllBuiltinTopic', 'label': StringResource.get('showAll'), 'checked': this.checkFavorite(), 'onChange': this.refreshList.bind(this), 'controlOnLeft': true }, { 'module': 'bi/content_apps/ui/RenderCallback', 'renderCallback': this.renderListControl.bind(this), 'el': this.$el, 'name': 'topicList' }); this._oPropertyUIControl = this._newPropertyUIControl(aControls); return this._oPropertyUIControl.render().then(function () { this.rightAlignLabel(); }.bind(this)); }, _newPropertyUIControl: function _newPropertyUIControl(items) { return new PropertyUIControl({ 'glassContext': this.glassContext, 'el': this.$el, 'items': items }); }, rightAlignLabel: function rightAlignLabel() { var $showAllParentDiv = this._oPropertyUIControl.getProperty('showAllBuiltinTopic').getPropertyNode().parent(); $showAllParentDiv.addClass('showAllBuiltinTopicFlexRightAlignControl'); }, checkFavorite: function checkFavorite() { var isChecked = true; if (_.contains(this.favouriteTopicList, this.currentBuiltinSelection.topicName)) { isChecked = false; } return isChecked; }, _getSelectedTopic: function _getSelectedTopic() { var selectedDefaultItem = this._listControl.getSelectedObjects()[0]; if (!_.isUndefined(selectedDefaultItem)) { this.currentBuiltinSelection.topicName = selectedDefaultItem.id; this.currentValue = this.currentBuiltinSelection; } }, getSelectedObjects: function getSelectedObjects() { var i; var rowObjects = []; var ancestors = this._listControl.contentView.getAncestors(); for (i = 0; i < this.aSelectedRows.length; i += 1) { var obj = this._dTable.fnGetData(this.aSelectedRows[i]); if (!obj[ContentStoreObject.ANCESTORS] && ancestors && ancestors.length > 0) { obj[ContentStoreObject.ANCESTORS] = ancestors; } rowObjects.push(obj); } return rowObjects; }, renderListControl: function renderListControl(container) { if (!_.isUndefined(container)) { this.$container = $(container); } if (_.isUndefined(this.$container)) { this.$container = this.$el; } this.$wrapper = $('