Skip to content

Commit

Permalink
Fix reporter builder state being auto-updated in configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
kelanik8 committed Jun 6, 2024
1 parent ca1b233 commit 813bd67
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions client/web/reporter/src/views/Report/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,18 @@
</grid>

<b-modal
v-model="blocks.showConfigurator"
:title="$t('builder:block.configuration')"
:ok-title="$t('builder:save-button')"
:visible="showEditor"
ok-variant="primary"
cancel-variant="link"
scrollable
size="xl"
body-class="p-0 border-top-0"
header-class="border-bottom-0"
no-fade
@ok="updateBlock()"
@hide="hideEditorModal"
@ok="updateEditorBlock()"
>
<b-tabs
v-if="currentBlock"
Expand Down Expand Up @@ -208,7 +209,7 @@
:current-index="displayElements.currentIndex"
draggable
@select="setCurrentDisplayElement"
@add="openDisplayElementSelector(blocks.currentIndex)"
@add="openDisplayElementSelector(editor.currentIndex)"
@delete="deleteCurrentDisplayElement"
>
<template #label="{ item: { kind, name } }">
Expand Down Expand Up @@ -511,6 +512,8 @@ export default {
selected: undefined,
},
editor: undefined,
}
},
Expand Down Expand Up @@ -574,12 +577,12 @@ export default {
currentBlock: {
get () {
return this.blocks.currentIndex !== undefined ? this.reportBlocks[this.blocks.currentIndex] : undefined
return this.editor ? this.editor.block : undefined
},
set (block) {
if (this.blocks.currentIndex !== undefined) {
this.reportBlocks[this.blocks.currentIndex] = block
if (this.editor && this.editor.currentIndex !== undefined) {
this.editor.block = block
}
},
},
Expand Down Expand Up @@ -650,6 +653,10 @@ export default {
return this.datasources.processing || hasDuplicates
},
showEditor () {
return this.editor && this.editor.currentIndex !== undefined
},
},
watch: {
Expand Down Expand Up @@ -883,17 +890,41 @@ export default {
}
},
updateEditorBlock (block = this.editor.block) {
const { currentIndex } = this.editor
this.reportBlocks[currentIndex] = block
this.editor = undefined
this.onBlockUpdated(currentIndex)
this.refreshReport()
},
editBlock (index = undefined) {
this.blocks.currentIndex = index
this.setCurrentDisplayElement(this.reportBlocks[this.blocks.currentIndex].elements.length ? 0 : undefined)
this.blocks.showConfigurator = true
const { x, y, w, h, i } = this.reportBlocks[index]
const block = new reporter.Block(this.reportBlocks[index])
block.x = x
block.y = y
block.w = w
block.h = h
block.i = i
this.editor = {
currentIndex: index,
block,
}
this.setCurrentDisplayElement(this.editor.block.elements.length ? 0 : undefined)
},
deleteBlock (index = undefined) {
this.reindexBlocks(this.reportBlocks.filter((p, i) => index !== i))
this.unsavedBlocks.add(index)
},
hideEditorModal () {
this.editor = undefined
this.displayElements.currentIndex = undefined
},
// Display elements
openDisplayElementSelector (index) {
this.blocks.currentIndex = index
Expand Down

0 comments on commit 813bd67

Please sign in to comment.