diff options
author | Wim <wim@42.be> | 2019-09-07 22:46:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-07 22:46:58 +0200 |
commit | a3bee01e0af3394c19360b98fd2db1b647f49299 (patch) | |
tree | ffc5778361d55d592a718354a37c9251e75fc7f6 /vendor/github.com/nlopes/slack/dialog_select.go | |
parent | 1dc93ec4f001edd01daccbe408767d4878be25a3 (diff) | |
download | matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.gz matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.bz2 matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.zip |
Update dependencies (#886)
Diffstat (limited to 'vendor/github.com/nlopes/slack/dialog_select.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/dialog_select.go | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/vendor/github.com/nlopes/slack/dialog_select.go b/vendor/github.com/nlopes/slack/dialog_select.go index ea95ccfa..385cef68 100644 --- a/vendor/github.com/nlopes/slack/dialog_select.go +++ b/vendor/github.com/nlopes/slack/dialog_select.go @@ -21,10 +21,11 @@ type DialogInputSelect struct { DialogInput Value string `json:"value,omitempty"` //Optional. DataSource SelectDataSource `json:"data_source,omitempty"` //Optional. Allowed values: "users", "channels", "conversations", "external". - SelectedOptions string `json:"selected_options,omitempty"` //Optional. Default value for "external" only + SelectedOptions []DialogSelectOption `json:"selected_options,omitempty"` //Optional. May hold at most one element, for use with "external" only. Options []DialogSelectOption `json:"options,omitempty"` //One of options or option_groups is required. OptionGroups []DialogOptionGroup `json:"option_groups,omitempty"` //Provide up to 100 options. MinQueryLength int `json:"min_query_length,omitempty"` //Optional. minimum characters before query is sent. + Hint string `json:"hint,omitempty"` //Optional. Additional hint text. } // DialogSelectOption is an option for the user to select from the menu @@ -54,14 +55,7 @@ func NewStaticSelectDialogInput(name, label string, options []DialogSelectOption } // NewGroupedSelectDialogInput creates grouped options select input for Dialogs. -func NewGroupedSelectDialogInput(name, label string, groups map[string]map[string]string) *DialogInputSelect { - optionGroups := []DialogOptionGroup{} - for groupName, options := range groups { - optionGroups = append(optionGroups, DialogOptionGroup{ - Label: groupName, - Options: optionsFromMap(options), - }) - } +func NewGroupedSelectDialogInput(name, label string, options []DialogOptionGroup) *DialogInputSelect { return &DialogInputSelect{ DialogInput: DialogInput{ Type: InputTypeSelect, @@ -69,34 +63,15 @@ func NewGroupedSelectDialogInput(name, label string, groups map[string]map[strin Label: label, }, DataSource: DialogDataSourceStatic, - OptionGroups: optionGroups, - } -} - -func optionsFromArray(options []string) []DialogSelectOption { - selectOptions := make([]DialogSelectOption, len(options)) - for idx, value := range options { - selectOptions[idx] = DialogSelectOption{ - Label: value, - Value: value, - } - } - return selectOptions + OptionGroups: options} } -func optionsFromMap(options map[string]string) []DialogSelectOption { - selectOptions := make([]DialogSelectOption, len(options)) - idx := 0 - var option DialogSelectOption - for key, value := range options { - option = DialogSelectOption{ - Label: key, - Value: value, - } - selectOptions[idx] = option - idx++ +// NewDialogOptionGroup creates a DialogOptionGroup from several select options +func NewDialogOptionGroup(label string, options ...DialogSelectOption) DialogOptionGroup { + return DialogOptionGroup{ + Label: label, + Options: options, } - return selectOptions } // NewConversationsSelect returns a `Conversations` select |