From 92eb24489b9eb12c972ef2e884f50cba6b8b1e7f Mon Sep 17 00:00:00 2001 From: Yan Georget Date: Mon, 27 Aug 2018 16:28:00 +0200 Subject: [PATCH] feat: Pass dialog parameters to isFulfilled function --- packages/botfuel-dialog/src/dialogs/prompt-dialog.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/botfuel-dialog/src/dialogs/prompt-dialog.js b/packages/botfuel-dialog/src/dialogs/prompt-dialog.js index 36fd8eaa..1b250245 100644 --- a/packages/botfuel-dialog/src/dialogs/prompt-dialog.js +++ b/packages/botfuel-dialog/src/dialogs/prompt-dialog.js @@ -72,8 +72,8 @@ class PromptDialog extends Dialog { // Check if the parameter is already fulfilled with its initial value // If so, we replace the fulfilled parameter’s entity // with the first candidate of the same dimension - const replace = - entity.isFulfilled(initialValue, { dialogEntities: {} }) && sameDimCandidates.length >= 1; + const replace = entity.isFulfilled(initialValue, { dialogEntities: {}, dialogParameters: this.parameters }) + && sameDimCandidates.length >= 1; if (replace) { const chosenCandidate = sameDimCandidates[0]; candidates = filterIntersectingEntities(candidates, chosenCandidate); @@ -85,7 +85,7 @@ class PromptDialog extends Dialog { } return candidates.filter(candidate => candidate.dim === entity.dim).reduce( ({ newValue, remainingCandidates }, candidate) => { - if (entity.isFulfilled(newValue, { dialogEntities: {} })) { + if (entity.isFulfilled(newValue, { dialogEntities: {}, dialogParameters: this.parameters })) { return { newValue, remainingCandidates }; } return { @@ -154,11 +154,13 @@ class PromptDialog extends Dialog { const priorityB = entityB.priority; const isFulfilledA = entityA.isFulfilled(matchedEntities[nameA], { dialogEntities: matchedEntities, + dialogParameters: this.parameters, }) ? 0 : 1; const isFulfilledB = entityB.isFulfilled(matchedEntities[nameB], { dialogEntities: matchedEntities, + dialogParameters: this.parameters, }) ? 0 : 1; @@ -247,6 +249,7 @@ class PromptDialog extends Dialog { const isFulfilled = entity.isFulfilled(newValue, { dialogEntities: matchedEntities, + dialogParameters: this.parameters, }); // If an entity matching the one we are expecting was found,