Extend TMS WEB Core with JS Libraries with Andrew: FlatPickr
So far in this blog series, we’ve covered JS libraries that included Helpers, Tools, and Assets. This time out, we’re going to dig into the first of many JS libraries that feature some sort of Control – a component or widget or element of some kind that can extend your TMS WEB Core project beyond what the standard components offer. Our first control describes itself as “a lightweight and powerful datetime picker” and indeed it is! It’s called FlatPickr and in this first part, we’ll cover how to get it up and running in your TMS WEB Core projects, with a few examples to show off its key features. In part two, we’ll take a different approach by creating a TFlatPickr component that can then be added to the Delphi IDE Palette, making it even easier to use in your projects. Motivation TMS WEB Core comes with a datetime picker of course, the TWebDateTimePicker component. And if you’re a fan of FNC components, there are the TTMSFNCDatePicker and TTMSFNCDateTimePicker components. And if you’re hunting around the Delphi IDE Palette, you’ll also run across a jQuery-based component called TWebJQXDateTimeInput. So plenty of options right off the bat. But it would be hard to think of another class of component where people (like me!) have very strongly-held opinions on how they should look and work, and what kinds of options they absolutely need to have. And that’s before we even get to the whole epic tale of date and time formats, something we’ll also be covering very shortly when we get to Luxon. Also, datetime pickers hide away a surprising amount of complexity for something that, on the surface, appears to be very simple. When it comes to choosing a datetime picker, here are some of the considerations that I have in mind. I would consider these to be “minimum requirements” rather than “nice-to-haves” for my projects. Your projects may have an entirely different set of priorities of course. What is perhaps most important is that the same datetime picker component is used throughout a project, where possible. Week Numbers. I work with many clients from the agriculture industry where week numbers are used all the time, probably more often than dates, in fact. Variations. Sometimes it makes sense to display a full month calendar on the page. Maybe even two months. Sometimes it is a drop-down. Sometimes there’s also a time. Sometimes there’s only a time. Being able to use the same control in different variations helps with providing a consistent user experience and results in fewer headaches as a developer. Restrictions. Having a start/end range for selectable dates is important, but it is often necessary to be able to provide a list of available dates to the component, and for the component to make it clear to the user which dates are available to be selected. Selections. The flexibility to be able to select an individual date, multiple dates, or a range is important, but making it simple is just as important. Themes. The component has to fit in visually with the rest of the project. My projects typically use CSS for theme work, so bonus points if it can be themed easily with CSS. But at the very list it should provide some options for the ubiquitous light and […]
