Skip to content

Commit

Permalink
different approach to hiding and disabling dropdown tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Nov 10, 2023
1 parent 78777cc commit 56871a2
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/web/assets/commerceui/src/js/order/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,26 +336,29 @@ export default new Vuex.Store({
},

handleTabs({state}) {
let tabManagerMenuBtn = Craft.cp.tabManager.$menuBtn.data('menubtn');
if (tabManagerMenuBtn !== undefined) {
let tabsDropdownMenu = tabManagerMenuBtn.menu;
if (tabsDropdownMenu !== undefined && tabsDropdownMenu !== null) {
for (let i = 0; i < tabsDropdownMenu.$options.length; i++) {
let $option = $(tabsDropdownMenu.$options[i]);
if (state.editing) {
if ($option.data('id').startsWith('static-fields-')) {
$option.parent().addClass('hidden');
} else {
$option.parent().removeClass('hidden');
}
} else {
if ($option.data('id').startsWith('fields-')) {
$option.parent().addClass('hidden');
} else {
$option.parent().removeClass('hidden');
}
}
}
const tabManagerMenuBtn = Craft.cp.tabManager.$menuBtn.data('menubtn');
const tabsDropdownMenu = tabManagerMenuBtn.menu;
if (tabsDropdownMenu !== undefined) {
const optionSelector =
'[id^="' + tabsDropdownMenu.menuId + '-option-"]';

const staticOptions = tabsDropdownMenu.$container
.find(optionSelector + '[data-id^="static-fields-"]');
const fieldsOptions = tabsDropdownMenu.$container
.find(optionSelector + '[data-id^="fields-"]');

if (state.editing) {
staticOptions.disable();
staticOptions.parent().addClass('hidden');

fieldsOptions.enable();
fieldsOptions.parent().removeClass('hidden');
} else {
staticOptions.enable();
staticOptions.parent().removeClass('hidden');

fieldsOptions.disable();
fieldsOptions.parent().addClass('hidden');
}
}
},
Expand Down

0 comments on commit 56871a2

Please sign in to comment.