From a4f133b512eca5617c15b53adea7fcaf1cb536f6 Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:08:16 -0300 Subject: [PATCH 1/6] Add convenience methods to NewOptionsSelectBlockElement --- block_element.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/block_element.go b/block_element.go index a2b755be2..dd1901115 100644 --- a/block_element.go +++ b/block_element.go @@ -258,6 +258,36 @@ func NewOptionsSelectBlockElement(optType string, placeholder *TextBlockObject, } } +// WithInitialOption sets the initial option for the select element +func (s *SelectBlockElement) WithInitialOption(option *OptionBlockObject) *SelectBlockElement { + s.InitialOption = option + return s +} + +// WithInitialUser sets the initial user for the select element +func (s *SelectBlockElement) WithInitialUser(user string) *SelectBlockElement { + s.InitialUser = user + return s +} + +// WithInitialConversation sets the initial conversation for the select element +func (s *SelectBlockElement) WithInitialConversation(conversation string) *SelectBlockElement { + s.InitialConversation = conversation + return s +} + +// WithInitialChannel sets the initial channel for the select element +func (s *SelectBlockElement) WithInitialChannel(channel string) *SelectBlockElement { + s.InitialChannel = channel + return s +} + +// WithConfirm adds a confirmation dialogue to the select element +func (s *SelectBlockElement) WithConfirm(confirm *ConfirmationBlockObject) *SelectBlockElement { + s.Confirm = confirm + return s +} + // NewOptionsGroupSelectBlockElement returns a new instance of SelectBlockElement for use with // the Options object only. func NewOptionsGroupSelectBlockElement( From f267b62b1a35b78ea8410f8b7cdc5e13674cc103 Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:12:53 -0300 Subject: [PATCH 2/6] Add convenience methods to NewInputBlock --- block_input.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block_input.go b/block_input.go index 78ffcdb81..7c1272a64 100644 --- a/block_input.go +++ b/block_input.go @@ -28,3 +28,15 @@ func NewInputBlock(blockID string, label, hint *TextBlockObject, element BlockEl Hint: hint, } } + +// WithOptional sets the optional flag on the input block +func (s *InputBlock) WithOptional(optional bool) *InputBlock { + s.Optional = optional + return s +} + +// WithDispatchAction sets the dispatch action flag on the input block +func (s *InputBlock) WithDispatchAction(dispatchAction bool) *InputBlock { + s.DispatchAction = dispatchAction + return s +} From 832b3a5724a37db3dd34d1966f3f678576a74525 Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:17:11 -0300 Subject: [PATCH 3/6] Add convenience methods to NewOptionsMultiSelectBlockElement --- block_element.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/block_element.go b/block_element.go index dd1901115..9a09fad14 100644 --- a/block_element.go +++ b/block_element.go @@ -339,6 +339,48 @@ func NewOptionsMultiSelectBlockElement(optType string, placeholder *TextBlockObj } } +// WithInitialOptions sets the initial options for the multi-select element +func (s *MultiSelectBlockElement) WithInitialOptions(options ...*OptionBlockObject) *MultiSelectBlockElement { + s.InitialOptions = options + return s +} + +// WithInitialUsers sets the initial users for the multi-select element +func (s *MultiSelectBlockElement) WithInitialUsers(users ...string) *MultiSelectBlockElement { + s.InitialUsers = users + return s +} + +// WithInitialConversations sets the initial conversations for the multi-select element +func (s *MultiSelectBlockElement) WithInitialConversations(conversations ...string) *MultiSelectBlockElement { + s.InitialConversations = conversations + return s +} + +// WithInitialChannels sets the initial channels for the multi-select element +func (s *MultiSelectBlockElement) WithInitialChannels(channels ...string) *MultiSelectBlockElement { + s.InitialChannels = channels + return s +} + +// WithConfirm adds a confirmation dialogue to the multi-select element +func (s *MultiSelectBlockElement) WithConfirm(confirm *ConfirmationBlockObject) *MultiSelectBlockElement { + s.Confirm = confirm + return s +} + +// WithMaxSelectedItems sets the maximum number of items that can be selected +func (s *MultiSelectBlockElement) WithMaxSelectedItems(maxSelectedItems int) *MultiSelectBlockElement { + s.MaxSelectedItems = &maxSelectedItems + return s +} + +// WithMinQueryLength sets the minimum query length for the multi-select element +func (s *MultiSelectBlockElement) WithMinQueryLength(minQueryLength int) *MultiSelectBlockElement { + s.MinQueryLength = &minQueryLength + return s +} + // NewOptionsGroupMultiSelectBlockElement returns a new instance of MultiSelectBlockElement for use with // the Options object only. func NewOptionsGroupMultiSelectBlockElement( From d1a9bf1147c4db7a9e31f823c3930dcd80f69f9f Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:18:28 -0300 Subject: [PATCH 4/6] Add convenience method to NewOverflowBlockElement --- block_element.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block_element.go b/block_element.go index 9a09fad14..b2a3669a4 100644 --- a/block_element.go +++ b/block_element.go @@ -424,6 +424,12 @@ func NewOverflowBlockElement(actionID string, options ...*OptionBlockObject) *Ov } } +// WithConfirm adds a confirmation dialogue to the overflow element +func (s *OverflowBlockElement) WithConfirm(confirm *ConfirmationBlockObject) *OverflowBlockElement { + s.Confirm = confirm + return s +} + // DatePickerBlockElement defines an element which lets users easily select a // date from a calendar style UI. Date picker elements can be used inside of // section and actions blocks. From 3070c1cd3f43724b80e0c59f9aa60e855137031d Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:20:08 -0300 Subject: [PATCH 5/6] Add convenience methods to NewPlainTextInputBlockElement --- block_element.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/block_element.go b/block_element.go index b2a3669a4..e5b2ae7b1 100644 --- a/block_element.go +++ b/block_element.go @@ -598,6 +598,36 @@ func NewPlainTextInputBlockElement(placeholder *TextBlockObject, actionID string } } +// WithInitialValue sets the initial value for the plain-text input element +func (s *PlainTextInputBlockElement) WithInitialValue(initialValue string) *PlainTextInputBlockElement { + s.InitialValue = initialValue + return s +} + +// WithMinLength sets the minimum length for the plain-text input element +func (s *PlainTextInputBlockElement) WithMinLength(minLength int) *PlainTextInputBlockElement { + s.MinLength = minLength + return s +} + +// WithMaxLength sets the maximum length for the plain-text input element +func (s *PlainTextInputBlockElement) WithMaxLength(maxLength int) *PlainTextInputBlockElement { + s.MaxLength = maxLength + return s +} + +// WithMultiline sets the multiline property for the plain-text input element +func (s *PlainTextInputBlockElement) WithMultiline(multiline bool) *PlainTextInputBlockElement { + s.Multiline = multiline + return s +} + +// WithDispatchActionConfig sets the dispatch action config for the plain-text input element +func (s *PlainTextInputBlockElement) WithDispatchActionConfig(config *DispatchActionConfig) *PlainTextInputBlockElement { + s.DispatchActionConfig = config + return s +} + // RichTextInputBlockElement creates a field where allows users to enter formatted text // in a WYSIWYG composer, offering the same messaging writing experience as in Slack // More Information: https://api.slack.com/reference/block-kit/block-elements#rich_text_input From a1c7f6d0385c778ff7fcc11ccdfb997c96bc85d0 Mon Sep 17 00:00:00 2001 From: "Obed S." Date: Thu, 18 Apr 2024 16:37:19 -0300 Subject: [PATCH 6/6] Add convenience methods to New NumberInputBlockElement --- block_element.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/block_element.go b/block_element.go index e5b2ae7b1..6edb4c22a 100644 --- a/block_element.go +++ b/block_element.go @@ -737,6 +737,30 @@ func NewNumberInputBlockElement(placeholder *TextBlockObject, actionID string, i } } +// WithInitialValue sets the initial value for the number input element +func (s *NumberInputBlockElement) WithInitialValue(initialValue string) *NumberInputBlockElement { + s.InitialValue = initialValue + return s +} + +// WithMinValue sets the minimum value for the number input element +func (s *NumberInputBlockElement) WithMinValue(minValue string) *NumberInputBlockElement { + s.MinValue = minValue + return s +} + +// WithMaxValue sets the maximum value for the number input element +func (s *NumberInputBlockElement) WithMaxValue(maxValue string) *NumberInputBlockElement { + s.MaxValue = maxValue + return s +} + +// WithDispatchActionConfig sets the dispatch action config for the number input element +func (s *NumberInputBlockElement) WithDispatchActionConfig(config *DispatchActionConfig) *NumberInputBlockElement { + s.DispatchActionConfig = config + return s +} + // FileInputBlockElement creates a field where a user can upload a file. // // File input elements are currently only available in modals.