123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2017, 2019
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../lib/@waca/core-client/js/core-client/ui/core/View', '../../lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl'], function (View, PropertyUIControl) {
- /**
- Class that will takes a propertyUIControl spec and renders it
- **/
- var PropertyUIControlView = View.extend({
- /**
- options.glassContext
- options.items
- **/
- init: function init(options) {
- PropertyUIControlView.inherited('init', this, arguments);
- this.options = options || {};
- this._propertyUIControl = null;
- this._isMainPropertyUIControl = this.options.items && this.options.items[0].type === 'Banner';
- this.setFocus = this.options.onSetFocus;
- this.node = this.options.node;
- this.setPropertySpec(this.options.items);
- },
- setPropertySpec: function setPropertySpec(properties) {
- this._propertySpec = {
- 'el': this.node || this.$el,
- 'glassContext': this.options.glassContext,
- 'items': properties
- };
- if (this._isMainPropertyUIControl && properties && properties.length) {
- this._propertySpec.ariaLabel = properties[0].value;
- }
- this._propertySpec.primaryUIControl = false;
- if (this.options) {
- this._propertySpec.onCloseCb = this.options.onCloseCb || null;
- this._propertySpec.closeCallback = this.options.closeCallback || null;
- }
- },
- render: function render(isRefresh) {
- var _this = this;
- this.$el.parent().addClass('dashboardPropertiesPane');
- var promise = null;
- if (this._propertyUIControl) {
- promise = this._propertyUIControl.onClose().then(function () {
- _this._propertyUIControl.remove();
- _this.$el.empty();
- });
- } else {
- promise = Promise.resolve();
- }
- return promise.then(function () {
- if (!_this._propertySpec || !_this._propertySpec.items || !_this._propertySpec.items.length) {
- return Promise.resolve();
- }
- _this._propertyUIControl = new PropertyUIControl(_this._propertySpec);
- return _this._propertyUIControl.render().then(function () {
- if (_this._isMainPropertyUIControl && !isRefresh) {
- _this._propertyUIControl.focus();
- }
- if (_this.options && _this.options.renderCallback) {
- _this.options.renderCallback();
- }
- if (_this._propertySpec) {
- _this._showMissingTranslationsIcon(_this._propertySpec.items);
- }
- return _this._propertyUIControl;
- });
- });
- },
- getPropertyUIControl: function getPropertyUIControl() {
- return this._propertyUIControl;
- },
- onClose: function onClose() {
- return this._propertyUIControl.onClose();
- },
- /**
- * recursively go through the properties. If a property has a method called 'appedTranslationIcon' defined,
- * then call it passing the property node. Note, that method will only be defined when we're in translation mode
- * and the translation for the current locale is missing.
- */
- _showMissingTranslationsIcon: function _showMissingTranslationsIcon(items) {
- items.forEach(function (property) {
- if (property.items) {
- this._showMissingTranslationsIcon(property.items);
- } else if (property.appendTranslationIcon && (!property.translationIconNode || property.translationIconNode.length === 0)) {
- // Save the node so we can use it to remove the marker on property change
- property.translationIconNode = this.$el.find('.property_' + property.id);
- property.appendTranslationIcon(property.translationIconNode);
- }
- }.bind(this));
- },
- remove: function remove() {
- if (this._propertyUIControl) {
- this._propertyUIControl.remove();
- this._propertyUIControl = null;
- }
- this._propertySpec = null;
- this.options = null;
- }
- });
- return PropertyUIControlView;
- });
- //# sourceMappingURL=PropertyUIControlView.js.map
|