Open Bug 381836 Opened 17 years ago Updated 10 years ago

edit.html.tmpl - automatically convert comma to dot in hours fields

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement)

enhancement
Not set
normal

Tracking

()

People

(Reporter: nobody, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Build Identifier: Bugzilla version 3.0

Good morning,

I've created a small JS function to convert commas in time value fields to dots. This affects the fields "Orig.Est", "Hrs.worked" and "Hrs.Left" and basically adds a substring replacement function to the changed event.

The reason: on my (german) numeric keypad there's no dot and bugzilla won't accept my comma.
If you like you can add this code to the edit.html.tmpl file, so I don't have to change this with every new bugzilla version :).

I will attach a patch as soon as this bug is created...

Reproducible: Always

Steps to Reproduce:
1. open a bug
2. enter "1,5" into the "hours worked" field
3. "NaN" appears in the "Hours left" field
Actual Results:  
see Step 3.

Expected Results:  
a correct number?!
Attached patch Patch of edit.html.tmpl (obsolete) — Splinter Review
This is the patch for the "edit.html.tmpl" file I applied to my installation of bugzilla version 3.0 (released a week ago, stable release)
Attachment #265915 - Flags: review?
Comment on attachment 265915 [details] [diff] [review]
Patch of edit.html.tmpl

+    // sCz 2007-03-06

Usually we don't do this. "sCz" is cryptic for anybody reading the code, and we have CVS log for keeping code history.

Instead, you should add yourself at the beginning of the file as a contributor. We can't accept your patch if you don't include yourself in the contributor section and therefore implicitly license your patch under the license specific in the header of the file that you're modifying.
Attachment #265915 - Flags: review? → review-
OS: Windows XP → All
Hardware: PC → All
Summary: edit.html.tmpl - automatically convert comma to dot in hours fields [Enhancement Request] → edit.html.tmpl - automatically convert comma to dot in hours fields
Comment on attachment 265915 [details] [diff] [review]
Patch of edit.html.tmpl

>+  function fCorrectTimeValues() {
>+    // sCz 2007-03-06
>+    // replace every ',' with '.' in all time fields
>+    var s = '';
>+    
>+  	 s = document.changeform.work_time.value;
>+  	 s = s.replace(',','.');
>+  	 document.changeform.work_time.value = s;
>+  	 
>+  	 s = document.changeform.remaining_time.value;
>+  	 s = s.replace(',','.');
>+  	 document.changeform.remaining_time.value = s;
>+  	 
>+  	 s = document.changeform.estimated_time.value;
>+  	 s = s.replace(',','.');
>+  	 document.changeform.estimated_time.value = s;
>+  }

When you edit one field, I don't see why you should update the other 2 as well. You should pass the current field to the function foo(this) and only update this field. This would also avoid all this code duplication.
Attachment #265915 - Flags: review-
Comment on attachment 265915 [details] [diff] [review]
Patch of edit.html.tmpl

+    var s = '';
+    
+  	 s = document.changeform.work_time.value;

Also please have a consistent indentation in the proposed code, per our developer guide located at:

http://www.bugzilla.org/docs/developer.html
(In reply to comment #3)
> When you edit one field, I don't see why you should update the other 2 as well.
> You should pass the current field to the function foo(this) and only update
> this field. This would also avoid all this code duplication.
> 
It was easier and faster to code, and since the user does not note any performance breakdown I did not really mind.

(In reply to comment #4)
> Also please have a consistent indentation in the proposed code, per our
> developer guide located at:
> 
> http://www.bugzilla.org/docs/developer.html
> 
I was not aware of any developer guide when I made the addition to Bugzilla 2.2 half a year ago, sorry.
Unfortunately I don't have big time for bugzilla tuning, and since I can live with any bad indentation and duplicate code I prefer not to put more work into this, since my boss doesn't really like paying me for that :)
new (and my last try):
 - only one function
 - only changed fields are processed
 - indentation at least similar to surrounding code

I hope this one's good enough for Bugzilla :)=)
Attachment #265915 - Attachment is obsolete: true
Comment on attachment 266479 [details] [diff] [review]
new patch for edit.html

No need to use JS to fix this in the UI. The backend only needs to support both syntax (dots and commas).
Attachment #266479 - Flags: review-
  Also, I think the backend should accept *any* punctuation as meaning "period", since there's no other reason to put punctuation there, and I have no idea how many different types of punctuation various locales use for the digit separator.
IMHO decisions on digit separators should be left to Perl locale modules.

On windows, the key on numeric keypad change its value in accordance with language panel selection.

So if I am using (say) ru-RU as Accept-Language but writing in English -- there's nothing wrong if UI would not accept my input -- or I will be forced to use explicit . and , keys on main keyboard.
Status: UNCONFIRMED → NEW
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: