/** * Licensed Materials - Property of IBM * IBM Cognos Products: Cognos Analytics * Copyright IBM Corp. 2018, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define([ 'react', 'react-dom', 'ba-react-admin/ba-react-admin.min', 'underscore', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource' ], function (React, ReactDOM, AdminReact, _, ContentView, StringResource) { 'use strict'; //NOSONAR: meant to be strict var ADD_MEMBER_FIELDS = ['defaultName', 'disabled', 'hidden', 'permissions', 'searchPath', 'type']; var ADD_MEMBER_TYPES = ['distributionList', 'contact', 'namespaceFolder', 'account', 'role', 'group', 'namespace']; var AccountPickerSlideoutView = ContentView.extend({ init: function (options) { AccountPickerSlideoutView.inherited('init', this, arguments); _.extend(this, options); this.ajaxService = this.glassContext.getCoreSvc('.Ajax'); this.logger = this.glassContext.getCoreSvc('.Logger'); }, _isActiveItem: function (obj) { return obj.type === 'namespaceFolder' || (obj.type === 'namespace' && _.contains(obj.permissions, 'traverse')) || ((obj.type === 'role' || obj.type === 'group') && obj.hasChildren); }, _getMembers: function (storeID) { return AdminReact.AdminSvc.getNamespaceObjItems(this.ajaxService, storeID, { types: ADD_MEMBER_TYPES, fields: ADD_MEMBER_FIELDS }); }, _doSearch: function (storeId, searchTerm) { return AdminReact.AdminSvc.getSearchNamespace(this.ajaxService, storeId, { types: ADD_MEMBER_TYPES, method: 'contains', filter: searchTerm, limit: 100, offset: 0, fields: ADD_MEMBER_FIELDS }); }, remove: function () { AccountPickerSlideoutView.inherited('remove', this, arguments); ReactDOM.unmountComponentAtNode(this.$el[0]); }, openFilterlideout: function (aStore) { var menuContentCheckbox = [{ label: StringResource.get('contact'), value: 'contact' }, { label: StringResource.get('distributionList'), value: 'distributionList' }, { label: StringResource.get('account'), value: 'account' }, { label: StringResource.get('role'), value: 'role' }, { label: StringResource.get('group'), value: 'group' }]; this.glassContext.appController.showSlideOut({ parent: this.slideout, content: { module: 'bi/admin/common/slideout/FilterSlideout', id: 'FilterAddToContent', glassContext: this.glassContext, StringResource: StringResource, controllerStore: aStore, menuContentCheckbox: menuContentCheckbox } }); }, openSortSlideout: function (aStore) { var sortCols = [{ value: 'defaultName', label: StringResource.get('name') }, { value: 'modificationTime', label: StringResource.get('modified') }, { value: 'objectClass', label: StringResource.get('type') }]; this.glassContext.appController.showSlideOut({ parent: this.slideout, content: { module: 'bi/admin/common/slideout/SortSlideout', id: 'SortAddToContent', glassContext: this.glassContext, StringResource: StringResource, controllerStore: aStore, sortContent: sortCols } }); }, render: function () { var dPagingEnabled = AdminReact.AdminSvc.getConfiguration_EnableNamespaceChildrenPaging(this.ajaxService); var dItemsPerPage = AdminReact.AdminSvc.getConfiguration_NamespaceChildrenPerPage(this.ajaxService); return Promise.all([dPagingEnabled, dItemsPerPage]).catch(function (e) { this.logger.error(e); return [false, 0]; }.bind(this)).then(function (aResp) { var addMemberToPanel = React.createElement(AdminReact.AddMembersToPanel, { closePanel: function () { this.slideout.hide(); }.bind(this), addMembersTo: this.addCallback.bind(this), isActive: this._isActiveItem.bind(this), selectableTypes: ['distributionList', 'contact', 'account', 'role', 'group'], glassContext: this.glassContext, StringResource: StringResource, dialog: this, hideSearchAtRoot: true, wrapper: this, parent: this, store: AdminReact.DistListSelectableMembers.create({ itemsPerPage: aResp[0] === 'true' ? parseInt(aResp[1]) : 0, ancestors: [{ id: '', type: 'directory', defaultName: StringResource.get('directory') }] }) }); ReactDOM.render(addMemberToPanel, this.$el[0]); }.bind(this)); } }); return AccountPickerSlideoutView; });