Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date picker block #36

Closed
bartbutenaers opened this issue Sep 12, 2018 · 4 comments
Closed

Add date picker block #36

bartbutenaers opened this issue Sep 12, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@bartbutenaers
Copy link
Owner

Beside to the timestamp-block, it would be nice if a user could enter a date/time in a datetime picker:
image

This is supported by Blockly as the field_date block:

{
  "type": "example_date",
  "message0": "date: %1",
  "args0": [
    {
      "type": "field_date",
      "name": "FIELDNAME",
      "date": "2020-02-20"
    }
  ]
}

However got an error that the field_date widget doesn't exist. Seems that that widget increases the library size with 30%, so Google has commented it. When you want to use it, you need to uncomment those lines and build Blockly yourself again. There is a proposal for a workaround (widget in a separate .js file), but don't think that is available yet...

Here is the explanation by Andrew.

@bartbutenaers bartbutenaers self-assigned this Sep 12, 2018
@bartbutenaers bartbutenaers added the enhancement New feature or request label Sep 12, 2018
@bartbutenaers bartbutenaers changed the title Add date/time picker block Add date picker block Sep 12, 2018
@bartbutenaers
Copy link
Owner Author

Perhaps we should also add a time block. Or a timestamp block.
Here is another date picker.

And another proposal from the blockly forum:

For time input blocks, I use 2 number fields for hours and minutes, followed by a dropdown field for am/pm. I added a feature to the number field to pad the minutes with a leading zero when the number < 10 so my block would show "1:05" instead of "1:5"

@bartbutenaers
Copy link
Owner Author

@cymplecy, @jsccjj,
This is an old issue. But luckily the Blockly team has meanwhile created a separate NPM module for the date picker: see @blockly/field-date.

This module is added as a dependency in our node, so it is automatically installed. Our endpoint serves the files to the browser.

Short demo of the standard date picker, which I have added to our "Date/time" category:

blockly_date_picker

P.S. It always uses format yyyy-mm-dd, which can be passed directly to the Date constructor (as you can see in the generated Javascript code).

Weekend is over ;-(

@cymplecy
Copy link
Collaborator

cymplecy commented Jun 7, 2021

It looks nice :)

@bartbutenaers
Copy link
Owner Author

I'm going to close this issue. If it doesn't work as expected, it can be reopened afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants