Class: Slack::BlockKit::Element::DatePicker

Inherits:
Object
  • Object
show all
Includes:
Composition::ConfirmationDialog::Confirmable
Defined in:
lib/slack/block_kit/element/date_picker.rb

Overview

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.

api.slack.com/reference/messaging/block-elements#datepicker

Constant Summary collapse

TYPE =
'datepicker'

Instance Method Summary collapse

Methods included from Composition::ConfirmationDialog::Confirmable

#confirmation_dialog, included

Constructor Details

#initialize(action_id:, placeholder: nil, initial: nil, emoji: nil) {|_self| ... } ⇒ DatePicker

Returns a new instance of DatePicker.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/slack/block_kit/element/date_picker.rb', line 17

def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
  @action_id = action_id
  @initial_date = initial
  if placeholder
    @placeholder = Composition::PlainText.new(
      text: placeholder,
      emoji: emoji
    )
  end

  yield(self) if block_given?
end

Instance Method Details

#as_jsonObject



30
31
32
33
34
35
36
37
38
# File 'lib/slack/block_kit/element/date_picker.rb', line 30

def as_json(*)
  {
    type: TYPE,
    action_id: @action_id,
    placeholder: @placeholder&.as_json,
    initial_date: @initial_date,
    confirm: confirm&.as_json
  }.compact
end