Skip to content

Commit

Permalink
apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kelanik8 committed Oct 23, 2023
1 parent 6545e81 commit 11cb415
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions client/web/compose/src/views/Admin/Pages/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,17 @@ export default {
if (this.editor) this.editor = undefined
},
deleteTab ({ blockIndex, tabIndex }) {
const { blockID } = this.blocks[blockIndex] || {}
if (!blockID) return
this.unsavedBlocks.add(blockID)
this.blocks[blockIndex].options.tabs.splice(tabIndex, 1)
this.showUntabbedHiddenBlocks()
},
// Changes meta.hidden property to false, for all blocks that are hidden but not in a tab
showUntabbedHiddenBlocks () {
const tabbedBlocks = new Set()
Expand Down Expand Up @@ -674,35 +685,14 @@ export default {
tabbedBlock.meta.hidden = true
})
this.showUnusedHiddenBlocks()
this.showUntabbedHiddenBlocks()
}
if (this.editor.block.kind === block.kind) {
this.editor = undefined
}
},
showUnusedHiddenBlocks () {
const allTabBlocks = this.blocks.filter(({ kind }) => kind === 'Tabs')
this.blocks.forEach(block => {
if (!block.meta.hidden) return
const hiddenBlockID = fetchID(block)
// Go through all hidden blocks to see if they are tabbed anywhere
const tabbed = allTabBlocks.some(({ options }) => {
const { tabs = [] } = options
return tabs.some(({ blockID }) => blockID === hiddenBlockID)
})
if (!tabbed) {
this.calculateNewBlockPosition(block)
block.meta.hidden = false
}
})
},
cloneBlock (index) {
this.appendBlock(this.blocks[index].clone(), this.$t('notification:page.cloneSuccess'))
},
Expand Down Expand Up @@ -1074,15 +1064,6 @@ export default {
this.$root.$off('tab-createRequest', this.fulfilCreateRequest)
this.$root.$off('tabChange', this.untabBlock)
},
deleteTab ({ blockIndex, tabIndex }) {
const { blockID } = this.blocks[blockIndex] || {}
if (!blockID) return
this.unsavedBlocks.add(blockID)
this.blocks[blockIndex].options.tabs.splice(tabIndex, 1)
},
},
}
</script>
Expand Down

0 comments on commit 11cb415

Please sign in to comment.