id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
4549,Enable HoursInPlaceEditor functionality for reports,Jason Winnebeck,Joachim Hoessler,"Enable the HoursInPlaceEditor to work with custom reports.
The request handler only injects the javascript into the custom query pages. This is probably because the script, as is, doesn't work for report pages, for three reasons:
1. The column for the ticket numbers has class ""ticket"" whereas in query it has class ""id"". The class is ""ticket"" in reports regardless of whether or not the report's columnname is ""id"" or ""ticket""
2. The HTML generated for the ticket column in the report module has a lot of extra whitespace added. The script assumes that the column's text is like ""#123"", with no spaces, and that all of the characters in the string after the first form a number.
3. The path to the xmlrpc is not correct when in a report page.
I fixed these three issues with the patch below. A disclaimer: I program Java, C#, C++, and a little Python out of necessity for Trac but I've never done JavaScript or JQuery, so there's probably better ways to do it. Also, a lot of whitespace changed so the changes below look like more than they are. Only the top portion of the script changed.
{{{
#!patch
Index: estimationtools/hoursinplaceeditor.py
===================================================================
--- estimationtools/hoursinplaceeditor.py (revision 5167)
+++ estimationtools/hoursinplaceeditor.py (working copy)
@@ -28,7 +28,7 @@
return handler
def post_process_request(self, req, template, data, content_type):
- if (req.path_info.startswith('/query')
+ if (req.path_info.startswith('/query') or req.path_info.startswith('/report')
and req.perm.has_permission('TICKET_MODIFY')
and req.perm.has_permission('XML_RPC')):
# add_script(req, 'estimationtools/jquery-1.2.3.min.js')
Index: estimationtools/templates/edithours.html
===================================================================
--- estimationtools/templates/edithours.html (revision 5167)
+++ estimationtools/templates/edithours.html (working copy)
@@ -2,39 +2,54 @@
xmlns:xi=""http://www.w3.org/2001/XInclude""
xmlns:py=""http://genshi.edgewall.org/"" py:strip="""">
$(document).ready(function() {
- ids = $('td.id').each(function(i) {
- var id = $(this).text().substr(1);
- var estimationField = '$data.field';
+ var reportMethod = $('td.ticket'); //used in Trac reports
+ var queryMethod = $('td.id'); //used in custom queries
- var estimationCell = $('td.' + estimationField).eq(i);
+ var xmlrpcPath = null;
+ var elements = null;
- estimationCell.editable(function(value, settings) {
- var currentElement = this;
- $.ajax({
- type: 'POST',
- url: 'xmlrpc',
- data: 'ticket.update' +
- '' + id + '' +
- '' +
- '' + estimationField + '' +
- '' + value + '' +
- '',
- contentType: 'text/xml',
- success: function(){
- $(currentElement).text(value);
+ if ( reportMethod.length != 0 ) {
+ elements = reportMethod;
+ xmlrpcPath = '../xmlrpc';
+ } else if ( queryMethod.length != 0 ) {
+ elements = queryMethod;
+ xmlrpcPath = 'xmlrpc';
+ }
+ if ( elements != null ) {
+ ids = elements.each(function(i) {
+ var id = jQuery.trim($(this).text()).substr(1);
+ var estimationField = '$data.field';
+
+ var estimationCell = $('td.' + estimationField).eq(i);
+
+ estimationCell.editable(function(value, settings) {
+ var currentElement = this;
+ $.ajax({
+ type: 'POST',
+ url: xmlrpcPath,
+ data: 'ticket.update' +
+ '' + id + '' +
+ '' +
+ '' + estimationField + '' +
+ '' + value + '' +
+ '',
+ contentType: 'text/xml',
+ success: function(){
+ $(currentElement).text(value);
}
});
return('Saving...');
}, {
- data : jQuery.trim(estimationCell.text()),
- tooltip : 'Click to edit...',
- placeholder: '',
- onblur : 'submit',
- select : 'true',
- style : 'inherit',
- width : 60
+ data : jQuery.trim(estimationCell.text()),
+ tooltip : 'Click to edit...',
+ placeholder: '',
+ onblur : 'submit',
+ select : 'true',
+ style : 'inherit',
+ width : 60
});
});
+ }
});
-
-
\ No newline at end of file
+
+
}}}
What I did is check to see whether we have ""td.ticket"" (for reports) or ""td.id"" fields (for query), then modify the behavior appropriately. I trimmed the ticket string so that the old ""substr(1)"" method will work regardless. If I knew how to do regular expressions in JavaScript, I would have done it that way. Also, I don't know if the closures that I used (using var xmlrpcPath in the calling code and the anonymous function) is safe/proper style.
I'm currently using this script in my 0.11.2 Trac, because we need to work with a report that is not possible with the ""custom query"" system.
This ticket is similar to a previously closed ticket I found, #4003.",enhancement,closed,normal,EstimationToolsPlugin,normal,fixed,,,0.11