Changeset 2460

Show
Ignore:
Timestamp:
07/12/07 10:25:15 (1 year ago)
Author:
bobbysmith007
Message:

TimingAndEstimationPlugin:

closes #1772

added javascript provided by Colin Guthrie that:

  • Changes the totalhours field to a non-editable span (no change).
  • Changes the estimated hours and total hours fields in the header table to be hours/minutes rather than a conceptually harder for humans decimal value!
  • Changes the billable flag in the header table to read Yes or No rather than 1 or 0.
  • Does the above two changes for all changelog entries through the ticket.

The only change I made to the javascript was to not emit any javascript into the global environment, instead add everything as local to a function that gets executed. Should keep the browser's namespace a bit cleaner for greasemonkey/other scripts and what not.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • timingandestimationplugin/branches/trac0.10/setup.py

    r2390 r2460  
    88      description='Plugin to make Trac support time estimation and tracking', 
    99      keywords='trac plugin estimation timetracking', 
    10       version='0.4.5', 
     10      version='0.4.6', 
    1111      url='http://www.trac-hacks.org/wiki/TimingAndEstimationPlugin', 
    1212      license='http://www.opensource.org/licenses/mit-license.php', 
     
    4747## trac-hacks user: coling 
    4848## Refactored the custom reports code to make it 
    49 ## easy for other plugins to provide reports to 
    50 ## compliment those provided by default 
     49##  easy for other plugins to provide reports to 
     50##  compliment those provided by default 
     51## Added Javascript that improves Ticket UI 
    5152 
  • timingandestimationplugin/branches/trac0.10/timingandestimationplugin/reports.py

    r2390 r2460  
    99    "uuid":"b24f08c0-d41f-4c63-93a5-25e18a8513c2", 
    1010    "title":"Ticket Work Summary", 
    11     "reportnumber":None, 
    1211    "version":14, 
    1312    "sql":""" 
     
    5150    "uuid":"af13564f-0e36-4a17-96c0-632dc68d8d14", 
    5251    "title":"Milestone Work Summary", 
    53     "reportnumber":None, 
    5452    "version":13, 
    5553    "sql":""" 
     
    9997    "uuid":"7bd4b0ce-da6d-4b11-8be3-07e65b540d99", 
    10098    "title":"Developer Work Summary", 
    101     "reportnumber":None, 
    10299    "version":13, 
    103100    "sql":""" 
     
    141138    "uuid":"8d785cdb-dcf5-43c9-b2a6-216997b0011a", 
    142139    "title": "Ticket Hours", 
    143     "reportnumber": None, 
    144140    "version":10, 
    145141    "sql": """ 
     
    211207    "uuid":"71e7c36d-e512-4d0b-b499-087d4d20ff0b", 
    212208    "title": "Ticket Hours with Description", 
    213     "reportnumber": None, 
    214209    "version":11, 
    215210    "sql": """ 
     
    290285    "uuid":"5f33b102-e6a6-47e8-976c-ac7a6794a909", 
    291286    "title":"Ticket Hours Grouped By Component", 
    292     "reportnumber":None, 
    293287    "version":10, 
    294288    "sql": """ 
     
    371365    "uuid":"7816f034-a174-4a94-aed6-358fb648b2fc", 
    372366    "title":"Ticket Hours Grouped By Component with Description", 
    373     "reportnumber":None, 
    374367    "version":9, 
    375368    "sql": """ 
     
    447440    "uuid":"03815803-7688-4f3a-8e65-8d254cc1d1fb", 
    448441    "title":"Ticket Hours Grouped By Milestone", 
    449     "reportnumber":None, 
    450442    "version":10, 
    451443    "sql": """ 
     
    524516    "uuid":"040c9025-7641-4d18-96ad-2b26b4095566", 
    525517    "title":"Ticket Hours Grouped By MileStone with Description", 
    526     "reportnumber":None, 
    527518    "version":10, 
    528519    "sql": """ 
  • timingandestimationplugin/branches/trac0.10/timingandestimationplugin/ticket_webui.py

    r1710 r2460  
    2424    def get_navigation_items(self, req): 
    2525        if re.search('ticket', req.path_info): 
    26             yield 'mainnav', "ticket-addon", \ 
    27                   Markup("""<script language="javascript" type="text/javascript"> 
    28                   function AddEventListener( elem, evt, func, capture){ 
    29                     capture = capture || false; 
    30                     if(elem.addEventListener) elem.addEventListener( evt, func, capture); 
    31                     else elem.attachEvent('on'+evt, func); 
    32                     return func; 
    33                   }; 
    34                   InitBilling = function(){ 
    35                     var x = document.getElementById('totalhours'); 
    36                     x = x || document.getElementById('field-totalhours'); 
    37                     if(x){ 
    38                       var p = x.parentNode; 
    39                       var n = document.createElement('span') 
    40                       n.id = x.id; 
    41                       n.innerHTML = x.value 
    42                       p.removeChild(x); 
    43                       p.appendChild(n); 
    44                     } 
    45                   } 
    46                   AddEventListener(window, 'load', InitBilling) 
    47                   </script>""") 
     26            add_script(req, 'Billing/ticket.js') 
     27            yield 'mainnav', "ticket-addon", "" 
  • timingandestimationplugin/branches/trac0.11/setup.py

    r2390 r2460  
    88      description='Plugin to make Trac support time estimation and tracking', 
    99      keywords='trac plugin estimation timetracking', 
    10       version='0.4.5', 
    11       url='http://trac-hacks.org/wiki/TimingAndEstimationPlugin', 
     10      version='0.4.6', 
     11      url='http://www.trac-hacks.org/wiki/TimingAndEstimationPlugin', 
    1212      license='http://www.opensource.org/licenses/mit-license.php', 
    1313      author='Russ Tyndall at Acceleration.net', 
     
    4747## trac-hacks user: coling 
    4848## Refactored the custom reports code to make it 
    49 ## easy for other plugins to provide reports to 
    50 ## compliment those provided by default 
     49##  easy for other plugins to provide reports to 
     50##  compliment those provided by default 
     51## Added Javascript that improves Ticket UI 
    5152 
  • timingandestimationplugin/branches/trac0.11/timingandestimationplugin/htdocs/ticket.js

    r2298 r2460  
    11(function(){ 
    2    function AddEventListener( elem, evt, func, capture){ 
     2   function teAddEventListener(elem, evt, func, capture) 
     3   { 
    34      capture = capture || false; 
    4       if(elem.addEventListener) elem.addEventListener( evt, func, capture); 
     5      if (elem.addEventListener) elem.addEventListener(evt, func, capture); 
    56      else elem.attachEvent('on'+evt, func); 
    67      return func; 
    7    }; 
     8   } 
     9    
     10// Function from: http://www.robertnyman.com/index.php?p=256 
     11   function getElementsByClassName(className, tag, elm) 
     12   { 
     13      var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)"); 
     14      var tag = tag || "*"; 
     15      var elm = elm || document; 
     16      var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag); 
     17      var returnElements = []; 
     18      var current; 
     19      var length = elements.length; 
     20      for (var i=0; i<length; i++) 
     21      { 
     22         current = elements[i]; 
     23         if(testClass.test(current.className)) 
     24         { 
     25            returnElements.push(current); 
     26         } 
     27      } 
     28      return returnElements; 
     29   } 
     30    
     31 
     32   function FloatToHoursMins(hours) 
     33   { 
     34      if (0 == hours) return hours; 
     35      mins = Math.floor((hours - Math.floor(hours)) * 60); 
     36      str = ''; 
     37      if (hours) str += Math.floor(hours) + 'h'; 
     38      if (mins) 
     39      { 
     40         if (str) str += ' '; 
     41         str += mins + 'm'; 
     42      } 
     43      return str; 
     44   } 
     45    
     46   function IntToYesNo(boolflag) 
     47   { 
     48      if (boolflag == '1') 
     49         return 'Yes'; 
     50       
     51      if (boolflag == '0') 
     52         return 'No'; 
     53       
     54      return boolflag; 
     55   } 
     56    
     57    
    858   InitBilling = function(){ 
    9       var x = document.getElementById('totalhours'); 
    10       x = x || document.getElementById('field-totalhours'); 
    11       if(x){ 
    12          var p = x.parentNode; 
    13          var n = document.createElement('span'); 
    14          n.id = x.id; 
    15          n.innerHTML = x.value; 
    16          p.removeChild(x); 
    17          p.appendChild(n); 
     59      // Convert totalhours field to non-editable 
     60      try 
     61      { 
     62         var x = document.getElementById('totalhours'); 
     63         x = x || document.getElementById('field-totalhours'); 
     64         if (x) 
     65         { 
     66            var p = x.parentNode; 
     67            var n = document.createElement('span') 
     68               n.id = x.id; 
     69            n.appendChild(document.createTextNode(x.value)); 
     70            p.removeChild(x); 
     71            p.appendChild(n); 
     72         } 
    1873      } 
     74      catch (er) {} 
     75       
     76      // Display yes/no in the summary 
     77      // if we fail, then no harm done. 
     78      try 
     79      { 
     80         var b = document.getElementById('h_billable'); 
     81         while (b) 
     82         { 
     83            if (!b.nextSibling) break; 
     84            b = b.nextSibling; 
     85            if (b.nodeName == 'TD') 
     86            { 
     87               b.innerHTML = IntToYesNo(b.innerHTML); 
     88               break; 
     89            } 
     90         } 
     91      } 
     92      catch (er) {} 
     93   
     94   
     95      // Hide the Add Hours in the title table 
     96      // if we fail, then no harm done. 
     97      try 
     98      { 
     99         var b = document.getElementById('h_hours'); 
     100         b.firstChild.nodeValue = ''; 
     101         b.nextSibling.nextSibling.firstChild.nodeValue = ''; 
     102      } 
     103      catch (er) {} 
     104       
     105       
     106      // Convert hours from float to hours minutes seconds 
     107      // if we fail, then no harm done. 
     108      try 
     109      { 
     110         fields = Array('estimatedhours', 'totalhours'); 
     111         for (i=0; i < 2; ++i)  
     112         { 
     113            var b = document.getElementById('h_' + fields[i]); 
     114            while (b) 
     115            { 
     116               if (!b.nextSibling) break; 
     117               b = b.nextSibling; 
     118               if (b.nodeName == 'TD') 
     119               { 
     120                  b.innerHTML = FloatToHoursMins(b.innerHTML); 
     121                  break; 
     122               } 
     123            } 
     124         } 
     125      } 
     126      catch (er) {} 
     127       
     128      // Convert all relevent ticket changes to hours/minutes 
     129      // if we fail, then no harm done. 
     130      try 
     131      { 
     132         changes = getElementsByClassName('changes', 'ul', document.getElementById('changelog')); 
     133         for (i=0; i < changes.length; ++i) 
     134         { 
     135            change = changes[i]; 
     136            for (j=0; j < change.childNodes.length; ++j) 
     137            { 
     138               li = change.childNodes[j]; 
     139               if (li.nodeName != 'LI') continue; 
     140               // We look for a STRONG childNode 
     141               if (!li.firstChild  
     142                   || li.firstChild.nodeName != 'STRONG' 
     143                   || !li.firstChild.firstChild 
     144                   || li.firstChild.firstChild.nodeName != '#text') 
     145               { 
     146                  continue; 
     147               } 
     148                
     149               field = li.firstChild.firstChild.nodeValue; 
     150               if (field == 'billable') 
     151               { 
     152                  for (k=1; k < li.childNodes.length; ++k) 
     153                  { 
     154                     if (li.childNodes[k].nodeName != 'EM' 
     155                         || !li.childNodes[k].firstChild 
     156                         || li.childNodes[k].firstChild.nodeName != '#text') 
     157                     { 
     158                        continue; 
     159                     } 
     160                     li.childNodes[k].firstChild.nodeValue = IntToYesNo(li.childNodes[k].firstChild.nodeValue); 
     161                  } 
     162               } 
     163               else if (field == 'hours' 
     164                        || field == 'estimatedhours' 
     165                        || field == 'totalhours') 
     166               { 
     167                  for (k=1; k < li.childNodes.length; ++k) 
     168                  { 
     169                     if (li.childNodes[k].nodeName != 'EM' 
     170                         || !li.childNodes[k].firstChild 
     171                         || li.childNodes[k].firstChild.nodeName != '#text') 
     172                     { 
     173                        continue; 
     174                     } 
     175                     li.childNodes[k].firstChild.nodeValue = FloatToHoursMins(li.childNodes[k].firstChild.nodeValue); 
     176                  } 
     177               } 
     178            } 
     179         } 
     180      } 
     181      catch (er) {} 
    19182   } 
    20    AddEventListener(window, 'load', InitBilling) 
     183 
     184   teAddEventListener(window, 'load', InitBilling) 
    21185})() 
     186 
  • timingandestimationplugin/branches/trac0.11/timingandestimationplugin/reports.py

    r2390 r2460  
    99    "uuid":"b24f08c0-d41f-4c63-93a5-25e18a8513c2", 
    1010    "title":"Ticket Work Summary", 
    11     "reportnumber":None, 
    1211    "version":14, 
    1312    "sql":""" 
     
    5150    "uuid":"af13564f-0e36-4a17-96c0-632dc68d8d14", 
    5251    "title":"Milestone Work Summary", 
    53     "reportnumber":None, 
    5452    "version":13, 
    5553    "sql":""" 
     
    9997    "uuid":"7bd4b0ce-da6d-4b11-8be3-07e65b540d99", 
    10098    "title":"Developer Work Summary", 
    101     "reportnumber":None, 
    10299    "version":13, 
    103100    "sql":""" 
     
    141138    "uuid":"8d785cdb-dcf5-43c9-b2a6-216997b0011a", 
    142139    "title": "Ticket Hours", 
    143     "reportnumber": None, 
    144140    "version":10, 
    145141    "sql": """ 
     
    211207    "uuid":"71e7c36d-e512-4d0b-b499-087d4d20ff0b", 
    212208    "title": "Ticket Hours with Description", 
    213     "reportnumber": None, 
    214209    "version":11, 
    215210    "sql": """ 
     
    290285    "uuid":"5f33b102-e6a6-47e8-976c-ac7a6794a909", 
    291286    "title":"Ticket Hours Grouped By Component", 
    292     "reportnumber":None, 
    293287    "version":10, 
    294288    "sql": """ 
     
    371365    "uuid":"7816f034-a174-4a94-aed6-358fb648b2fc", 
    372366    "title":"Ticket Hours Grouped By Component with Description", 
    373     "reportnumber":None, 
    374367    "version":9, 
    375368    "sql": """ 
     
    447440    "uuid":"03815803-7688-4f3a-8e65-8d254cc1d1fb", 
    448441    "title":"Ticket Hours Grouped By Milestone", 
    449     "reportnumber":None, 
    450442    "version":10, 
    451443    "sql": """ 
     
    524516    "uuid":"040c9025-7641-4d18-96ad-2b26b4095566", 
    525517    "title":"Ticket Hours Grouped By MileStone with Description", 
    526     "reportnumber":None, 
    527518    "version":10, 
    528519    "sql": """ 
  • timingandestimationplugin/branches/trac0.11/timingandestimationplugin/ticket_webui.py

    r2298 r2460  
    2323 
    2424    def get_navigation_items(self, req): 
    25         src = req.href.chrome("Billing/ticket.js") 
    2625        if re.search('ticket', req.path_info): 
    27             yield 'mainnav', "ticket-addon", \ 
    28                   Markup("""<script language="javascript" type="text/javascript" src="%s"></script>"""%src) 
     26            add_script(req, 'Billing/ticket.js') 
     27            yield 'mainnav', "ticket-addon", ""