是否可以创建一个松弛的datetime picker元素? [英] Is it possible to create a slack datetime picker element?

查看:86
本文介绍了是否可以创建一个松弛的datetime picker元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的懈怠机器人来支持用户输入日期和时间,我知道有DatePicker可以输入特定日期.但是我也需要时间,我在考虑使用文本字段来输入字符串,但是令人讨厌的是用户每次都必须处理格式问题. 有一个更好的方法吗?还是可以自己做一个日期时间选择器?

I need my slack bot to support user input date and time, I know there is DatePicker which I can input a certain date. But I also need time, I am thinking to use a text field to just input string, but it's annoying that users have to deal with format stuff every time. Is there a better way to do this? or is it possible to make a date time picker by myself?

用户可以输入任何特定的时间,小时或分钟.

edit: Users might input any specific time, any hour or minute.

推荐答案

Slack API当前仅提供日期选择器,而不提供日期时间选择器.

The Slack API currently only provides a date picker, not not a datetime picker.

但是,您可以自己创建日期时间选择器:结合日期选择器元素与静态选择菜单元素具有所有时间选项,瞧,您有一个日期时间选择器.

However, you can create a datetime picker yourself: Combine a date picker element with a static select menu element that has all the time options and voila you have a datetime picker.

这将最容易在模块中实现,因为这允许用户同时设置多个元素的值.

This would be easiest to be implemented in a Modal, since this allows a user to set values for multiple elements at the same time.

以下是

Here is an example with block-kit. Depending on the granularity of your time values you may want to generate the list of options programmatically.

如果您需要提供更细致的输入(例如直到分钟),那么我建议放置两个选择:

And if you need to provide a more granular input, like down to the minute, then I would suggest to place two selects:

  • 第一个小时(00-23)
  • 第二分钟(00-59)

这是更新的代码块示例有关其外观.

Here is an updated block-kit example on how this would look.

这是该示例的屏幕截图:

And here is a screenshot of the example:

如果需要,可以持续几秒钟.

Dito for seconds if you need them.

select元素允许的最大选项数量为100,因此可以使用.

The maximum allowed number of options for a select element is 100, so this will work.

这篇关于是否可以创建一个松弛的datetime picker元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆