On Tuesday, November 15, 2016 at 4:38:32 AM UTC-8, Mo wrote: > > Hi, I'm also looking for a way to define a custom order for non-custom > ticket fields and custom ticket fields. > > As for the custom there is this possibility: > > project = select > project.order = 5 > > But there is no way to define that for internal fields such as type and > priority. It would be nice to set the internals in [ticket-custom] as well > by defining the order only. > There was already a request like this before: > https://trac-hacks.org/ticket/2642#comment:11 > <https://www.google.com/url?q=https%3A%2F%2Ftrac-hacks.org%2Fticket%2F2642%23comment%3A11&sa=D&sntz=1&usg=AFQjCNF29eRY5xFytbPCyL11ccS-GkGvBA> > > Is redefining the CS template the only way? Which template define the > ticket fields? > > br, Mo >
This thread is pretty old and the CS template refers to the pre-0.11 version of Trac that used ClearSilver. Trac doesn't currently support re-ordering the standard ticket fields. The feature has been requested in #4549 and I would agree that this is something we should address in the near future. https://trac.edgewall.org/ticket/4549 For now, I've written a plugin that will allow you to re-order the ticket fields, subject to a few restrictions. See attached TicketFieldOrderer.py. The visible fields in the Ticket Properties box can be reordered, excepted "Reported by" and "Owned by". You'll have the change the ticket_box.html template to change the position of those fields. The visible fields in the Change Properties box can be reordered. The plugin implements IRequestFilter, so it can override ordering of ticket custom fields defined in Trac.ini. I haven't tested, but I think it will preserve ordering of custom fields as defined in Trac.ini provided you don't list any of those fields in [ticket] field_order. - Ryan -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*- # # Copyright (C) 2016 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://trac.edgewall.org/wiki/TracLicense. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://trac.edgewall.org/log/. from trac.core import Component, implements from trac.config import ListOption from trac.web.api import IRequestFilter class TicketFieldOrderer(Component): implements(IRequestFilter) field_order = ListOption('ticket', 'field_order', doc="Ticket field order.") def __init__(self): self._fields = None def pre_process_request(self, req, handler): return handler def post_process_request(self, req, template, data, content_type): if template == 'ticket.html' and self.field_order: if self._fields is None: self._fields = data['fields'] def index_of(f): name = f['name'] return self.field_order.index(name) \ if name in self.field_order \ else len(self.field_order) self._fields.sort(cmp=lambda x, y: cmp(index_of(x), index_of(y))) data['fields'] = self._fields return template, data, content_type
