alternate date/time widgets?

372 views
Skip to first unread message

..mg..

unread,
Mar 25, 2016, 1:17:18 PM3/25/16
to web...@googlegroups.com
I'm looking to replace the date and time widgets that ship with web2py.
My dream widget would use dropdowns (or similar) for
month/day/hour/minute, but store values as datetime objects (like native
web2py).

Does anyone have experience or recommendations with this?

Thanks,

-mg

Massimo Di Pierro

unread,
Mar 25, 2016, 7:09:03 PM3/25/16
to web2py-users, shoe...@riseup.net
I made these


Still beta but the calendar one is there to stay. I will be come default in web2py in the next version.

shoe...@riseup.net

unread,
Mar 28, 2016, 6:51:46 PM3/28/16
to web...@googlegroups.com

Thanks -- I like the way these look. -mg

Massimo Di Pierro

unread,
Mar 29, 2016, 12:10:12 AM3/29/16
to web2py-users, shoe...@riseup.net
I need to merge the autocomplete with tags and than we are done. Please help us test them.

Ron Chatterjee

unread,
Mar 29, 2016, 12:52:38 AM3/29/16
to web2py-users
If we dont use stupid css wondering what will b the equivalent autocomplete with dismissal tags can b (for search).

Massimo Di Pierro

unread,
Mar 29, 2016, 5:25:11 PM3/29/16
to web2py-users
You do not have to use stupid css to use the tags widget. But you will need to write some CSS to make it look the way you want.

..mg..

unread,
Mar 29, 2016, 8:32:40 PM3/29/16
to web...@googlegroups.com
Is there an easy way to get just the widgets? I have stupid.css, and
I should have some time Thursday to play with it.

-mg
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Massimo Di Pierro

unread,
Apr 2, 2016, 1:44:20 PM4/2/16
to web2py-users, shoe...@riseup.net
Eventually I will move them to a different repo. The js do not depend on any css.
> To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

shoe...@riseup.net

unread,
Apr 5, 2016, 3:31:41 PM4/5/16
to web...@googlegroups.com
Working on integrating the new date and time pickers with my code,
thoughts:

* I added sugar.js and widgets.js and removed all of the existing JS.
The calendar locked up those plus the existing JS: I wasn't using
(AFAIK) any of the existing JS, and it wasn't clear what parts were in
what files, so I stopped including them.

* The background color for the picker is set in the element, overriding
my CSS -- I have to use !important, which seems less than ideal.

* My form (created by SQLFORM) has separate date and time fields, with
.date and .time classes by web2py (no data-format): I get a full
datetime picker for both.

* The time picker uses 12 hour time with no AM/PM by default

* I'm getting an error from inside widgets.min.js: self.attr(...) is
undefined on line 28

* getting 'data-format' in my SQLFORM fields was harder than it should
have been. I ended up needing:

db.cal_event.starttime.widget = lambda field, value:
SQLFORM.widgets.time.widget(
field, value, **{'_data-format': "{HH}:{MM} {TT}"})

* is there a way to get the date picker to go away when I click on a
day?
I have to click out of the calendar and not in another input item to
make it hide? I love that TAB still takes me to the next field, but it
would be great if I could use arrow keys to navigate -- I still have to
switch from keyboard/mouse to move through the form.
>> an email to web2py+un...@googlegroups.com.

shoe...@riseup.net

unread,
Apr 5, 2016, 5:25:25 PM4/5/16
to web...@googlegroups.com
Continued below...
* is a non-minified widgets.js available?

* timepicker: the {h} time format (hour in 12-hour time, without zero
padding, like strftime's %i) is interpreted correctly for display, but
the .cal_wrapper table is empty (no data at all)

* datepicker: puts a time of 12:00:00 placed in the input value,
preventing web2py from accepting the form. I have a JQuery .submit
snipping the time bit out for now

* timepicker: web2py requires 24 hour time representation. If I have a
default time
of "19:00", it gets displayed correctly in the form as "07:00PM", but on
submission the time in the record is AM. I'm using the same .submit to
clean this up too.

Thanks for writing these, hope the feedback is helpful.

-mg

shoe...@riseup.net

unread,
Apr 5, 2016, 5:45:54 PM4/5/16
to web...@googlegroups.com

It seems like the form input isn't holding any AM/PM information at all,
so I can't fix this up. Even on

http://mdipierro.github.io/stupid.css/widgets/index.html

enter in, say '11:12 PM', and inspect the form in debugger -- the form
value will only be '11:12', so that's what gets submitted.

-mg

Massimo Di Pierro

unread,
Apr 5, 2016, 5:59:31 PM4/5/16
to web2py-users, shoe...@riseup.net
thanks this helps me a lot. Will fix it this week.

shoe...@riseup.net

unread,
Apr 5, 2016, 9:06:18 PM4/5/16
to web...@googlegroups.com

On this issue:

>
> * timepicker: web2py requires 24 hour time representation. If I have
> a default time
> of "19:00", it gets displayed correctly in the form as "07:00PM", but
> on submission the time in the record is AM.


I found these two lines:

var ISO = '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss}';
if (self.hasClass('time')) ISO = '{hh}:{mm}:{ss}';

Changing to HH:

var ISO = '{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}';
if (self.hasClass('time')) ISO = '{HH}:{mm}:{ss}';


seems to fix this problem.


And with that, my forms work and I get to go home!

Best,

-mg
Reply all
Reply to author
Forward
0 new messages