Reputation: 217
I've spent a long time going over documentation but have not been able to get a confirmation view to show up before running my action. What are the steps to adding a confirmation view to a capsule?
I have an action called Evaluate
and an address input that i automatically pull from the user's profile. I would like to confirm this address before running Evaluate
in case the user wants to use a different address
Here's what I have done:
1) import viv.common in capsule.bxb:
import (viv.common) {
as (common)
version (3.30.0)
}
2) add confirm/by statement to Evaluate action:
confirm {
by (common.Confirmation)
}
3) add a confirmation view that will match on the evaluate action:
confirmation-view {
match: common.Confirmation {
confirming {Evaluate (action) }
}
mode (PositiveEmphasis)
message ("Is this the correct address?")
render {
layout {
section {
content{
paragraph {
style (Title_XS)
value {
template (
"#{value(action.address)}}?"
)
}
}
}
}
}
}
confirm-options {
label ("Yes")
}
abort-options {
label ("Try another Address")
on-abort {
intent {
goal: InputAddress
}
}
}
}
I was hoping that would do it, but I think i'm missing something else. Any ideas?
Upvotes: 3
Views: 165
Reputation: 6299
I've been looking into this and my guess is that it doesn't work with a Calculation
action (or Constructor
action), you need a transaction action, based on the following sentence in the confirmation-view documentation:
There must be a corresponding transactional action asking for confirmation with the confirm key.
Take a look at the sample capsule capsule-sample-bank. Committing a transfer prompts the user for Confirmation. They use two confirmation prompts:
CreateTransfer
and results in a Transfer
model. This is the one you're looking for.transaction-support
and a match { Transfer }
to match the output of the first one and starts a new intent on CommitTransfer
upon user confirmation.The relevant files in the folder structure are:
+-- models/
| +-- actions/
| | +-- CreateTransfer.model.bxb
+-- resources/
| +-- base/
| | +-- dialog/
| | | +-- CreateTransfer_Confirmation.dialog.bxb
| | | +-- Transfer_Result.dialog.bxb
| | +-- transactions/
| | | +-- precommit.transaction.bxb
| | +-- views/
| | | +-- CreateTransfer_Confirmation.view.bxb
Maybe someone from the Bixby developer team can expand this answer. I don't see a reason why it shouldn't be possible to use a confirmation on a Calculation
action.
Upvotes: 6