#11413 closed defect (fixed)
Difficult to edit directly text field with date/time picker
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | general | Version: | 1.0.1 |
Severity: | normal | Keywords: | datepicker, jqueryui |
Cc: | Branch: | ||
Release Notes: |
Prevent moving the cursor to end of field with datetime picker when editing hours part. |
||
API Changes: | |||
Internal Changes: |
Description
The date/time picker on Trac has some issues. It is difficult to edit directly caused by the following issue.
- Restore immediately the value after removing end of the text field with backspace key
- Move the cursor to end of the text field after removing hours part
- Fill the text field with today after focusing even if it's empty
See https://groups.google.com/d/msg/trac-users/1Xi8cz-m1KY/7E8ZgU6WjKgJ.
Attachments (0)
Change History (8)
follow-up: 5 comment:1 by , 11 years ago
comment:2 by , 11 years ago
Milestone: | next-stable-1.0.x → 1.0.2 |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | new → closed |
comment:3 by , 11 years ago
Owner: | set to |
---|---|
Release Notes: | modified (diff) |
comment:4 by , 11 years ago
Keywords: | jqueryui added |
---|
comment:5 by , 9 years ago
comment:6 by , 9 years ago
Hmmm. It seems the spec of timezoneList
option has been changed and Z
in format has been added. However, this patch still doesn't fix the difficulty of direct editing when selected format is iso8601.
-
trac/util/datefmt.py
diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py index ef771174f..1b16439f5 100644
a b def get_date_format_jquery_ui(locale): 353 353 def get_time_format_jquery_ui(locale): 354 354 """Get the time format for the jQuery UI timepicker addon.""" 355 355 if locale == 'iso8601': 356 return 'HH:mm:ss z' # XXX timepicker doesn't support 'ISO_8601'356 return 'HH:mm:ssZ' 357 357 if babel and locale: 358 358 values = {'h': 'h', 'hh': 'hh', 'H': 'H', 'HH': 'HH', 359 359 'm': 'm', 'mm': 'mm', 's': 's', 'ss': 'ss'} … … def get_time_format_jquery_ui(locale): 374 374 375 375 def get_timezone_list_jquery_ui(t=None): 376 376 """Get timezone list for jQuery timepicker addon""" 377 def utcoffset(tz, t): # in minutes 378 offset = t.astimezone(get_timezone(tz)).utcoffset() 379 return offset.days * 24 * 60 + offset.seconds // 60 380 def label(offset): 381 if offset == 0: 382 return 'Z' 383 if offset < 0: 384 offset = -offset 385 sign = '-' 386 else: 387 sign = '+' 388 return '%s%02d:%02d' % (sign, offset // 60, offset % 60) 377 389 t = datetime.now(utc) if t is None else utc.localize(t) 378 zones = set(t.astimezone(get_timezone(tz)).strftime('%z') 379 for tz in all_timezones) 380 return [{'value': 'Z', 'label': '+00:00'} \ 381 if zone == '+0000' else zone[:-2] + ':' + zone[-2:] 382 for zone in sorted(zones, key=lambda tz: int(tz))] 390 offsets = set(utcoffset(tz, t) for tz in all_timezones) 391 return [{'value': offset, 'label': label(offset)} 392 for offset in sorted(offsets)] 383 393 384 394 def get_first_week_day_jquery_ui(req): 385 395 """Get first week day for jQuery date picker""" -
trac/web/chrome.py
diff --git a/trac/web/chrome.py b/trac/web/chrome.py index f5a7f0e8a..ac1731702 100644
a b class Chrome(Component): 1379 1379 # default timezone must be included 1380 1380 'timezone_list': get_timezone_list_jquery_ui() 1381 1381 if is_iso8601 1382 else [{'value': 'Z', 'label': '+00:00'}],1382 else [{'value': 0, 'label': 'Z'}], 1383 1383 'timezone_iso8601': is_iso8601, 1384 1384 }) 1385 1385 add_script(req, 'common/js/jquery-ui-i18n.js')
comment:8 by , 9 years ago
I hadn't noticed the issue with the timezone list being incorrect, displaying [object Object]
for the utc entry. The patch seems to provide a minor improvement for editing the timepicker even for ISO8601 format. After the patch the cursor only moves to the end of the line when editing the timezone or entering an out-of-range value, such as 90
for the seconds field. Previously it would move the cursor to the end of the line on any edit. I made a new ticket for the issue: #12220.
I've tried the latest of jquery-ui-addons.js, v1.4.3. But it isn't fixed.
I investigated it and noticed that timezone list must have default timezone even if the timezone is not used. The default timezone is at tags/trac-1.0.1/trac/htdocs/js/jquery-ui-i18n.js@:42#L28.
trac/web/chrome.py
],The patch would fix the issues. However, even with the patch, the cursor is moved to end when invalid hours is typed.