Class: Slack::BlockKit::Element::Datepicker

Inherits:
Object
  • Object
show all
Includes:
Composition::ConfirmationDialog::Confirmable
Defined in:
lib/slack/block_kit/element/datepicker.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, focus_on_load: nil) {|_self| ... } ⇒ Datepicker

Returns a new instance of Datepicker.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
# File 'lib/slack/block_kit/element/datepicker.rb', line 17

def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil, focus_on_load: nil)
  @action_id = action_id
  @initial_date = initial
  @focus_on_load = focus_on_load
  @placeholder = placeholder_text(placeholder, emoji)

  yield(self) if block_given?
end

Instance Method Details

#as_jsonObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/slack/block_kit/element/datepicker.rb', line 26

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