diff --git a/application/utils.inc.php b/application/utils.inc.php index 7ee001146..e2d0de654 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1277,7 +1277,6 @@ class utils new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('$sOQL', '', 'xlsx', ".json_encode(Dict::S('ExcelExporter:ExportMenu')).")"), new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:PrintableVersion', Dict::S('UI:Menu:PrintableVersion'), $sUrl.'&printable=1', '_blank'), - new JSPopupMenuItem('UI:Menu:SwitchTabMode', Dict::S('UI:Menu:SwitchTabMode'), "SwitchTabMode()"), ); break; diff --git a/dictionaries/ui/layouts/en.dictionary.itop.object-details.php b/dictionaries/ui/layouts/en.dictionary.itop.object-details.php index 55bf2bf35..d71a01245 100644 --- a/dictionaries/ui/layouts/en.dictionary.itop.object-details.php +++ b/dictionaries/ui/layouts/en.dictionary.itop.object-details.php @@ -5,5 +5,4 @@ */ Dict::Add('EN US', 'English', 'English', [ - 'UI:Menu:SwitchTabMode' => 'Switch tab mode', ]); diff --git a/dictionaries/ui/pages/en.dictionary.itop.preferences.php b/dictionaries/ui/pages/en.dictionary.itop.preferences.php index 836079dc6..56344df48 100644 --- a/dictionaries/ui/pages/en.dictionary.itop.preferences.php +++ b/dictionaries/ui/pages/en.dictionary.itop.preferences.php @@ -27,6 +27,9 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:RichText:ToolbarState:Expanded' => 'Expanded', 'UI:RichText:ToolbarState:Collapsed' => 'Collapsed', 'UI:Tabs:Preferences' => 'Tabs', + 'UI:Tabs:Layout:Label' => 'Tabs layout', + 'UI:Tabs:Layout:Horizontal' => 'Horizontal', + 'UI:Tabs:Layout:Vertical' => 'Vertical', 'UI:Tabs:Scrollable:Label' => 'Tabs navigation', 'UI:Tabs:Scrollable:Classic' => 'Classic', 'UI:Tabs:Scrollable:Scrollable' => 'Scrollable', diff --git a/js/pages/backoffice/toolbox.js b/js/pages/backoffice/toolbox.js index d98013cd4..248cf6d58 100644 --- a/js/pages/backoffice/toolbox.js +++ b/js/pages/backoffice/toolbox.js @@ -41,22 +41,6 @@ function StripArchiveArgument(sUrl) var res = sUrl.replace(/&with-archive=[01]/g, ''); return res; } -//TODO 3.0.0 Is this the right place to put this method ? -function SwitchTabMode() -{ - let aTabContainer = $('[data-role="ibo-tab-container"]'); - if (!aTabContainer.hasClass('ibo-is-vertical')) - { - aTabContainer.removeClass('ibo-is-horizontal'); - aTabContainer.addClass('ibo-is-vertical'); - SetUserPreference('tab_layout', 'vertical', true); - } else - { - aTabContainer.removeClass('ibo-is-vertical'); - aTabContainer.addClass('ibo-is-horizontal'); - SetUserPreference('tab_layout', 'horizontal', true); - } -} /** * A toolbox for common JS operations in the backoffice. Meant to be used by Combodo developers and the community. diff --git a/pages/preferences.php b/pages/preferences.php index 4337f74f2..f91c25a6d 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -331,7 +331,15 @@ JS $oTabsForm = new Form(); $oTabsForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('operation', 'apply_tab_config')); - + + // Tab Layout + $sTabsLayoutValue = appUserPreferences::GetPref('tab_layout', false);; + $oTabsLayout = InputUIBlockFactory::MakeForSelectWithLabel('tab_layout', Dict::S('UI:Tabs:Layout:Label')); + $oTabsLayout->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('horizontal', Dict::S('UI:Tabs:Layout:Horizontal'), 'horizontal' === $sTabsLayoutValue)); + $oTabsLayout->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('vertical', Dict::S('UI:Tabs:Layout:Vertical'), 'vertical' === $sTabsLayoutValue)); + $oTabsForm->AddSubBlock($oTabsLayout); + + // Tab navigation $sTabsScrollableValue = appUserPreferences::GetPref('tab_scrollable', false);; $oTabsScrollable = InputUIBlockFactory::MakeForSelectWithLabel('tab_scrollable', Dict::S('UI:Tabs:Scrollable:Label')); $oTabsScrollable->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:Tabs:Scrollable:Scrollable'), true === $sTabsScrollableValue)); @@ -501,8 +509,16 @@ try { DisplayPreferences($oPage); break; case 'apply_tab_config': - $bScrollable= utils::ReadParam('tab_scrollable', 'false') === 'true'; + $sLayout = utils::ReadParam('tab_layout', 'horizontal'); + $sLayoutAllowedValues = ['horizontal', 'vertical']; + if(in_array($sLayout, $sLayoutAllowedValues, true)) + { + appUserPreferences::SetPref('tab_layout', $sLayout); + } + + $bScrollable = utils::ReadParam('tab_scrollable', 'false') === 'true'; appUserPreferences::SetPref('tab_scrollable', $bScrollable); + DisplayPreferences($oPage); break; case 'apply_language': $sLangCode = utils::ReadParam('language', 'EN US');