TimeTracking: CustomFields0.11Rev7651.patch
| File CustomFields0.11Rev7651.patch, 4.9 KB (added by FelixCollins, 5 years ago) |
|---|
-
trac/htdocs/js/trac.js
72 72 return $(elem).parents(tagName).get(0); 73 73 } 74 74 75 })(jQuery); 76 No newline at end of file 75 })(jQuery); 76 77 //Functions for the processing of special custom fields 78 79 //Add the contents of newfield to oldfield 80 function accumulateInt(oldfield,newfield) 81 { 82 if (checkInt(newfield.value)) 83 { 84 if (checkInt(oldfield.defaultValue)) 85 { 86 oldfield.value = parseInt(oldfield.defaultValue, 10) + parseInt(newfield.value, 10); 87 } 88 else 89 { 90 oldfield.value = newfield.value; 91 } 92 newfield.value = "0"; 93 } 94 else 95 { 96 newfield.value = newfield.defaultValue; 97 oldfield.value = oldfield.defaultValue; 98 } 99 } 100 101 //Check whether the string can be parsed into an integer 102 function checkInt(text) 103 { 104 var result = true; 105 if (isBlank(text)) 106 { 107 result = false; 108 } 109 for(var i=0;i<text.length;i++) 110 { 111 if(!isDigit(text.charAt(i))) 112 { 113 result = false; 114 } 115 } 116 117 return result; 118 } 119 120 function isDigit(num) 121 { 122 if (num.length>1) 123 { 124 return false; 125 } 126 var string="-1234567890"; 127 if (string.indexOf(num)!=-1) 128 { 129 return true; 130 } 131 return false; 132 } 133 134 function isBlank(val) 135 { 136 if(val==null) 137 { 138 return true; 139 } 140 for(var i=0;i<val.length;i++) 141 { 142 if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")) 143 { 144 return false; 145 } 146 } 147 return true; 148 } 149 No newline at end of file -
trac/ticket/templates/ticket.html
337 337 </label> 338 338 <py:otherwise><!--! Text input fields --> 339 339 <py:choose> 340 <span py:when="field.cc_entry"><!--! Special case for Cc: field --> 340 <!--! Special case for Cc: field --> 341 <span py:when="field.cc_entry"> 341 342 <em>${field.cc_entry}</em> 342 343 <input type="checkbox" id="field-cc" name="cc_update" 343 344 title="This checkbox allows you to add or remove yourself from the CC list." … … 349 350 title="Space or comma delimited email addresses and usernames are accepted." 350 351 name="field_${field.name}" value="${ticket[field.name]}" /> 351 352 </span> 353 <!--! Integer Field --> 354 <span py:when="field.type == 'integer'"> 355 <input type="text" id="field-${field.name}" 356 title="Integer data only" 357 name="field_${field.name}" value="${ticket[field.name]}" 358 onchange="javascript:if (!checkInt(this.value)){this.value = this.defaultValue;};" /> 359 </span> 360 <!--! Cumulative Integer Field --> 361 <span py:when="field.type == 'cumulative_integer'"> 362 <input type="text" id="field-${field.name}" readonly="true" 363 title="Add the value in the right hand box to the total. Integer data only" 364 name="field_${field.name}" value="${ticket[field.name]}"/> 365 366 <input type="text" id="field-${field.name}-acc" 367 title="Add the value in the this box to the total on the left. Integer data only" 368 name="field_${field.name}_acc" value="0" 369 onchange="javascript:accumulateInt(document.getElementById('field-${field.name}'),this);" /> 370 </span> 371 <!--! WriteOnce Integer Field --> 372 <span py:when="field.type == 'set_once_integer'"> 373 <py:if test="ticket.exists"> 374 <input type="text" id="field-${field.name}" readonly="true" 375 title="Integer data only" 376 name="field_${field.name}" value="${ticket[field.name]}"/> 377 </py:if> 378 <py:if test="not ticket.exists"> 379 <input type="text" id="field-${field.name}" 380 title="This value can only be edited on New tickets. Integer data only" 381 name="field_${field.name}" value="${ticket[field.name]}" 382 onchange="javascript:if (!checkInt(this.value)){this.value = this.defaultValue;};" /> 383 </py:if> 384 </span> 352 385 <!--! All the other text input fields --> 353 386 <input py:otherwise="" type="text" id="field-${field.name}" 354 387 name="field_${field.name}" value="${ticket[field.name]}" />
