Is it possible to create a slack datetime picker element?

巧了我就是萌 提交于 2020-03-22 12:15:52

问题


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.


回答1:


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:

  • First for the hour (00 - 23)
  • Second for the minute (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.

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



来源:https://stackoverflow.com/questions/58618607/is-it-possible-to-create-a-slack-datetime-picker-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!