Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/views/InteractionDesigner.legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export default {
// Redraw all connections related to that block:
// this.resetJsPlumbBindings(true, app.ui.mostRecentlyDeletedBlock.jsKey)

this.undoDeleteDecisionBranchBlockReferencesIfAny()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bulatgab , I'm curious how you identified the change should be in this legacy file ?
This is not called anywhere in the code as I know. https://github.com/FLOIP/flow-builder/blob/master/src/views/InteractionDesigner.vue#L56

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I forgot to confirm this review last week, so it was still pending


// Set mostRecentlyDeletedBlock to false so that
// multiple undo presses do not add duplicate blocks.
app.ui.mostRecentlyDeletedBlock = false
Expand Down Expand Up @@ -328,10 +330,18 @@ export default {
app.tree.deleteBlock(selectedBlockKey)

// handle if the deleted block was a numeric question block - amend associated
if (selectedBlock.type == 'NumericQuestionBlock') {
if (selectedBlock.type === 'NumericQuestionBlock') {
app.tree.handleDeleteNumericQuestionBlockAssociations(selectedBlockKey)
}

if (selectedBlock.type === 'MultipleChoiceQuestionBlock'
|| selectedBlock.type === 'DirectorySelectionBlock'
|| selectedBlock.type === 'MultipleSelectMultipleChoiceQuestionBlock') {
this.deleteDecisionBranchBlockReferencesIfAny(selectedBlock)
} else {
app.ui.mostRecentlyDeletedDecisionBranchBlockReferences = []
}

// Flag that a change has occured:
app.ui.change('Block deleted.')

Expand Down Expand Up @@ -434,5 +444,29 @@ export default {
? Lang.trans(`trees.output-${_.kebabCase(name)}`)
: name
},

deleteDecisionBranchBlockReferencesIfAny(selectedBlock) {
app.ui.mostRecentlyDeletedDecisionBranchBlockReferences = []

_.filter(app.tree.get('blocks'), (block) => block.type === 'DecisionBranchBlock')
.forEach((decisionBranchBlock) => {
const removedQuestionBlocks = _.remove(decisionBranchBlock.customData.questionBlocks, (questionBlock) =>
questionBlock.jsKey === selectedBlock.jsKey)
app.ui.mostRecentlyDeletedDecisionBranchBlockReferences.push({
decisionBranchBlockJsKey: decisionBranchBlock.jsKey,
removedQuestionBlocks,
})
// VMO-4787 todo: clear the decisionBranchBlock.customData.title? do anything else?
})
},

undoDeleteDecisionBranchBlockReferencesIfAny() {
_.forEach(app.ui.mostRecentlyDeletedDecisionBranchBlockReferences, (reference) => {
const decisionBranchBlock = _.find(app.tree.get('blocks'), (block) => block.jsKey === reference.decisionBranchBlockJsKey)
decisionBranchBlock.customData.questionBlocks.push(reference.removedQuestionBlocks)
})
app.ui.mostRecentlyDeletedDecisionBranchBlockReferences = []
// VMO-4787 todo: undo clear title, etc.
},
},
}