Skip to content

Commit

Permalink
handle "duplicate" tabs in the dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Nov 9, 2023
1 parent 5f31ae1 commit 78777cc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/web/assets/commerceui/dist/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/commerceui/dist/js/app.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/web/assets/commerceui/src/js/order/apps/OrderActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
methods: {
...mapActions(['edit']),
...mapActions(['edit', 'handleTabs']),
cancel() {
window.location.reload();
Expand All @@ -72,6 +72,8 @@
// re-init the tabs after hiding the non-static ones
// see: https://github.com/craftcms/cms/issues/13911 for more details
Craft.cp.initTabs();
// and handle tabs dropdown
this.handleTabs();
// For custom tabs, if the selected tab is dynamic, find corresponding static tab and select it instead.
const $selectedTabLink = window.document.querySelector(
Expand Down
28 changes: 28 additions & 0 deletions src/web/assets/commerceui/src/js/order/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,34 @@ export default new Vuex.Store({

// Update `editing` state
commit('updateEditing', true);

// handle duplicate content (fields) tabs
dispatch('handleTabs');
},

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');
}
}
}
}
}
},

getOrder({state, commit}) {
Expand Down

0 comments on commit 78777cc

Please sign in to comment.