Commits

Peter Suter committed 755d5c7

Add datetimepicker.patch that activates jQuery UI date/time picker control for custom time fields in ticket view.

Comments (0)

Files changed (2)

datetimepicker.patch

+# HG changeset patch
+# Parent 7c09c0515dd9cc53b7e730bcca5b7703e4c484e6
+Use jQuery datetime picker for custom time fields.
+
+diff -r 7c09c0515dd9 trac/ticket/templates/ticket.html
+--- a/trac/ticket/templates/ticket.html	Thu Mar 01 23:32:30 2012 +0100
++++ b/trac/ticket/templates/ticket.html	Fri Mar 02 00:33:00 2012 +0100
+@@ -13,11 +13,13 @@
+       <py:when test="ticket.exists">#${ticket.id} (${ticket.summary})</py:when>
+       <py:otherwise>New Ticket</py:otherwise>
+     </title>
+-    <script type="text/javascript" src="${chrome.htdocs_location}js/threaded_comments.js"></script>
++    <script py:if="ticket.exists" type="text/javascript" src="${chrome.htdocs_location}js/threaded_comments.js"></script>
+     <script type="text/javascript" py:choose="">
+       jQuery(document).ready(function($) {
+         $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
+         $(".foldable").enableFolding(false, true);
++        $(".datepicker").datepicker();
++        $(".datetimepicker").datetimepicker();
+       <py:when test="ticket.exists">/*<![CDATA[*/
+         $("#modify").parent().toggleClass("collapsed");
+         $(".trac-topnav a").click(function() { $("#modify").parent().removeClass("collapsed"); });
+@@ -278,7 +280,7 @@
+                           ${option}
+                         </label>
+                         <input py:when="'time'" type="text" id="field-${field.name}" title="${field.format_hint}"
+-                               name="field_${field.name}" value="${field.edit}" />
++                               name="field_${field.name}" value="${field.edit}" class="${field.date_or_datetime}picker" />
+                         <py:otherwise><!--! Text input fields -->
+                           <py:choose>
+                             <span py:when="field.cc_entry"><!--! Special case for Cc: field -->
+diff -r 7c09c0515dd9 trac/ticket/web_ui.py
+--- a/trac/ticket/web_ui.py	Thu Mar 01 23:32:30 2012 +0100
++++ b/trac/ticket/web_ui.py	Fri Mar 02 00:33:00 2012 +0100
+@@ -451,6 +451,7 @@
+         add_script(req, 'common/js/folding.js')
+         Chrome(self.env).add_wiki_toolbars(req)
+         Chrome(self.env).add_auto_preview(req)
++        Chrome(self.env).add_jquery_ui(req)
+         return 'ticket.html', data, None
+ 
+     def _process_ticket_request(self, req):
+@@ -641,6 +642,7 @@
+         add_script(req, 'common/js/folding.js')
+         Chrome(self.env).add_wiki_toolbars(req)
+         Chrome(self.env).add_auto_preview(req)
++        Chrome(self.env).add_jquery_ui(req)
+ 
+         # Add registered converters
+         for conversion in mime.get_supported_conversions('trac.ticket.Ticket'):
+@@ -1477,6 +1479,7 @@
+             elif type_ == 'time':
+                 value = ticket[name]
+                 format = field.get('format', 'datetime')
++                field['date_or_datetime'] = format
+                 field['rendered'] = pretty_format_time(req, value, format,
+                                                             relative=True)
+                 field['edit'] = pretty_format_time(req, value, format)
 TicketFieldList.patch
 customtimefields.patch
 ct-tests.patch
+datetimepicker.patch