Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sap.ui.define(
- ['sap/ui/core/Item', 'sap/m/IconTabFilter'],
- function (Item, IconTabFilter) {
- 'use strict';
- const IconTabButton = Item.extend('your.namespace.IconTabButton', {
- metadata: {
- interfaces: ['sap.m.IconTab'],
- aggregations: {
- button: {
- type: 'sap.m.Button',
- multiple: false,
- },
- content: {
- type: 'sap.ui.core.Control',
- multiple: true,
- },
- },
- properties: {
- visible: { type: 'boolean', defaultValue: true },
- enabled: { type: 'boolean', defaultValue: true },
- icon: { type: 'sap.ui.core.URI', defaultValue: '' },
- iconDensityAware: {
- type: 'boolean',
- defaultValue: true,
- },
- count: { type: 'string', defaultValue: '' },
- },
- },
- init: function () {
- this._oCloneInList = null; // holds reference to the cloned item in the SelectList
- },
- _getRealTab: function () {
- return IconTabFilter.prototype._getRealTab.call(this);
- },
- _getNonEmptyKey: function () {
- return IconTabFilter.prototype._getNonEmptyKey.call(this);
- },
- _getNestedLevel: function () {
- return IconTabFilter.prototype._getNestedLevel.call(this);
- },
- _getRootTab: function () {
- return IconTabFilter.prototype._getRootTab.call(this);
- },
- _isParentOf: function () {
- return IconTabFilter.prototype._isParentOf.call(this);
- },
- _getAllSubFilters: function () {
- return IconTabFilter.prototype._getAllSubFilters.call(this);
- },
- _getAllSubItems: function () {
- return IconTabFilter.prototype._getAllSubItems.call(this);
- },
- getItems: function () {
- return IconTabFilter.prototype.getItems.call(this);
- },
- renderInSelectList: function (
- oRM,
- oSelectList,
- iIndexInSet,
- iSetSize,
- fPaddingValue,
- ) {
- if (this._invisibleText) {
- this._invisibleText.destroy();
- this._invisibleText = null;
- }
- if (!this.getVisible()) {
- return;
- }
- var bTextOnly = true,
- bIconOnly = false,
- oIconTabHeader = oSelectList._oIconTabHeader;
- if (oIconTabHeader) {
- bTextOnly = oIconTabHeader._bTextOnly;
- }
- oRM
- .openStart('li', this)
- .class('sapMITBSelectItem')
- .attr('tabindex', '-1')
- .attr('role', 'menuitem');
- if (fPaddingValue) {
- oRM.style('padding-left', fPaddingValue + 'rem');
- }
- if (iIndexInSet !== undefined && iSetSize !== undefined) {
- oRM.attr('aria-posinset', iIndexInSet + 1);
- oRM.attr('aria-setsize', iSetSize);
- oRM.attr('aria-level', this._getNestedLevel());
- }
- var sTooltip = this.getTooltip_AsString();
- if (sTooltip) {
- oRM.attr('title', sTooltip);
- }
- if (oIconTabHeader._isUnselectable(this)) {
- oRM.class('sapMITHUnselectable');
- }
- if (!this.getEnabled()) {
- oRM.class('sapMITBDisabled').attr('aria-disabled', true);
- }
- if (oSelectList.getSelectedItem() == this) {
- oRM.class('sapMITBSelectItemSelected');
- oRM.attr('aria-selected', true);
- }
- var oIconColor = 'Neutral';
- oRM.class('sapMITBFilter' + oIconColor);
- var sItemId = this.getId(),
- bShouldReadIconColor =
- oIconColor == 'Positive' ||
- oIconColor == 'Critical' ||
- oIconColor == 'Negative' ||
- oIconColor == 'Neutral',
- aLabelledByIds = [];
- if (!bIconOnly) {
- aLabelledByIds.push(sItemId + '-text');
- }
- if (!bTextOnly && this.getIcon()) {
- aLabelledByIds.push(sItemId + '-icon');
- }
- if (bShouldReadIconColor) {
- this._invisibleText = new sap.ui.core.InvisibleText({
- text: 'ICONTABBAR_ICONCOLOR_NEUTRAL',
- });
- aLabelledByIds.push(this._invisibleText.getId());
- }
- oRM
- .accessibilityState({ labelledby: aLabelledByIds.join(' ') })
- .openEnd();
- if (this._invisibleText) {
- oRM.renderControl(this._invisibleText);
- }
- if (!bTextOnly) {
- this._renderIcon(oRM, bIconOnly);
- }
- if (!bIconOnly) {
- this._renderText(oRM);
- }
- oRM.close('li');
- },
- _getSelectList: function () {
- return IconTabFilter.prototype._getSelectList.call(this);
- },
- _setSelectListItems: function () {
- return IconTabFilter.prototype._setSelectListItems.call(this);
- },
- _expandButtonPress: function () {
- return IconTabFilter.prototype._expandButtonPress.call(this);
- },
- _getAllSubFilters: function () {
- return IconTabFilter.prototype._getAllSubFilters.call(this);
- },
- _getAllSubFiltersDomRefs: function () {
- return IconTabFilter.prototype._getAllSubFiltersDomRefs.call(this);
- },
- _getFirstAvailableSubFilter: function () {
- return IconTabFilter.prototype._getFirstAvailableSubFilter.call(this);
- },
- _createPopoverCloseButton: function () {
- return IconTabFilter.prototype._createPopoverCloseButton.call(this);
- },
- _closePopover: function () {
- return IconTabFilter.prototype._closePopover.call(this);
- },
- _renderText: function (oRM) {
- var sText = 'ADD NEW',
- sCount = this.getCount(),
- bRTL = sap.ui.getCore().getConfiguration().getRTL(),
- sTextDir = this.getTextDirection();
- oRM
- .openStart('span', this.getId() + '-text')
- .attr('dir', 'ltr')
- .class('sapMText')
- .class('sapMTextNoWrap')
- .class('sapMITBText')
- .class('sapMITBBadgeHolder');
- if (sTextDir !== sap.ui.core.TextDirection.Inherit) {
- oRM.attr('dir', sTextDir.toLowerCase());
- }
- var sTextAlign = sap.ui.core.TextAlign.Initial;
- if (sTextAlign) {
- oRM.style('text-align', sTextAlign);
- }
- if (sCount) {
- if (bRTL) {
- sText = '(' + sCount + ') ' + sText;
- } else {
- sText += ' (' + sCount + ')';
- }
- }
- oRM.openEnd().text(sText).close('span');
- },
- render: function (oRM) {
- let mAriaParams = {};
- if (!this.getVisible()) {
- return;
- }
- oRM
- .openStart('div', this)
- .accessibilityState(mAriaParams)
- .class('sapMITBItem');
- oRM.openEnd();
- oRM.renderControl(this.getButton());
- oRM.close('div');
- },
- });
- return IconTabButton;
- },
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement