slack-ruby-block-kit 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.github/dependabot.yml +9 -0
- data/.rubocop.yml +31 -1
- data/Gemfile.lock +29 -26
- data/lib/slack/block_kit.rb +5 -5
- data/lib/slack/block_kit/composition/confirmation_dialog.rb +4 -0
- data/lib/slack/block_kit/composition/option.rb +1 -1
- data/lib/slack/block_kit/element/external_select.rb +1 -0
- data/lib/slack/block_kit/element/multi_channels_select.rb +51 -0
- data/lib/slack/block_kit/element/multi_conversations_select.rb +52 -0
- data/lib/slack/block_kit/element/multi_external_select.rb +61 -0
- data/lib/slack/block_kit/element/multi_static_select.rb +88 -0
- data/lib/slack/block_kit/element/multi_users_select.rb +51 -0
- data/lib/slack/block_kit/element/overflow_menu.rb +1 -0
- data/lib/slack/block_kit/element/plain_text_input.rb +1 -1
- data/lib/slack/block_kit/layout/context.rb +1 -0
- data/lib/slack/block_kit/layout/section.rb +8 -0
- data/lib/slack/block_kit/layout/section/multi_select_elements.rb +92 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa3cc74b7d6e5de2e6889ec9fdc8ba02b8678be5731708cb7b5319985d839354
|
4
|
+
data.tar.gz: a261f505882c2662bd1009ff3a020a394154dcfe336439e032e0942085a2df46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d3a21decd19a4cfb54351bf31d2ec36516f2777a010ceae26e21b121f3bf229b8c8df2d7a9cef7598ae8fe2f93e42642321d8d7cd72cccdc8b384a62845da2
|
7
|
+
data.tar.gz: c90b7442867bc51d87d8d1bb2c6a34193bcc6ad3cec7808527955e5bc0b157360ffac521ed58b8bd545fca76c3bf86f4d459e649eb26f0e5a69b10a990aa4076
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,7 +4,7 @@ inherit_from: .rubocop_todo.yml
|
|
4
4
|
AllCops:
|
5
5
|
TargetRubyVersion: 2.5.3
|
6
6
|
|
7
|
-
|
7
|
+
Layout/LineLength:
|
8
8
|
Max: 120
|
9
9
|
|
10
10
|
Style/AsciiComments:
|
@@ -23,3 +23,33 @@ Metrics/BlockLength:
|
|
23
23
|
- '**/*.rake'
|
24
24
|
- 'spec/**/*.rb'
|
25
25
|
- '**/*.gemspec'
|
26
|
+
|
27
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Layout/SpaceAroundMethodCallOperator:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Lint/DeprecatedOpenSSLConstant:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Lint/RaiseException:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Lint/StructNewOverride:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Style/ExponentialNotation:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
Style/HashEachMethods:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Style/HashTransformKeys:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
Style/HashTransformValues:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Style/SlicingWithRange:
|
55
|
+
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,59 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack-ruby-block-kit (0.
|
4
|
+
slack-ruby-block-kit (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
9
|
+
ast (2.4.1)
|
10
10
|
coderay (1.1.2)
|
11
11
|
diff-lcs (1.3)
|
12
12
|
dotenv (2.7.5)
|
13
13
|
faraday (1.0.1)
|
14
14
|
multipart-post (>= 1.2, < 3)
|
15
|
-
jaro_winkler (1.5.2)
|
16
15
|
method_source (1.0.0)
|
17
16
|
multipart-post (2.1.1)
|
18
|
-
parallel (1.
|
19
|
-
parser (2.
|
17
|
+
parallel (1.19.1)
|
18
|
+
parser (2.7.1.3)
|
20
19
|
ast (~> 2.4.0)
|
21
|
-
powerpack (0.1.2)
|
22
20
|
pry (0.13.1)
|
23
21
|
coderay (~> 1.1)
|
24
22
|
method_source (~> 1.0)
|
25
23
|
rainbow (3.0.0)
|
26
24
|
rake (13.0.1)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
rspec-
|
31
|
-
|
32
|
-
rspec-
|
33
|
-
rspec-
|
25
|
+
regexp_parser (1.7.1)
|
26
|
+
rexml (3.2.4)
|
27
|
+
rspec (3.9.0)
|
28
|
+
rspec-core (~> 3.9.0)
|
29
|
+
rspec-expectations (~> 3.9.0)
|
30
|
+
rspec-mocks (~> 3.9.0)
|
31
|
+
rspec-core (3.9.2)
|
32
|
+
rspec-support (~> 3.9.3)
|
33
|
+
rspec-expectations (3.9.2)
|
34
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-mocks (3.
|
35
|
+
rspec-support (~> 3.9.0)
|
36
|
+
rspec-mocks (3.9.1)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-support (3.
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-support (3.9.3)
|
40
40
|
rspec_junit_formatter (0.4.1)
|
41
41
|
rspec-core (>= 2, < 4, != 2.12.0)
|
42
|
-
rubocop (0.
|
43
|
-
jaro_winkler (~> 1.5.1)
|
42
|
+
rubocop (0.85.1)
|
44
43
|
parallel (~> 1.10)
|
45
|
-
parser (>= 2.
|
46
|
-
powerpack (~> 0.1)
|
44
|
+
parser (>= 2.7.0.1)
|
47
45
|
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.7)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 0.0.3)
|
48
49
|
ruby-progressbar (~> 1.7)
|
49
|
-
unicode-display_width (
|
50
|
-
rubocop-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
51
|
+
rubocop-ast (0.0.3)
|
52
|
+
parser (>= 2.7.0.1)
|
53
|
+
rubocop-rspec (1.40.0)
|
54
|
+
rubocop (>= 0.68.1)
|
55
|
+
ruby-progressbar (1.10.1)
|
56
|
+
unicode-display_width (1.7.0)
|
54
57
|
|
55
58
|
PLATFORMS
|
56
59
|
ruby
|
data/lib/slack/block_kit.rb
CHANGED
@@ -6,12 +6,12 @@ module Slack
|
|
6
6
|
module Element; end
|
7
7
|
module Layout; end
|
8
8
|
|
9
|
-
VERSION = '0.
|
9
|
+
VERSION = '0.7.0'
|
10
10
|
|
11
|
-
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].each { |file| require file }
|
12
|
-
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].each { |file| require file }
|
13
|
-
Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].each { |file| require file }
|
14
|
-
Dir[File.join(__dir__, 'block_kit', '*.rb')].each { |file| require file }
|
11
|
+
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
|
12
|
+
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
|
13
|
+
Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
|
14
|
+
Dir[File.join(__dir__, 'block_kit', '*.rb')].sort.each { |file| require file }
|
15
15
|
|
16
16
|
module_function
|
17
17
|
|
@@ -9,6 +9,10 @@ module Slack
|
|
9
9
|
#
|
10
10
|
# https://api.slack.com/reference/messaging/composition-objects#confirm
|
11
11
|
class ConfirmationDialog
|
12
|
+
def initialize
|
13
|
+
@title, @confirm, @text, @style = nil
|
14
|
+
end
|
15
|
+
|
12
16
|
def title(text:, emoji: nil)
|
13
17
|
@title = PlainText.new(text: text, emoji: emoji)
|
14
18
|
|
@@ -11,7 +11,7 @@ module Slack
|
|
11
11
|
def initialize(value:, text:, emoji: nil, description: nil, url: nil)
|
12
12
|
@text = PlainText.new(text: text, emoji: emoji)
|
13
13
|
@value = value
|
14
|
-
@description = PlainText.new(text: description, emoji: emoji)
|
14
|
+
@description = description && PlainText.new(text: description, emoji: emoji)
|
15
15
|
@url = url
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
9
|
+
# all of an option string to filter the list.
|
10
|
+
#
|
11
|
+
# This multi-select menu will populate its options with a list of public
|
12
|
+
# channels visible to the current user in the active workspace.
|
13
|
+
#
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#channel_multi_select
|
15
|
+
class MultiChannelsSelect
|
16
|
+
TYPE = 'multi_channels_select'
|
17
|
+
|
18
|
+
attr_accessor :confirm
|
19
|
+
|
20
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
22
|
+
@action_id = action_id
|
23
|
+
@initial_channel = initial
|
24
|
+
@confirm = nil
|
25
|
+
@max_selected_items = max_selected_items
|
26
|
+
|
27
|
+
yield(self) if block_given?
|
28
|
+
end
|
29
|
+
|
30
|
+
def confirmation_dialog
|
31
|
+
@confirm = Composition::ConfirmationDialog.new
|
32
|
+
|
33
|
+
yield(@confirm) if block_given?
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def as_json(*)
|
39
|
+
{
|
40
|
+
type: TYPE,
|
41
|
+
placeholder: @placeholder.as_json,
|
42
|
+
action_id: @action_id,
|
43
|
+
initial_channel: @initial_channel,
|
44
|
+
confirm: @confirm&.as_json,
|
45
|
+
max_selected_items: @max_selected_items
|
46
|
+
}.compact
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
9
|
+
# all of an option string to filter the list.
|
10
|
+
#
|
11
|
+
# This multi-select menu will populate its options with a list of public and
|
12
|
+
# private channels, DMs, and MPIMs visible to the current user in the
|
13
|
+
# active workspace.
|
14
|
+
#
|
15
|
+
# https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select
|
16
|
+
class MultiConversationsSelect
|
17
|
+
TYPE = 'multi_conversations_select'
|
18
|
+
|
19
|
+
attr_accessor :confirm
|
20
|
+
|
21
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
22
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
23
|
+
@action_id = action_id
|
24
|
+
@initial_conversation = initial
|
25
|
+
@confirm = nil
|
26
|
+
@max_selected_items = max_selected_items
|
27
|
+
|
28
|
+
yield(self) if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def confirmation_dialog
|
32
|
+
@confirm = Composition::ConfirmationDialog.new
|
33
|
+
|
34
|
+
yield(@confirm) if block_given?
|
35
|
+
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def as_json(*)
|
40
|
+
{
|
41
|
+
type: TYPE,
|
42
|
+
placeholder: @placeholder.as_json,
|
43
|
+
action_id: @action_id,
|
44
|
+
initial_conversation: @initial_conversation,
|
45
|
+
confirm: @confirm&.as_json,
|
46
|
+
max_selected_items: @max_selected_items
|
47
|
+
}.compact
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
9
|
+
# all of an option string to filter the list.
|
10
|
+
#
|
11
|
+
# This select menu will load its options from an external data source,
|
12
|
+
# allowing for a dynamic list of options.
|
13
|
+
#
|
14
|
+
# Each time a select menu of this type is opened or the user starts typing
|
15
|
+
# in the typeahead field, we'll send a request to your specified URL. Your
|
16
|
+
# app should return an HTTP 200 OK response, along with an
|
17
|
+
# application/json post body with an object containing either an options
|
18
|
+
# array, or an option_groups array.
|
19
|
+
#
|
20
|
+
# https://api.slack.com/reference/block-kit/block-elements#external_multi_select
|
21
|
+
class MultiExternalSelect
|
22
|
+
TYPE = 'multi_external_select'
|
23
|
+
|
24
|
+
attr_accessor :confirm
|
25
|
+
|
26
|
+
def initialize(placeholder:, action_id:,
|
27
|
+
initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil)
|
28
|
+
|
29
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
30
|
+
@action_id = action_id
|
31
|
+
@initial_option = initial
|
32
|
+
@min_query_length = min_query_length
|
33
|
+
@confirm = nil
|
34
|
+
@max_selected_items = max_selected_items
|
35
|
+
|
36
|
+
yield(self) if block_given?
|
37
|
+
end
|
38
|
+
|
39
|
+
def confirmation_dialog
|
40
|
+
@confirm = Composition::ConfirmationDialog.new
|
41
|
+
|
42
|
+
yield(@confirm) if block_given?
|
43
|
+
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
def as_json(*)
|
48
|
+
{
|
49
|
+
type: TYPE,
|
50
|
+
placeholder: @placeholder.as_json,
|
51
|
+
action_id: @action_id,
|
52
|
+
initial_option: @initial_option&.as_json,
|
53
|
+
min_query_length: @min_query_length,
|
54
|
+
confirm: @confirm&.as_json,
|
55
|
+
max_selected_items: @max_selected_items
|
56
|
+
}.compact
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
9
|
+
# all of an option string to filter the list.
|
10
|
+
#
|
11
|
+
# This is the simplest form of select menu, with a static list of options
|
12
|
+
# passed in when defining the element.
|
13
|
+
#
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#static_multi_select
|
15
|
+
class MultiStaticSelect
|
16
|
+
TYPE = 'multi_static_select'
|
17
|
+
|
18
|
+
attr_accessor :confirm, :options, :option_groups, :initial_option
|
19
|
+
|
20
|
+
def initialize(placeholder:, action_id:, emoji: nil, max_selected_items: nil)
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
22
|
+
@action_id = action_id
|
23
|
+
@confirm = nil
|
24
|
+
@max_selected_items = max_selected_items
|
25
|
+
|
26
|
+
@options = nil
|
27
|
+
@option_groups = nil
|
28
|
+
@initial_option = nil
|
29
|
+
|
30
|
+
yield(self) if block_given?
|
31
|
+
end
|
32
|
+
|
33
|
+
def confirmation_dialog
|
34
|
+
@confirm = Composition::ConfirmationDialog.new
|
35
|
+
|
36
|
+
yield(@confirm) if block_given?
|
37
|
+
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def option(value:, text:, emoji: nil)
|
42
|
+
@options ||= []
|
43
|
+
@options << Composition::Option.new(
|
44
|
+
value: value,
|
45
|
+
text: text,
|
46
|
+
emoji: emoji
|
47
|
+
)
|
48
|
+
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def option_group(label:, emoji: nil)
|
53
|
+
option_group = Composition::OptionGroup.new(label: label, emoji: emoji)
|
54
|
+
|
55
|
+
yield(option_group) if block_given?
|
56
|
+
|
57
|
+
@option_groups ||= []
|
58
|
+
@option_groups << option_group
|
59
|
+
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def initial(value:, text:, emoji: nil)
|
64
|
+
@initial_option = Composition::Option.new(
|
65
|
+
value: value,
|
66
|
+
text: text,
|
67
|
+
emoji: emoji
|
68
|
+
)
|
69
|
+
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
def as_json(*)
|
74
|
+
{
|
75
|
+
type: TYPE,
|
76
|
+
placeholder: @placeholder.as_json,
|
77
|
+
action_id: @action_id,
|
78
|
+
options: @options&.map(&:as_json),
|
79
|
+
option_groups: @option_groups&.map(&:as_json),
|
80
|
+
initial_option: @initial_option&.as_json,
|
81
|
+
confirm: @confirm&.as_json,
|
82
|
+
max_selected_items: @max_selected_items
|
83
|
+
}.compact
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
9
|
+
# all of an option string to filter the list.
|
10
|
+
#
|
11
|
+
# This multi-select menu will populate its options with a list of Slack users
|
12
|
+
# visible to the current user in the active workspace.
|
13
|
+
#
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#users_multi_select
|
15
|
+
class MultiUsersSelect
|
16
|
+
TYPE = 'multi_users_select'
|
17
|
+
|
18
|
+
attr_accessor :confirm
|
19
|
+
|
20
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
22
|
+
@action_id = action_id
|
23
|
+
@initial_user = initial
|
24
|
+
@confirm = nil
|
25
|
+
@max_selected_items = max_selected_items
|
26
|
+
|
27
|
+
yield(self) if block_given?
|
28
|
+
end
|
29
|
+
|
30
|
+
def confirmation_dialog
|
31
|
+
@confirm = Composition::ConfirmationDialog.new
|
32
|
+
|
33
|
+
yield(@confirm) if block_given?
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def as_json(*)
|
39
|
+
{
|
40
|
+
type: TYPE,
|
41
|
+
placeholder: @placeholder.as_json,
|
42
|
+
action_id: @action_id,
|
43
|
+
initial_user: @initial_user,
|
44
|
+
confirm: @confirm&.as_json,
|
45
|
+
max_selected_items: @max_selected_items
|
46
|
+
}.compact
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -22,7 +22,7 @@ module Slack
|
|
22
22
|
min_length: nil,
|
23
23
|
max_length: nil
|
24
24
|
)
|
25
|
-
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
25
|
+
@placeholder = placeholder && Composition::PlainText.new(text: placeholder, emoji: emoji)
|
26
26
|
@initial_value = initial_value
|
27
27
|
@action_id = action_id
|
28
28
|
@multiline = multiline
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './section/multi_select_elements'
|
4
|
+
|
3
5
|
module Slack
|
4
6
|
module BlockKit
|
5
7
|
module Layout
|
@@ -8,13 +10,19 @@ module Slack
|
|
8
10
|
# with any of the available block elements.
|
9
11
|
#
|
10
12
|
# https://api.slack.com/reference/messaging/blocks#section
|
13
|
+
# rubocop:disable Metrics/ClassLength
|
11
14
|
class Section
|
15
|
+
# rubocop:enable Metrics/ClassLength
|
16
|
+
|
17
|
+
include Section::MultiSelectElements
|
12
18
|
TYPE = 'section'
|
13
19
|
|
14
20
|
attr_accessor :fields, :text, :accessory
|
15
21
|
|
16
22
|
def initialize(block_id: nil)
|
17
23
|
@block_id = block_id
|
24
|
+
@fields = nil
|
25
|
+
@accessory = nil
|
18
26
|
|
19
27
|
yield(self) if block_given?
|
20
28
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Section
|
7
|
+
# Helper methods for Multi Select to inject to section
|
8
|
+
module MultiSelectElements
|
9
|
+
def multi_channels_select(placeholder:, action_id:,
|
10
|
+
initial: nil, emoji: nil, max_selected_items: nil)
|
11
|
+
element = Element::MultiChannelsSelect.new(
|
12
|
+
placeholder: placeholder,
|
13
|
+
action_id: action_id,
|
14
|
+
initial: initial,
|
15
|
+
emoji: emoji,
|
16
|
+
max_selected_items: max_selected_items
|
17
|
+
)
|
18
|
+
|
19
|
+
yield(element) if block_given?
|
20
|
+
|
21
|
+
accessorise(element)
|
22
|
+
end
|
23
|
+
|
24
|
+
def multi_conversations_select(placeholder:, action_id:,
|
25
|
+
initial: nil, emoji: nil, max_selected_items: nil)
|
26
|
+
element = Element::MultiConversationsSelect.new(
|
27
|
+
placeholder: placeholder,
|
28
|
+
action_id: action_id,
|
29
|
+
initial: initial,
|
30
|
+
emoji: emoji,
|
31
|
+
max_selected_items: max_selected_items
|
32
|
+
)
|
33
|
+
|
34
|
+
yield(element) if block_given?
|
35
|
+
|
36
|
+
accessorise(element)
|
37
|
+
end
|
38
|
+
|
39
|
+
def multi_external_select(placeholder:, action_id:,
|
40
|
+
initial: nil,
|
41
|
+
min_query_length: nil,
|
42
|
+
emoji: nil,
|
43
|
+
max_selected_items: nil)
|
44
|
+
element = Element::MultiExternalSelect.new(
|
45
|
+
placeholder: placeholder,
|
46
|
+
action_id: action_id,
|
47
|
+
initial: initial,
|
48
|
+
min_query_length: min_query_length,
|
49
|
+
emoji: emoji,
|
50
|
+
max_selected_items: max_selected_items
|
51
|
+
)
|
52
|
+
|
53
|
+
yield(element) if block_given?
|
54
|
+
|
55
|
+
accessorise(element)
|
56
|
+
end
|
57
|
+
|
58
|
+
def multi_static_select(placeholder:, action_id:,
|
59
|
+
emoji: nil, max_selected_items: nil)
|
60
|
+
element = Element::MultiStaticSelect.new(
|
61
|
+
placeholder: placeholder,
|
62
|
+
action_id: action_id,
|
63
|
+
emoji: emoji,
|
64
|
+
max_selected_items: max_selected_items
|
65
|
+
)
|
66
|
+
|
67
|
+
yield(element) if block_given?
|
68
|
+
|
69
|
+
accessorise(element)
|
70
|
+
end
|
71
|
+
|
72
|
+
def multi_users_select(placeholder:, action_id:,
|
73
|
+
initial: nil,
|
74
|
+
emoji: nil,
|
75
|
+
max_selected_items: nil)
|
76
|
+
element = Element::MultiUsersSelect.new(
|
77
|
+
placeholder: placeholder,
|
78
|
+
action_id: action_id,
|
79
|
+
emoji: emoji,
|
80
|
+
initial: initial,
|
81
|
+
max_selected_items: max_selected_items
|
82
|
+
)
|
83
|
+
|
84
|
+
yield(element) if block_given?
|
85
|
+
|
86
|
+
accessorise(element)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-block-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Gregg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,6 +144,7 @@ extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
146
|
- ".circleci/config.yml"
|
147
|
+
- ".github/dependabot.yml"
|
147
148
|
- ".gitignore"
|
148
149
|
- ".rspec"
|
149
150
|
- ".rubocop.yml"
|
@@ -168,6 +169,11 @@ files:
|
|
168
169
|
- lib/slack/block_kit/element/date_picker.rb
|
169
170
|
- lib/slack/block_kit/element/external_select.rb
|
170
171
|
- lib/slack/block_kit/element/image.rb
|
172
|
+
- lib/slack/block_kit/element/multi_channels_select.rb
|
173
|
+
- lib/slack/block_kit/element/multi_conversations_select.rb
|
174
|
+
- lib/slack/block_kit/element/multi_external_select.rb
|
175
|
+
- lib/slack/block_kit/element/multi_static_select.rb
|
176
|
+
- lib/slack/block_kit/element/multi_users_select.rb
|
171
177
|
- lib/slack/block_kit/element/overflow_menu.rb
|
172
178
|
- lib/slack/block_kit/element/plain_text_input.rb
|
173
179
|
- lib/slack/block_kit/element/static_select.rb
|
@@ -178,6 +184,7 @@ files:
|
|
178
184
|
- lib/slack/block_kit/layout/image.rb
|
179
185
|
- lib/slack/block_kit/layout/input.rb
|
180
186
|
- lib/slack/block_kit/layout/section.rb
|
187
|
+
- lib/slack/block_kit/layout/section/multi_select_elements.rb
|
181
188
|
- slack-ruby-block-kit.gemspec
|
182
189
|
homepage: https://github.com/CGA1123/slack-ruby-block-kit
|
183
190
|
licenses:
|