Ticket #7026: query_column_reorder2_6737.3.diff
| File query_column_reorder2_6737.3.diff, 5.8 KB (added by ebray <hyugaricdeau@…>, 10 months ago) |
|---|
-
trac/ticket/query.py
41 41 INavigationContributor, Chrome 42 42 from trac.wiki.api import IWikiSyntaxProvider, parse_args 43 43 from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api 44 from trac.config import Option 44 from trac.config import Option 45 45 46 46 class QuerySyntaxError(Exception): 47 47 """Exception raised when a ticket query cannot be parsed from a string.""" … … 94 94 for filter_ in filters: 95 95 filter_ = filter_.split('=') 96 96 if len(filter_) != 2: 97 raise QuerySyntaxError('Query filter requires field and ' 97 raise QuerySyntaxError('Query filter requires field and ' 98 98 'constraints separated by a "="') 99 99 field,values = filter_ 100 100 if not field: … … 637 637 rows, 638 638 req.args.get('limit')) 639 639 640 if cols: 641 for idx, col in enumerate(cols): 642 if 'up_' + col in req.args: 643 query.cols[idx] = cols[idx-1] 644 query.cols[idx-1] = col 645 req.redirect(query.get_href(req.href)) 646 elif 'down_' + col in req.args: 647 query.cols[idx] = cols[idx+1] 648 query.cols[idx+1] = col 649 req.redirect(query.get_href(req.href)) 650 640 651 if 'update' in req.args: 641 652 # Reset session vars 642 653 for var in ('query_constraints', 'query_time', 'query_tickets'): … … 779 790 data.setdefault('description', None) 780 791 data['title'] = title 781 792 782 data['all_columns'] = query.get_all_columns() 793 all_columns = query.get_all_columns() 794 all_columns.sort(key=lambda x: (not x in query.cols, 795 x in query.cols and 796 query_cols.index(x))) 783 797 # Don't allow the user to remove the id column 784 data['all_columns'].remove('id') 798 all_columns.remove('id') 799 data['all_columns'] = all_columns 785 800 data['all_textareas'] = query.get_all_textareas() 786 801 787 802 add_stylesheet(req, 'common/css/report.css') -
trac/ticket/templates/query.html
136 136 <fieldset id="columns"> 137 137 <legend>Columns</legend> 138 138 <div> 139 <py:for each="column in all_columns"> 140 <label> 141 <input type="checkbox" name="col" value="$column" 142 checked="${any([(value == column) for value in col]) 143 and 'checked' or None}" /> 144 ${labels.get(column, column or 'none')} 145 </label> 146 </py:for> 139 <table> 140 <tbody> 141 <tr py:for="idx, column in enumerate(all_columns)"> 142 <td> 143 <input type="checkbox" name="col" value="$column" 144 checked="${any([(value == column) for value in col]) 145 and 'selected' or None}" /> 146 </td> 147 <td>${labels.get(column, column or 'none')}</td> 148 <td> 149 <input type="submit" name="up_${column}" value="Up" 150 disabled="${not idx or None}" /> 151 <input type="submit" name="down_${column}" value="Down" 152 disabled="${idx == len(all_columns)-1 or None}" /> 153 </td> 154 </tr> 155 </tbody> 156 </table> 147 157 </div> 148 158 </fieldset> 149 159 -
trac/htdocs/js/query.js
273 273 } 274 274 select.selectedIndex = 0; 275 275 } 276 277 $("input[@name^='up_']").click(function() { 278 var row = $(this).parents('tr'); 279 if (row.prev().length) { 280 var prev = row.prev(); 281 if (!row.next().length) { 282 prev.find("input[@name^='down_']").attr("disabled", true); 283 } 284 prev.find("input[@name^='up_']").attr("disabled", false); 285 row.insertBefore(row.prev()); 286 if (!row.prev().length) { 287 $(this).attr("disabled", true); 288 } 289 row.find("input[@name^='down_']").attr("disabled", false); 290 } 291 return false; 292 }); 293 $("input[@name^='down_']").click(function() { 294 var row = $(this).parents('tr'); 295 if (row.next().length) { 296 var next = row.next(); 297 if (!row.prev().length) { 298 next.find("input[@name^='up_']").attr("disabled", true); 299 } 300 next.find("input[@name^='down_']").attr("disabled", false); 301 row.insertAfter(row.next()); 302 if (!row.next().length) { 303 $(this).attr("disabled", true); 304 } 305 row.find("input[@name^='up_']").attr("disabled", false); 306 } 307 return false; 308 }); 276 309 } 277 278 })(jQuery); 279 No newline at end of file 310 })(jQuery); -
trac/htdocs/css/report.css
41 41 #filters td.filter label { padding-right: 1em } 42 42 #filters td.actions { text-align: right; white-space: nowrap } 43 43 44 #columns div { 45 height: 15em; 46 overflow: -moz-scrollbars-vertical; 47 overflow-x: hidden; 48 overflow-y: scroll; 49 } 50 44 51 #columns div label { 45 52 display: block; 46 53 float: left;
