在Bixby输入视图中,如何在多复选框中匹配多个概念

时间:2019-10-01 15:35:06

标签: bixby

我要用户填写一个包含多个复选框表单元素的表单,以为多个概念提供真/假值。

所以我有这样的看法:

input-view{
    match:PremiumContent

  message("Which of the following features do you need?")

    render{
    form{
      elements{
        checkbox{
          id(premiumcontent)
          type (PremiumContent)
          primary-text (Yes, I want to provide premium content.)
          secondary-text (We recommend providing a free tier.)
          value(true)
        }
        checkbox{
          id(searchabletext)
          type (SearchableText)
          primary-text (Yes, I want to provide searchable text.)
          secondary-text (Passages of one to three paragraphs work well.)
          value(true)
        }
        checkbox{
          id(twittersearch)
          type (TwitterSearch)
          primary-text (Yes, I want to pull permissioned Twitter results into my capsule.)
          secondary-text (AltBrains supports the full twitter search syntax.)
          value(true)
        }
         checkbox{
          id(carousel)
          type (Carousel)
          primary-text (Yes, I want an image gallery.)
          secondary-text (JPG or PNG at least 720 x 480.)
          value(true)
        }
      }
          on-submit{
        goal:PremiumContent
        value:viv.core.FormElement(premiumcontent)
      }
    }
  }
}

将会替换PremiumContent,SearchableText,Carousel和TwitterSearch的四个单独的视图页面。但是我不知道如何构造匹配查询。我该如何处理?

2 个答案:

答案 0 :(得分:1)

我会尝试让父母Boolean,然后让PremiumContentSearchableTextTwitterSearchCarousel中的每一个都担任该父母的角色布尔值或扩展它。然后,您将在匹配模式中使用该父布尔值。

类似这样:

boolean (Parent) {}

boolean (PremiumContent) {
  role-of (Parent)
}
boolean (SearchableText) {
  role-of (Parent)
}
...

boolean (PremiumContent) {
  extends (Parent)
}
boolean (SearchableText) {
  extends (Parent)
}
...

,那么您的匹配模式将是:

match: Parent

和您的on-submit应该类似于:

on-submit {
  goal: Parent
  value-set: Parent {
    viv.core.FormElement (premiumcontent)
    viv.core.FormElement (searchabletext)
    ...
  }
}

或者,您可以使用四个不同的布尔属性创建一个结构,然后在匹配模式中使用该结构。像这样:

structure (Thing) {
  property (premiumContent) {
    type (PremiumContent)
  }
  ...
}

然后您的匹配模式将是:

match: Thing

,那么您的on-submit将是:

on-submit {
  goal: Thing
  value: Thing {
    premiumContent: viv.core.FormElement (premiumcontent)
    ...
  }
}

答案 1 :(得分:1)

创建一个包含所有布尔值as属性的结构。

使用以下示例。了解更多here

input-view {
  match: Person (this)

  message {
    template (Fill in your information)
  }

  render {
    form {
      // the intent that will be used when the form is submitted
      on-submit {
        goal: viv.tutorial.Person
        value: viv.tutorial.Person {
          wineClubJoined: viv.core.FormElement(wineclub)
          beerClubJoined: viv.core.FormElement(beerclub)
        }
      }
      elements {
        checkbox {
          id ("wineclub")
          type (WineClubJoined)
          primary-text (Join the wine club)
          secondary-text (We will invite you to our monthly wine events)
          value ("#{raw(this.wineClubJoined)}")
        }
        checkbox {
          id ("beerclub")
          type (BeerClubJoined)
          primary-text (Join the beer club)
          secondary-text (We will invite you to our monthly beer events)
          value ("#{raw(this.beerClubJoined)}")
        }

      }
    }
  }