Modify

Opened 12 years ago

Closed 12 years ago

#10496 closed defect (fixed)

js bug in adding status columns

Reported by: gary.martin@… Owned by: Jun Omae
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 12 years ago by Jun Omae

Status: newassigned

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 12 years ago by Jun Omae

Trac Release: 0.121.0

comment:3 Changed 12 years ago by Jun Omae

Resolution: fixed
Status: assignedclosed

Applied in [12214].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.