blockly-samples icon indicating copy to clipboard operation
blockly-samples copied to clipboard

Field-date field with restricted dates

Open samlvarez opened this issue 2 years ago • 3 comments

Component Field-date

Is your feature request related to a problem? Please describe.

I would like to create a custom time range of availability, for example that a user is only able choose from 2020 to 2022 and the rest of dates were shown as unable. Or even even more specific time ranges and only allow the user to choose from a list of available dates.

Right now the users get confuses because sometimes they can choose from all dates when they know there are some restrictions.

Describe the solution you'd like

A visual restricted calendar where you can see what dates are able to choose or not and if the date is not able you can't click on it because it's disabled.

Describe alternatives you've considered

I asked in Blockly groups and the ideas are to use validators (I am trying, but the restricted dates are not shown as disabled in the calendar) and to extend the field with subclasses.

Additional context

This is another calendar I have for the users that is exactly as i want it with blockly. This one is from the Ionic library.

Captura de pantalla 2023-01-27 a las 6 59 06

Thank you very much!

samlvarez avatar Jan 27 '23 06:01 samlvarez

This is a perfectly reasonable request, but I'm not sure it's possible to fulfil given that we are planning to transition the field-date picker from the version in the Closure library to a simple <input type="date">: while the latter does support min, max and step attributes but does not have the ability to enumerate an arbitrary set of dates that can be picked.

cpcallen avatar Jan 30 '23 17:01 cpcallen

@cpcallen so as you said it's not possible to do this kind of date selection with Blockly? I think the only way I to do it is to create an extension for the block and a custom field type isn't? It's a pity, but thank you very much.

samYnsat avatar Feb 07 '23 10:02 samYnsat

@samYnsat :

so as you said it's not possible to do this kind of date selection with Blockly? I think the only way I to do it is to create an extension for the block and a custom field type isn't? It's a pity, but thank you very much.

Yes: you'd need to create your own FieldDate implementation (perhaps as a subclass of the existing one), and either hack up the Closure date picker or write/find a new date picker.

cpcallen avatar Feb 07 '23 10:02 cpcallen