Ticket #2363: t2363_cf-order_011.diff

File t2363_cf-order_011.diff, 2.8 kB (added by osimons, 5 months ago)

Patch to fix generating and editing custom field order.

  • 0.11/customfieldadmin/api.py

    old new  
    9494        if create: 
    9595            last = len(self.get_custom_fields(env)) 
    9696            env.config.set('ticket-custom', customfield['name'] + '.order', 
    97                     customfield.get('order',0) or last
     97                    customfield.get('order',0) or last-1
    9898        elif customfield.has_key('order') and customfield['order']: 
    9999            # Exists and have value - note: will not update order conflicting with other fields 
    100100            if str(customfield['order']).isdigit(): 
  • 0.11/customfieldadmin/customfieldadmin.py

    old new  
    8989                                  in req.args.keys() 
    9090                                  if key.startswith('order_')]) 
    9191                    values = dict([(val, True) for val in order.values()]) 
    92                     if len(order) != len(values): 
    93                         raise TracError, 'Order numbers must be unique.' 
     92                    # Disabled testing for uniqueness of order field 
     93                    # if len(order) != len(values): 
     94                    #     raise TracError, 'Order numbers must be unique.' 
    9495                    cf = cfapi.get_custom_fields(self.env) 
    9596                    for cur_cf in cf: 
    9697                        cur_cf['order'] = order[cur_cf['name']] 
  • 0.11/customfieldadmin/templates/customfieldadmin.html

    old new  
    138138              <td>${cf.type}</td> 
    139139              <td>${cf.label}</td> 
    140140              <td class="default"> 
    141                 <select name="order_${cf.name}"
    142                   <option py:for="other in cfadmin.customfields
    143                       selected="${other.order==cf.order and 'selected' or None}"> 
    144                       ${other.order
     141                <select name="order_${cf.name}" py:with="count = len(cfadmin.customfields)"
     142                  <option py:for="num in range(count)
     143                      selected="${num==cf.order and 'selected' or None}"> 
     144                      ${num
    145145                  </option> 
     146                  <!--! Extra option in case value is outside regular range --> 
     147                  <option py:if="cf.order not in range(count)" 
     148                      selected="selected">${cf.order}</option> 
    146149                </select> 
    147150              </td> 
    148151            </tr>