Commits

Peter Suter committed 9e0a436

Activate date/time picker also in query view.

  • Participants
  • Parent commits 755d5c7

Comments (0)

Files changed (1)

File datetimepicker.patch

 # Parent 7c09c0515dd9cc53b7e730bcca5b7703e4c484e6
 Use jQuery datetime picker for custom time fields.
 
+diff -r 7c09c0515dd9 trac/htdocs/js/query.js
+--- a/trac/htdocs/js/query.js	Thu Mar 01 23:32:30 2012 +0100
++++ b/trac/htdocs/js/query.js	Fri Mar 02 09:41:39 2012 +0100
+@@ -179,11 +179,19 @@
+             .append(createRadio(propertyName, "0", propertyName + "_off"))
+             .append(" ").append(createLabel(_("no"), propertyName + "_off"));
+         } else if (property.type == "time") {
+-          focusElement = createText(propertyName, 14)
++          var endElement = createText(propertyName + "_end", 14);
++          focusElement = createText(propertyName, 14);
++          if (property.format == "datetime") {
++            focusElement.datetimepicker();
++            endElement.datetimepicker();
++          } else if (property.format == "date") {
++            focusElement.datepicker();
++            endElement.datepicker();
++          }
+           td.append(createLabel(_("between"))).append(" ")
+             .append(focusElement).append(" ")
+             .append(createLabel(_("and"))).append(" ")
+-            .append(createText(propertyName + "_end", 14));
++            .append(endElement);
+         }
+         tr.append(td);
+       } else {
+diff -r 7c09c0515dd9 trac/ticket/query.py
+--- a/trac/ticket/query.py	Thu Mar 01 23:32:30 2012 +0100
++++ b/trac/ticket/query.py	Fri Mar 02 09:41:39 2012 +0100
+@@ -1107,13 +1107,14 @@
+ 
+         properties = dict((name, dict((key, field[key])
+                                       for key in ('type', 'label', 'options',
+-                                                  'optgroups')
++                                                  'optgroups', 'format')
+                                       if key in field))
+                           for name, field in data['fields'].iteritems())
+         add_script_data(req, properties=properties, modes=data['modes'])
+ 
+         add_stylesheet(req, 'common/css/report.css')
+         add_script(req, 'common/js/query.js')
++        Chrome(self.env).add_jquery_ui(req)
+ 
+         return 'query.html', data, None
+ 
+diff -r 7c09c0515dd9 trac/ticket/templates/query.html
+--- a/trac/ticket/templates/query.html	Thu Mar 01 23:32:30 2012 +0100
++++ b/trac/ticket/templates/query.html	Fri Mar 02 09:41:39 2012 +0100
+@@ -21,6 +21,8 @@
+           $("#filters").toggleClass("collapsed");
+         /* Hide the columns by default. */
+         $("#columns").toggleClass("collapsed");
++        $(".datepicker").datepicker();
++        $(".datetimepicker").datetimepicker();
+       });
+     /*]]>*/</script>
+   </head>
+@@ -118,12 +120,13 @@
+                         
+                         <py:when test="field.type == 'time'"
+                                  py:with="(start, end) = '..' in constraint_value and constraint_value.split('..', 1)
+-                                                         or (constraint_value, '')">
++                                                         or (constraint_value, '');
++                                          date_or_datetime = field.get('format', 'datetime')">
+                           <i18n:msg>
+                             <label>between</label>
+-                            <input type="text" name="${n_field_name}" value="$start" size="14" />
++                            <input type="text" name="${n_field_name}" value="$start" size="14" class="${date_or_datetime}picker" />
+                             <label>and</label>
+-                            <input type="text" name="${n_field_name}_end" value="$end" size="14" />
++                            <input type="text" name="${n_field_name}_end" value="$end" size="14" class="${date_or_datetime}picker" />
+                           </i18n:msg>
+                         </py:when>
+                       </td>
 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
++++ b/trac/ticket/templates/ticket.html	Fri Mar 02 09:41:39 2012 +0100
 @@ -13,11 +13,13 @@
        <py:when test="ticket.exists">#${ticket.id} (${ticket.summary})</py:when>
        <py:otherwise>New Ticket</py:otherwise>
                              <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
++++ b/trac/ticket/web_ui.py	Fri Mar 02 09:41:39 2012 +0100
 @@ -451,6 +451,7 @@
          add_script(req, 'common/js/folding.js')
          Chrome(self.env).add_wiki_toolbars(req)