不确定如何使用新信息更新结构

时间:2019-04-14 10:44:22

标签: bixby bixbystudio

有关Bixby Studio的问题。

我试图弄清楚如何接受用户的文本输入。

我有一个带有一些字段的Filter结构,例如SearchField,流派,平台(游戏机)和主题(其他一些条目)

默认情况下,所有这些都是可选的,尤其是在搜索字段中。但是,我希望用户能够看到启用了哪些过滤器,并能够选择和更改其值(NLP培训可以覆盖此值,但是我不知道如何禁用该字段)

我为过滤器创建了一个结果视图,并设置了输入单元格以选择要修改的特定字段。 (在这种情况下,为SearchField。)。我已经成功重定向到输入视图,但是无论我在此处输入什么文本,它都不会保存或不应用于我的过滤器。

寻求对问题的一些了解,并愿意根据需要提供更多信息。

我过去尝试过的某些方法,似乎想要在过滤器(可能不存在)中使用现有上下文“ SearchField”,并将其应用于新的“搜索字段”。但是,这不起作用,似乎会创建一个循环。

我也曾尝试在动作模型中为SetSearchField设置prompt-behavior (AlwaysSelection),但它似乎无能为力。

// Result View for Filters
result-view {
  match {
    Filter(this)
  }
  message {
    template (Active Filters){
      speech (Would you like to change any filters?)
    }
  }
  render {
    layout-macro (filter-details) {
      param (filter) {
        expression (this)
      }
    }
  }
}
// Layout Macro

layout-macro-def(filter-details) {
  params {
    param (filter) {
      type (Filter)
      min (Required)
      max (One)
    }
  }

  content {
    section {
      title (Filters)
      content {
        input-cell {
          label (Search Name)
          value ("#{value(filter.name)}")
          on-click {
            intent {
              goal: SetSearchField // <-------- Field in question
            }
          }
        }
      }
    }
  }
}
// Input-view for SearchField

input-view {
  match {
    SearchField(searchField)
  }
  render {
    form {
      elements {
        text-input {
          id (val)
          type (SearchField)
          required (true)
        }
      }
      on-submit {
        goal:SearchField
      }
    }
  }
}
// SetSearchField action
action (SetSearchField) {
  description (Sets the name in a search filter)
  type (Fetch)
  collect {
    input (newSearchField) {
      type (SearchField)
      min (Required)
      prompt-behavior (AlwaysSelection)
    }
  }
  output (SearchField)
}
// SetSearchField endpoint
    action-endpoint (SetSearchField) {
      accepted-inputs (newSearchField) 
      local-endpoint ("filters/SetSearchField.js")
    }

// .js file

module.exports.function = function setName (newSearchField) {
  return newSearchField
}

1 个答案:

答案 0 :(得分:1)

我发现访问输入表单元素以获取输入视图的一种特殊方法。

通过form-> elements收集输入,然后使用viv.core.FormElement(id)

引用它们
input-view {
  match {
    SearchField(searchField)
  }
  render {
    form {
      on-submit {
        goal: SearchField
        value: viv.core.FormElement(text)
      }
      elements {
        text-input {
          id (text)
          type (SearchField)
          label (Search for: )
          value("#{raw(searchField)}")
        }
      }
    }
  }
}