【问题标题】:Not sure how to update a struct with new information不确定如何使用新信息更新结构
【发布时间】:2019-04-15 10:57:02
【问题描述】:

关于 Bixby Studio 的问题。

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

我有一个 Filter 结构,其中包含一些字段,例如 SearchField、Genre、Platforms(游戏控制台)和 Themes(其他一些条目)

默认情况下,所有这些都是可选的,尤其是搜索字段。但是,我希望用户能够明显地看到启用了哪些过滤器,并能够选择和更改它们的值(这些值可以被 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
}

【问题讨论】:

    标签: bixby bixbystudio


    【解决方案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)}")
            }
          }
        }
      }
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      • 2023-04-07
      • 1970-01-01
      • 2018-03-10
      • 1970-01-01
      • 2021-04-13
      • 2017-05-09
      相关资源
      最近更新 更多