我有一个胶囊可以根据用户输入计算一些东西。用户需要告诉我的胶囊一个始发国 ( FromCountryConcept
)、目的地国家 ( ToCountryConcept
) 和一个文本 ( LetterContentConcept
)。既然是国家概念enum
,那input-view
对于那些就简单了selection-of
。对于input-view
文本,我使用textarea
. 所有代码都在下面,可在此存储库的 github 上找到:SendLetter-Bixby
当用户使用 Bixby 视图向 Bixby 提供所需的输入时,一切都会按预期工作。
如何让用户input-view
使用(口语或打字)NL 输入向显示的内容提供输入?
我的动作SendLetter.model.bxb
是这样的:
action (SendLetter) {
description (Sends a Letter from one country to another and calculates the cost based on the letter content length.)
type (Calculation)
collect {
input (fromCountry) {
type (FromCountryConcept)
min (Required)
max (One)
default-init {
intent {
goal: FromCountryConcept
value-set: FromCountryConcept {
FromCountryConcept(Germany)
FromCountryConcept(South Korea)
FromCountryConcept(USA)
FromCountryConcept(Spain)
FromCountryConcept(Austria)
FromCountryConcept(France)
}
}
}
}
input (toCountry) {
type (ToCountryConcept)
min (Required)
max (One)
default-init {
intent {
goal: ToCountryConcept
value-set: ToCountryConcept {
ToCountryConcept(Austria)
ToCountryConcept(South Korea)
ToCountryConcept(USA)
ToCountryConcept(Spain)
ToCountryConcept(Germany)
ToCountryConcept(France)
}
}
}
}
input (letterContent) {
type (LetterContentConcept)
min (Required)
max (One)
}
}
output (SendLetterResponseConcept)
}
国家/input-view
地区概念FromCountry_Input.view.bxb
如下所示(ToCountry_Input.view.bxb
等效):
input-view {
match: FromCountryConcept(this)
message {
template ("Select the country this letter will be sent from")
}
render {
selection-of (this) {
where-each (fromCountry) {
// default-layout used
}
}
}
}
input-view
我希望用户能够输入的文本位于LetterContent_Input.view.bxb
:
input-view {
match: LetterContentConcept(this)
message {
template ("Write the content of the letter.")
}
render {
form {
on-submit {
goal: LetterContentConcept
value {
viv.core.FormElement(letterContent)
}
}
elements {
textarea {
id (letterContent)
label ("Letter Content")
type (LetterContentConcept)
value ("#{value(this)}")
}
}
}
}
}