WordPress.org

Making WordPress.org

Changeset 309


Ignore:
Timestamp:
01/24/2014 04:21:04 AM (6 years ago)
Author:
nacin
Message:

Trac: Explicitly sort fields on the ticket screen.

This positioning is necessary for rendering the focus field. But this also results in some good pairings. Milestone and priority are on the same row (and both are disabled for non-gardeners). Priority and severity are adjacent. So are focuses and components, and focuses and keywords.

see #287.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site.html

    r308 r309  
    3333    except (IndexError, KeyError):
    3434        pass
     35
     36    field_types = [ 'milestone', 'priority', 'type', 'severity', 'version', 'component', 'keywords', 'focuses', ]
     37
     38    # Sorting function
     39    def sort_nicely(field1, field2):
     40        try:
     41            idx1 = field_types.index(field1['name'])
     42        except ValueError:
     43            idx1 = 1000 # no match, push to the end
     44
     45        try:
     46            idx2 = field_types.index(field2['name'])
     47        except ValueError:
     48            idx2 = 1000 # no match, push to the end
     49
     50        return cmp(idx1, idx2)
     51
     52    if ticket and 'fields' in locals():
     53        # Sort the fields
     54        fields.sort(cmp=sort_nicely)
     55
     56        # Re-generate fields_map for use within the ticket template
     57        fields_map = {}
     58        for i in xrange(0, len(fields)):
     59            fields_map[ fields[i]['name'] ] = i
    3560?>
    3661
Note: See TracChangeset for help on using the changeset viewer.