Class: Slack::BlockKit::Element::Datetimepicker

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

Overview

An element that allows the selection of both a date and a time of day formatted as a UNIX timestamp.

On desktop clients, the time picker will take the form of a dropdown list and the date picker will take the form of a dropdown calendar. Both options will have free-text entry for precise choices. On mobile clients, the time picker and date picker will use native UIs.

api.slack.com/reference/block-kit/block-elements#datetimepicker

Constant Summary collapse

TYPE =
'datetimepicker'

Instance Method Summary collapse

Methods included from Composition::ConfirmationDialog::Confirmable

#confirmation_dialog, included

Constructor Details

#initialize(action_id:, initial: nil, focus_on_load: nil) {|_self| ... } ⇒ Datetimepicker

Returns a new instance of Datetimepicker.

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
24
25
26
# File 'lib/slack/block_kit/element/datetimepicker.rb', line 20

def initialize(action_id:, initial: nil, focus_on_load: nil)
  @action_id = action_id
  @initial_datetime = initial
  @focus_on_load = focus_on_load

  yield(self) if block_given?
end

Instance Method Details

#as_jsonObject



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

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