Modify

#10496 closed defect (fixed)

js bug in adding status columns

Reported by: gary.martin@… Owned by: jun66j5
Priority: normal Component: TracWorkflowAdminPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

I was wondering why the limit on the number of statuses was so low when I spotted that it was probably a bug due to the differences in the way that javascript deals with + and - operators with strings.

This appears to be a possible solution:

  • tracworkflowadmin/htdocs/scripts/main.js

     
    657657                var colspan = $('#status-header-bar').attr('colspan'); 
    658658                var statusName = $('#new-status-input-dialog input').val(); 
    659659                if (!statusName) return false; 
    660                 $('#status-header-bar').attr('colspan', colspan + 1); 
     660                $('#status-header-bar').attr('colspan', parseInt(colspan) + 1); 
    661661                var el = $($('#status-editor-1 th')[0]).clone(true); 
    662662                $('input', el).val(statusName); 
    663663                $('span:first', el).text(statusName); 

Attachments (0)

Change History (3)

comment:1 Changed 22 months ago by jun66j5

  • Status changed from new to assigned

I just confirmed. You're right.

$(selector).attr('colspan') returns a number on Trac 0.12.x with jQuery 1.4.x. However, it returns a string on Trac 1.0 with jQuery 1.7.2.

I'll apply the following patch later. Thanks!

  • tracworkflowadmin/htdocs/scripts/main.js

     
    603603    // ステータスの削除 
    604604    $('#elements .del-status').click(function() { 
    605605        var colspan = $('#status-header-bar').attr('colspan'); 
     606        colspan = parseInt(colspan || '1', 10); 
    606607        var c = 0; 
    607608        var rowNo = -1; 
    608609        var thisEl = $(this).parent().get()[0]; 
     
    655656            'Ok': function(){ 
    656657                $('#new-status-input-dialog').dialog('close'); 
    657658                var colspan = $('#status-header-bar').attr('colspan'); 
     659                colspan = parseInt(colspan || '1', 10); 
    658660                var statusName = $('#new-status-input-dialog input').val(); 
    659661                if (!statusName) return false; 
    660662                $('#status-header-bar').attr('colspan', colspan + 1); 
     
    686688 
    687689    $('#elements #add-status').click(function() { 
    688690        var colspan = $('#status-header-bar').attr('colspan'); 
     691        colspan = parseInt(colspan || '1', 10); 
    689692        if (colspan >= 30) { 
    690693            alert(_("Too many statuses. Please remove unnecessary statuses.")); 
    691694            return false; 

comment:2 Changed 22 months ago by jun66j5

  • Trac Release changed from 0.12 to 1.0

comment:3 Changed 22 months ago by jun66j5

  • Resolution set to fixed
  • Status changed from assigned to closed

Applied in [12214].

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from jun66j5. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.