TimeTracking: CustomFieldsRev2827.patch
| File CustomFieldsRev2827.patch, 4.6 kB (added by Felix Collins, 3 years ago) |
|---|
-
htdocs/js/trac.js
118 118 addLinks(container.getElementsByTagName('h' + lvl)); 119 119 } 120 120 } 121 122 123 //Functions for the processing of special custom fields 124 125 //Add the contents of newfield to oldfield 126 function accumulateInt(oldfield,newfield) 127 { 128 if (checkInt(newfield.value)) 129 { 130 if (checkInt(oldfield.defaultValue)) 131 { 132 oldfield.value = parseInt(oldfield.defaultValue, 10) + parseInt(newfield.value, 10); 133 } 134 else 135 { 136 oldfield.value = newfield.value; 137 } 138 newfield.value = "0"; 139 } 140 else 141 { 142 newfield.value = newfield.defaultValue; 143 oldfield.value = oldfield.defaultValue; 144 } 145 } 146 147 //Check whether the string can be parsed into an integer 148 function checkInt(text) 149 { 150 var result = true; 151 if (isBlank(text)) 152 { 153 result = false; 154 } 155 for(var i=0;i<text.length;i++) 156 { 157 if(!isDigit(text.charAt(i))) 158 { 159 result = false; 160 } 161 } 162 163 return result; 164 } 165 166 function isDigit(num) 167 { 168 if (num.length>1) 169 { 170 return false; 171 } 172 var string="-1234567890"; 173 if (string.indexOf(num)!=-1) 174 { 175 return true; 176 } 177 return false; 178 } 179 180 function isBlank(val) 181 { 182 if(val==null) 183 { 184 return true; 185 } 186 for(var i=0;i<val.length;i++) 187 { 188 if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")) 189 { 190 return false; 191 } 192 } 193 return true; 194 } 195 -
templates/newticket.cs
61 61 if:field.type == 'text' ?><input type="text" id="<?cs 62 62 var:name(field) ?>" name="<?cs 63 63 var:name(field) ?>" value="<?cs var:newticket[name(field)] ?>" /><?cs 64 elif:field.type == 'integer' ?><input type="text" id="<?cs 65 var:name(field) ?>" name="<?cs 66 var:name(field) ?>" value="<?cs var:newticket[name(field)] ?>" 67 onchange="javascript:if (!checkInt(this.value)){this.value = this.defaultValue;};"/><?cs 68 elif:field.type == 'set_once_integer' ?><input type="text" id="<?cs 69 var:name(field) ?>" name="<?cs 70 var:name(field) ?>" value="<?cs var:newticket[name(field)] ?>" 71 title="This field will not be editable once the ticket is created." 72 onchange="javascript:if (!checkInt(this.value)){this.value = this.defaultValue;};"/><?cs 73 elif:field.type == 'cumulative_integer' ?><input type="text" readonly id="<?cs 74 var:name(field) ?>" name="<?cs 75 var:name(field) ?>" value="<?cs var:ticket[name(field)] ?>"/> 76 <input type="text" id="<?cs var:name(field) ?>_e" name="<?cs 77 var:name(field) ?>_e" value="0" 78 title="Enter value to add to total." 79 onchange="javascript:accumulateInt(document.getElementById('<?cs var:name(field) ?>'),this);"/><?cs 64 80 elif:field.type == 'select' ?><select id="<?cs 65 81 var:name(field) ?>" name="<?cs var:name(field) ?>"><?cs 66 82 if:field.optional ?><option></option><?cs /if ?><?cs -
templates/ticket.cs
190 190 if:field.type == 'text' ?><input type="text" id="<?cs 191 191 var:name(field) ?>" name="<?cs 192 192 var:name(field) ?>" value="<?cs var:ticket[name(field)] ?>" /><?cs 193 elif:field.type == 'integer' ?><input type="text" id="<?cs 194 var:name(field) ?>" name="<?cs 195 var:name(field) ?>" value="<?cs var:ticket[name(field)] ?>" 196 onchange="javascript:if (!checkInt(this.value)){this.value = this.defaultValue;};"/><?cs 197 elif:field.type == 'set_once_integer' ?><input type="text" disabled id="<?cs 198 var:name(field) ?>" name="<?cs 199 var:name(field) ?>" value="<?cs var:ticket[name(field)] ?>"/><?cs 200 elif:field.type == 'cumulative_integer' ?><input type="text" readonly id="<?cs 201 var:name(field) ?>" name="<?cs 202 var:name(field) ?>" value="<?cs var:ticket[name(field)] ?>"/> 203 <input type="text" id="<?cs var:name(field) ?>_e" name="<?cs 204 var:name(field) ?>_e" value="0" 205 title="Enter value to add to total." 206 onchange="javascript:accumulateInt(document.getElementById('<?cs 207 var:name(field) ?>'),this);"/><?cs 193 208 elif:field.type == 'select' ?><select id="<?cs 194 209 var:name(field) ?>" name="<?cs 195 210 var:name(field) ?>"><?cs
