123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Cognos Analytics
- * Copyright IBM Corp. 2016, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', 'q', 'bi/admin/nls/StringResource', 'bi/commons/ui/StandardLayoutView', 'bi/commons/ui/SlideoutHeaderView', 'bi/commons/ui/ButtonBar', 'bi/admin/account/slideout/contentFilePicker/ContentFilePickerBody', 'bi/admin/account/slideout/contentFilePicker/TeamFolderController'], function (_, Q, StringResource, StandardLayoutView, SlideoutHeaderView, ButtonBar, ContentFilePickerBody, TeamFolderController) {
- var TeamFoldersPane = StandardLayoutView.extend({
- RESET_BUTTON_ID: 'resetSelectionBtn',
- APPLY_BUTTON_ID: 'applySelectionBtn',
- init: function init(options) {
- TeamFoldersPane.inherited('init', this, arguments);
- this.headerView = this._createHeader();
- this.bodyView = this._createBody();
- this.footerView = this._createFooter();
- },
- _createHeader: function _createHeader() {
- return new SlideoutHeaderView({
- 'title': this.title,
- 'slideout': this.slideout
- });
- },
- _createBody: function _createBody() {
- return new ContentFilePickerBody({
- 'glassContext': this.glassContext,
- 'className': 'setTeamFoldersView',
- 'slideout': this.slideout,
- 'onChange': this._onChange.bind(this),
- 'teamContentOnly': true,
- 'controller': this._createTeamFolderController()
- });
- },
- _createTeamFolderController: function _createTeamFolderController() {
- return new TeamFolderController({
- 'currentValue': this.currentValue
- });
- },
- _createFooter: function _createFooter() {
- return new ButtonBar({
- buttons: [{
- 'id': this.APPLY_BUTTON_ID,
- 'label': StringResource.get('apply'),
- 'onSelect': this._onApply.bind(this),
- 'disabled': true
- }, {
- 'id': this.RESET_BUTTON_ID,
- 'label': StringResource.get('clear'),
- 'onSelect': this._onReset.bind(this),
- 'disabled': !this.currentValue || !this.currentValue.pathRef
- }]
- });
- },
- render: function render() {
- var promise = TeamFoldersPane.inherited('render', this);
- promise.then(function () {
- _.each(this.footerView.getButtonList(), function (button) {
- button.disabled ? button.disable() : button.enable();
- }.bind(this));
- }.bind(this));
- return promise;
- },
- _onReset: function _onReset() {
- this.bodyView.reset();
- if (this.bodyView.isValueChanged()) {
- this._getApplyButton().enable();
- } else {
- this._getApplyButton().disable();
- }
- this._getResetButton().disable();
- },
- _onApply: function _onApply() {
- if (_.isFunction(this.onApplyCallback)) {
- this.onApplyCallback(this.bodyView.getCurrentValue());
- }
- _.each(this.footerView.getButtonList(), function (button) {
- button.disable();
- }.bind(this));
- },
- _onChange: function _onChange(isValueChanged) {
- if (isValueChanged) {
- _.each(this.footerView.getButtonList(), function (button) {
- button.enable();
- }.bind(this));
- } else {
- this._getApplyButton().disable();
- }
- },
- _getApplyButton: function _getApplyButton() {
- return this.footerView.getButtonList()[this.APPLY_BUTTON_ID];
- },
- _getResetButton: function _getResetButton() {
- return this.footerView.getButtonList()[this.RESET_BUTTON_ID];
- }
- });
- return TeamFoldersPane;
- });
|