mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
Merge branch 'feature/6132-disabling-tabs-dynamically' into saas/3.0
This commit is contained in:
@@ -35,6 +35,10 @@ $ibo-sticky-sentinel-bottom--height: $ibo-sticky-sentinel--height !default;
|
|||||||
opacity: 1 !important; /* Note: !important is necessary as it needs to overload any standard rules */
|
opacity: 1 !important; /* Note: !important is necessary as it needs to overload any standard rules */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ibo-is-disabled {
|
||||||
|
cursor: not-allowed !important; /* Note: !important is necessary as it needs to overload any standard rules */
|
||||||
|
}
|
||||||
|
|
||||||
/****************************/
|
/****************************/
|
||||||
/* Disposition / alignement */
|
/* Disposition / alignement */
|
||||||
/****************************/
|
/****************************/
|
||||||
|
|||||||
@@ -126,13 +126,14 @@ $.widget( "itop.regulartabs", $.ui.tabs, {
|
|||||||
},
|
},
|
||||||
// JQuery UI overload
|
// JQuery UI overload
|
||||||
disable: function(index){
|
disable: function(index){
|
||||||
let panel = this._getPanelForTab( index );
|
const panel = this._getPanelForTab( index );
|
||||||
panel.css({display: 'none'});
|
panel.hide();
|
||||||
this._super( index );
|
this._super( index );
|
||||||
},
|
},
|
||||||
|
// JQuery UI overload
|
||||||
enable: function(index) {
|
enable: function(index) {
|
||||||
let panel = this._getPanelForTab( index );
|
const panel = this._getPanelForTab( index );
|
||||||
panel.css({display: 'block'});
|
panel.show();
|
||||||
this._super( index );
|
this._super( index );
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -379,13 +379,14 @@ $.widget( "itop.scrollabletabs", $.ui.tabs, {
|
|||||||
},
|
},
|
||||||
// JQuery UI overload
|
// JQuery UI overload
|
||||||
disable: function(index){
|
disable: function(index){
|
||||||
let panel = this._getPanelForTab( this.tabs[index] );
|
const panel = this._getPanelForTab( this.tabs[index] );
|
||||||
panel.css({display: 'none'});
|
panel.hide();
|
||||||
this._super( index );
|
this._super( index );
|
||||||
},
|
},
|
||||||
|
// JQuery UI overload
|
||||||
enable: function(index) {
|
enable: function(index) {
|
||||||
let panel = this._getPanelForTab( this.tabs[index] );
|
const panel = this._getPanelForTab( this.tabs[index] );
|
||||||
panel.css({display: 'block'});
|
panel.show();
|
||||||
this._super( index );
|
this._super( index );
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ $(function()
|
|||||||
css_classes:
|
css_classes:
|
||||||
{
|
{
|
||||||
is_hidden: 'ibo-is-hidden',
|
is_hidden: 'ibo-is-hidden',
|
||||||
|
is_disabled: 'ibo-is-disabled',
|
||||||
is_transparent: 'ibo-is-transparent',
|
is_transparent: 'ibo-is-transparent',
|
||||||
is_opaque: 'ibo-is-opaque',
|
is_opaque: 'ibo-is-opaque',
|
||||||
is_scrollable: 'ibo-is-scrollable',
|
is_scrollable: 'ibo-is-scrollable',
|
||||||
@@ -252,6 +253,11 @@ $(function()
|
|||||||
// Prevent anchor default behaviour
|
// Prevent anchor default behaviour
|
||||||
oEvent.preventDefault();
|
oEvent.preventDefault();
|
||||||
|
|
||||||
|
if (oExtraTabTogglerElem.attr('aria-disabled') === 'true') {
|
||||||
|
// Corresponding tab is disabled, do nothing
|
||||||
|
oEvent.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Trigger click event on real tab toggler (the hidden one)
|
// Trigger click event on real tab toggler (the hidden one)
|
||||||
const sTargetTabId = oExtraTabTogglerElem.attr('href').replace(/#/, '');
|
const sTargetTabId = oExtraTabTogglerElem.attr('href').replace(/#/, '');
|
||||||
this.element.find(this.js_selectors.tab_header+'[data-tab-id="'+sTargetTabId+'"] '+this.js_selectors.tab_toggler).trigger('click');
|
this.element.find(this.js_selectors.tab_header+'[data-tab-id="'+sTargetTabId+'"] '+this.js_selectors.tab_toggler).trigger('click');
|
||||||
@@ -297,9 +303,10 @@ $(function()
|
|||||||
const sTabId = oTabHeaderElem.attr('data-tab-id');
|
const sTabId = oTabHeaderElem.attr('data-tab-id');
|
||||||
const oMatchingExtraTabElem = this.element.find(this.js_selectors.extra_tab_toggler+'[href="#'+sTabId+'"]');
|
const oMatchingExtraTabElem = this.element.find(this.js_selectors.extra_tab_toggler+'[href="#'+sTabId+'"]');
|
||||||
|
|
||||||
// Disabled tabs are never added to the ExtraTabs list
|
// Disabled tabs should be disabled in the ExtraTabs list as well
|
||||||
if (oTabHeaderElem.attr('aria-disabled') == 'true') {
|
let bIsDisabled = false;
|
||||||
bIsVisible = true;
|
if (oTabHeaderElem.attr('aria-disabled') === 'true') {
|
||||||
|
bIsDisabled = true;
|
||||||
}
|
}
|
||||||
// Manually check if the tab header is visible if the info isn't passed
|
// Manually check if the tab header is visible if the info isn't passed
|
||||||
if (bIsVisible === null) {
|
if (bIsVisible === null) {
|
||||||
@@ -312,6 +319,14 @@ $(function()
|
|||||||
} else {
|
} else {
|
||||||
oMatchingExtraTabElem.removeClass(this.css_classes.is_hidden);
|
oMatchingExtraTabElem.removeClass(this.css_classes.is_hidden);
|
||||||
}
|
}
|
||||||
|
// Enable/disable the corresponding extra tab element
|
||||||
|
if (bIsDisabled) {
|
||||||
|
oMatchingExtraTabElem.attr('aria-disabled', 'true');
|
||||||
|
oMatchingExtraTabElem.addClass(this.css_classes.is_disabled);
|
||||||
|
} else {
|
||||||
|
oMatchingExtraTabElem.attr('aria-disabled', 'false');
|
||||||
|
oMatchingExtraTabElem.removeClass(this.css_classes.is_disabled);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// - Update extra tabs list
|
// - Update extra tabs list
|
||||||
_updateExtraTabsList: function () {
|
_updateExtraTabsList: function () {
|
||||||
@@ -343,19 +358,35 @@ $(function()
|
|||||||
|
|
||||||
return oTabElem.length === 0 ? 0 : oTabElem.prevAll().length;
|
return oTabElem.length === 0 ? 0 : oTabElem.prevAll().length;
|
||||||
},
|
},
|
||||||
_getTabElementFromTabIndex: function(iIdx) {
|
/**
|
||||||
return this.element.children(this.js_selectors.tabs_list).children(this.js_selectors.tab_header).eq(iIdx);
|
* @param sId {string} The [data-tab-id] of the tab
|
||||||
|
* @return {Object} The jQuery object representing the tab element
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_getTabElementFromTabId: function(sId) {
|
||||||
|
return this.element.children(this.js_selectors.tabs_list).children(this.js_selectors.tab_header+'[data-tab-id="'+sId+'"]');
|
||||||
},
|
},
|
||||||
disableTab: function(iIdx){
|
/**
|
||||||
let tabsWidget = this.GetTabsWidget();
|
* @param sId {string} The [data-tab-id] of the tab
|
||||||
|
* @return {Object} The jQuery object representing the tab element
|
||||||
|
*/
|
||||||
|
disableTab: function(sId){
|
||||||
|
const tabsWidget = this.GetTabsWidget();
|
||||||
|
const iIdx = this._getTabIndexFromTabId(sId);
|
||||||
tabsWidget.disable(iIdx);
|
tabsWidget.disable(iIdx);
|
||||||
let tabElement = this._getTabElementFromTabIndex(iIdx);
|
const tabElement = this._getTabElementFromTabId(sId);
|
||||||
this._updateTabHeaderDisplay(tabElement);
|
this._updateTabHeaderDisplay(tabElement);
|
||||||
},
|
},
|
||||||
enableTab: function(iIdx){
|
/**
|
||||||
let tabsWidget = this.GetTabsWidget();
|
* @param sId {string} The [data-tab-id] of the tab
|
||||||
|
* @return {Object} The jQuery object representing the tab element
|
||||||
|
*/
|
||||||
|
enableTab: function(sId){
|
||||||
|
const tabsWidget = this.GetTabsWidget();
|
||||||
|
const iIdx = this._getTabIndexFromTabId(sId);
|
||||||
tabsWidget.enable(iIdx);
|
tabsWidget.enable(iIdx);
|
||||||
let tabElement = this._getTabElementFromTabIndex(iIdx);
|
const tabElement = this._getTabElementFromTabId(sId);
|
||||||
this._updateTabHeaderDisplay(tabElement);
|
this._updateTabHeaderDisplay(tabElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user