Ticket #10496 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

js bug in adding status columns

Reported by: gary.martin@wandisco.com Assigned to: 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:

Index: tracworkflowadmin/htdocs/scripts/main.js
===================================================================
--- tracworkflowadmin/htdocs/scripts/main.js	(revision 12188)
+++ tracworkflowadmin/htdocs/scripts/main.js	(working copy)
@@ -657,7 +657,7 @@
                 var colspan = $('#status-header-bar').attr('colspan');
                 var statusName = $('#new-status-input-dialog input').val();
                 if (!statusName) return false;
-                $('#status-header-bar').attr('colspan', colspan + 1);
+                $('#status-header-bar').attr('colspan', parseInt(colspan) + 1);
                 var el = $($('#status-editor-1 th')[0]).clone(true);
                 $('input', el).val(statusName);
                 $('span:first', el).text(statusName);

Attachments

Change History

10/18/12 13:23:28 changed 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!

Index: tracworkflowadmin/htdocs/scripts/main.js
===================================================================
--- tracworkflowadmin/htdocs/scripts/main.js    (revision 12193)
+++ tracworkflowadmin/htdocs/scripts/main.js    (working copy)
@@ -603,6 +603,7 @@
     // ステータスの削除
     $('#elements .del-status').click(function() {
         var colspan = $('#status-header-bar').attr('colspan');
+        colspan = parseInt(colspan || '1', 10);
         var c = 0;
         var rowNo = -1;
         var thisEl = $(this).parent().get()[0];
@@ -655,6 +656,7 @@
             'Ok': function(){
                 $('#new-status-input-dialog').dialog('close');
                 var colspan = $('#status-header-bar').attr('colspan');
+                colspan = parseInt(colspan || '1', 10);
                 var statusName = $('#new-status-input-dialog input').val();
                 if (!statusName) return false;
                 $('#status-header-bar').attr('colspan', colspan + 1);
@@ -686,6 +688,7 @@

     $('#elements #add-status').click(function() {
         var colspan = $('#status-header-bar').attr('colspan');
+        colspan = parseInt(colspan || '1', 10);
         if (colspan >= 30) {
             alert(_("Too many statuses. Please remove unnecessary statuses."));
             return false;

10/18/12 13:23:50 changed by jun66j5

  • release changed from 0.12 to 1.0.

10/19/12 04:21:03 changed by jun66j5

  • status changed from assigned to closed.
  • resolution set to fixed.

Applied in [12214].


Add/Change #10496 (js bug in adding status columns)




Change Properties
Action