• R/O
  • SSH
  • HTTPS

shibuya-trac: Commit


Commit MetaInfo

Revision847 (tree)
Time2014-08-23 18:39:24
Authorjun66j5

Log Message

GanttCalendarPlugin: allow sorting with any field in gantt chart (sf.jp #34214)

Change Summary

Incremental Difference

--- plugins/ganttcalendarplugin/trunk/ganttcalendar/ticketgantt.py (revision 846)
+++ plugins/ganttcalendarplugin/trunk/ganttcalendar/ticketgantt.py (revision 847)
@@ -189,7 +189,7 @@
189189 req.perm.require('TICKET_VIEW')
190190
191191 tktsys = TicketSystem(self.env)
192- fields = tktsys.fields
192+ fields = tktsys.get_ticket_fields()
193193
194194 year = req.args.get('year')
195195 month = req.args.get('month')
@@ -491,6 +491,14 @@
491491 if clauses:
492492 condition += " AND (%s)" % (" OR ".join('(%s)' % c for c in clauses))
493493
494+ if sorted_field not in ('due_assign', 'due_close', 'complete',
495+ 'estimatedhours', 'totalhours') and \
496+ any(f['name'] == sorted_field and f['custom'] for f in fields):
497+ sort_expr = "(SELECT tc.value FROM ticket_custom tc " \
498+ "WHERE tc.ticket=t.id AND name=%s LIMIT 1)"
499+ args.append(sorted_field)
500+ else:
501+ sort_expr = sorted_field
494502 sql = """\
495503 SELECT id, type, summary, owner, t.description, status, resolution,
496504 priority, a.value AS due_assign, c.value AS due_close,
@@ -502,7 +510,7 @@
502510 JOIN ticket_custom cmp ON cmp.ticket=t.id AND cmp.name='complete'
503511 LEFT OUTER JOIN ticket_custom est ON est.ticket=t.id AND est.name='estimatedhours'
504512 LEFT OUTER JOIN ticket_custom tot ON tot.ticket=t.id AND tot.name='totalhours'
505- %s %s ORDER BY %s, a.value""" % (custom_join, condition, sorted_field)
513+ %s %s ORDER BY %s, a.value""" % (custom_join, condition, sort_expr)
506514
507515 if not errors:
508516 cursor.execute(sql, args)
--- plugins/ganttcalendarplugin/trunk/ganttcalendar/templates/ganttcalendar_gantt.html (revision 846)
+++ plugins/ganttcalendarplugin/trunk/ganttcalendar/templates/ganttcalendar_gantt.html (revision 847)
@@ -206,9 +206,10 @@
206206 <td>
207207 <label>
208208 ${_('Sort by')}
209- <select name="sorted_field" style="font-size:100%">
210- <option value="milestone" selected="${sorted_field=='milestone' or None}">${_('Milestone')}</option>
211- <option value="component" selected="${sorted_field=='component' or None}">${_('Component')}</option>
209+ <select name="sorted_field">
210+ <option py:for="name in field_names" py:with="f = fields[name]"
211+ value="${f.name}"
212+ selected="${sorted_field == f.name and 'selected' or None}">${f.label}</option>
212213 </select>
213214 </label><br/>
214215 </td>
Show on old repository browser