Edgewall Software
Modify

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12702 closed defect (worksforme)

Ticket query Columns checkboxes are reordered

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone:
Component: query system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

To reproduce:

  1. Go to ticket query page and view the columns.

  1. Add Keywords to query filters.
  2. Update and view columns again.

Is there a reason I should expect the Columns checkboxes to reorder?

Attachments (2)

Screen Shot 2017-02-24 at 10.37.25.png (43.4 KB ) - added by Ryan J Ollos 10 years ago.
Screen Shot 2017-02-24 at 10.37.40.png (49.1 KB ) - added by Ryan J Ollos 10 years ago.

Download all attachments as: .zip

Change History (5)

by Ryan J Ollos, 10 years ago

by Ryan J Ollos, 10 years ago

comment:1 by Jun Omae, 10 years ago

This behavior is intentionally implemented in Query.get_all_column() at tags/trac-1.2/trac/ticket/query.py@:226-238#L217. We could simply rewrite the Query.get_all_column() like:

  • trac/ticket/query.py

    diff --git a/trac/ticket/query.py b/trac/ticket/query.py
    index 2a909b8e9..01fc6059b 100644
    a b class Query(object):  
    223223                cols.remove(col)
    224224                cols.append(col)
    225225
    226         def sort_columns(col1, col2):
    227             constrained_fields = self.constraint_cols.keys()
    228             if 'id' in (col1, col2):
    229                 # Ticket ID is always the first column
    230                 return -1 if col1 == 'id' else 1
    231             elif 'summary' in (col1, col2):
    232                 # Ticket summary is always the second column
    233                 return -1 if col1 == 'summary' else 1
    234             elif col1 in constrained_fields or col2 in constrained_fields:
    235                 # Constrained columns appear before other columns
    236                 return -1 if col1 in constrained_fields else 1
    237             return 0
    238         cols.sort(sort_columns)
     226        constrained_fields = set(self.constraint_cols)
     227        def sort_columns(name):
     228            if name == 'id':
     229                return 1  # Ticket ID is always the first column
     230            if name == 'summary':
     231                return 2  # Ticket summary is always the second column
     232            if name in constrained_fields:
     233                return 3  # Constrained columns appear before other columns
     234            return 4
     235        cols.sort(key=sort_columns)
    239236        return cols

comment:2 by Ryan J Ollos, 10 years ago

Milestone: next-stable-1.2.x1.2.1
Owner: set to Ryan J Ollos
Status: newassigned

Thanks, that change works well.

comment:3 by Ryan J Ollos, 10 years ago

Milestone: 1.2.1
Resolution: worksforme
Status: assignedclosed

I see we did a similar refactoring on the trunk in r15332.

Last edited 10 years ago by Jun Omae (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.